-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1096 from LilithHafner/lh/limits
Add dep on SymbolicLimits.jl and export `limit`
- Loading branch information
Showing
6 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Symbolic Limits | ||
|
||
Experimental symbolic limit support is provided by the [`limit`](@ref) function, documented | ||
below. See [SymbolicLimits.jl](https://github.com/SciML/SymbolicLimits.jl) for more | ||
information and implementation details. | ||
|
||
```@docs | ||
limit | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
limit(expr, var, h[, side::Symbol]) | ||
Compute the limit of `expr` as `var` approaches `h`. | ||
`side` indicates the direction from which `var` approaches `h`. It may be one of `:left`, | ||
`:right`, or `:both`. If `side` is `:both` and the two sides do not align, an error is | ||
thrown. Side defaults to `:both` for finite `h`, `:left` for `h = Inf`, and `:right` for | ||
`h = -Inf`. | ||
`expr` must be compoesed of `log`, `exp`, constants, and the rational opperators `+`, `-`, | ||
`*`, and `/`. This limitation may eventually be relaxed. | ||
!!! warning | ||
Because symbolic limit computation is undecidable, this function necessarily employs | ||
heuristics and may occasionally return wrong answers. Nevertheless, please report wrong | ||
answers as issues as we aim to have heuristics that produce correct answers in all | ||
practical cases. | ||
""" | ||
limit(expr, var, h, side...) = SymbolicLimits.limit(expr, var, h, side...)[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Symbolics, Test | ||
|
||
@testset "limits" begin | ||
@syms x | ||
@test limit(exp(x+exp(-x))-exp(x), x, Inf) == 1 | ||
@test limit(x^7/exp(x), x, Inf) == 0 | ||
@test limit(log(log(x*exp(x*exp(x))+1))-exp(exp(log(log(x))+1/x)), x, Inf) == 0 | ||
@test limit(2exp(-x)/exp(-x), x, 0) == 2 | ||
|
||
@test_throws ArgumentError limit(1/x, x, 0) | ||
@test limit(1/x, x, 0, :left)[1] == -Inf | ||
@test limit(1/x, x, 0, :right)[1] == Inf | ||
end |