Skip to content

Commit 932be20

Browse files
Merge pull request #51 from shahriariravanian/main
docstrings fixed
2 parents 7db9064 + e3edee3 commit 932be20

File tree

4 files changed

+73
-65
lines changed

4 files changed

+73
-65
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SymbolicNumericIntegration"
22
uuid = "78aadeae-fbc0-11eb-17b6-c7ec0477ba9e"
33
authors = ["Shahriar Iravanian <[email protected]>"]
4-
version = "1.2.0"
4+
version = "1.2.1"
55

66
[deps]
77
DataDrivenDiffEq = "2445eb08-9709-466a-b3fc-47e12bd697a2"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ makedocs(sitename = "SymbolicNumericIntegration.jl",
1111
clean = true, doctest = false, linkcheck = true,
1212
strict = [
1313
:doctest,
14-
# :linkcheck,
14+
:linkcheck,
1515
:parse_error,
1616
:example_block,
1717
# Other available options are

docs/src/index.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ using Pkg
1616
Pkg.add("SymbolicNumericIntegration")
1717
```
1818

19+
Examples:
20+
1921
```julia
2022
using Symbolics
2123
using SymbolicNumericIntegration
@@ -90,21 +92,9 @@ julia> integrate(1 / (x*log(log(x))))
9092
(SymbolicNumericIntegration.Li(log(x)), 0, 1.1102230246251565e-16)
9193
```
9294

93-
`integrate` has the form `integrate(y; kw...)` or `integrate(y, x; kw...)`, where `y` is the integrand and the optional `x` is the variable of integration. The keyword parameters are:
94-
95-
- `abstol` (default `1e-6`): the error tolerance to accept a solution.
96-
- `symbolic` (default `true`): if true, pure symbolic integration is attempted first.
97-
- `bypass` (default `false`): if true, the whole expression is considered at once and not per term.
98-
- `num_steps` (default `2`): one plus the number of expanded basis to check (if `num_steps` is 1, only the main basis is checked).
99-
- `num_trials` (default `5`): the number of attempts to solve the integration numerically for each basis set.
100-
- `show_basis` (default `false`): print the basis set, useful for debugging. Only works if `verbose` is also set.
101-
- `homotopy` (default: `true` as of version 0.7.0): uses the continuous Homotopy operators to generate the integration candidates.
102-
- `verbose` (default `false`): if true, prints extra (and voluminous!) debugging information.
103-
- `radius` (default `1.0`): the starting radius to generate random test points.
104-
- `opt` (default `STLSQ(exp.(-10:1:0))`): the optimizer passed to `sparse_regression!`.
105-
- `max_basis` (default `110`): the maximum number of expression in the basis.
106-
- `complex_plane` (default `true`): random test points are generated on the complex plane (only over the real axis if `complex_plane` is `false`).
107-
- `use_optim` (default `false`): use Optim.jl `minimize` function instead of the STLSQ algorithm (**experimental**)
95+
```@docs
96+
integrate(eq, x; kwargs...)
97+
```
10898

10999
## Testing
110100

src/integral.jl

Lines changed: 66 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,39 @@ Base.signbit(z::Complex{T}) where {T <: Number} = signbit(real(z))
55
Base.signbit(x::SymbolicUtils.Sym{Number}) = false
66

77
"""
8-
integrate is the main entry point
9-
10-
input:
11-
------
12-
eq: a Symbolics expression to integrate
13-
x: the independent variable (optional)
14-
15-
abstol: the desired tolerance
16-
num_steps: the number of different steps with expanding basis to be tried
17-
num_trials: the number of trials in each step (no changes to the basis)
18-
radius: the radius of the disk in the complex plane to generate random test points
19-
show_basis: if true, the basis (list of candidate terms) is printed
20-
opt: the sparse regression optimizer
21-
bypass: if true, do not integrate terms separately but consider all at once
22-
symbolic: try symbolic integration first
23-
max_basis: the maximum number of candidate terms to consider
24-
verbose: print a detailed report
25-
complex_plane: generate random test points on the complex plane (if false, the points will be on real axis)
26-
homotopy: use the homotopy algorithm to generate the basis (deprecated)
27-
use_optim: use Optim.jl `minimize` function instead of the STLSQ algorithm (**experimental**)
28-
29-
output:
30-
-------
31-
solved, unsolved, err
32-
33-
solved is the solved integral and unsolved is the residual unsolved portion of the input
34-
err is the numerical error in reaching the solution
8+
integrate(eq, x; kwargs...)
9+
10+
is the main entry point to integrate a univariate expression `eq` with respect to `x' (optional).
11+
12+
```julia
13+
integrate(x * sin(2x))
14+
15+
# output
16+
17+
((1//4)*sin(2x) - (1//2)*x*cos(2x), 0, 0)
18+
```
19+
20+
kwards:
21+
-------
22+
abstol: the desired tolerance
23+
num_steps: the number of different steps with expanding basis to be tried
24+
num_trials: the number of trials in each step (no changes to the basis)
25+
radius: the radius of the disk in the complex plane to generate random test points
26+
show_basis: if true, the basis (list of candidate terms) is printed
27+
opt: the sparse regression optimizer (from DataDrivenSparse)
28+
bypass: if true do not integrate terms separately but consider all at once
29+
symbolic: try symbolic integration first
30+
max_basis: the maximum number of candidate terms to consider
31+
verbose: print a detailed report
32+
complex_plane: generate random test points on the complex plane (if false, the points will be on real axis)
33+
homotopy: use the homotopy algorithm to generate the basis (deprecated, will be removed in a future version)
34+
use_optim: use Optim.jl `minimize` function instead of the STLSQ algorithm (**experimental**)
35+
36+
output:
37+
-------
38+
solved: the solved integral
39+
unsolved: the residual unsolved portion of the input
40+
err: the numerical error in reaching the solution
3541
"""
3642
function integrate(eq, x = nothing; abstol = 1e-6, num_steps = 2, num_trials = 10,
3743
radius = 1.0,
@@ -65,13 +71,17 @@ function integrate(eq, x = nothing; abstol = 1e-6, num_steps = 2, num_trials = 1
6571
end
6672

6773
"""
68-
integrate_sum applies the integral summation rule ∫ Σᵢ fᵢ(x) dx = Σᵢ ∫ fᵢ(x) dx
74+
integrate_sum(eq, x, l; kwargs...)
6975
70-
eq: the integrand
71-
x: the indepedent variable
72-
l: a logger
76+
applies the integral summation rule ∫ Σᵢ fᵢ(x) dx = Σᵢ ∫ fᵢ(x) dx
7377
74-
output is the same as integrate
78+
inputs:
79+
------
80+
eq: the integrand
81+
x: the indepedent variable
82+
l: a logger
83+
84+
output is the same as `integrate`
7585
"""
7686
function integrate_sum(eq, x, l; bypass = false, kwargs...)
7787
solved = 0
@@ -122,14 +132,18 @@ function integrate_sum(eq, x, l; bypass = false, kwargs...)
122132
end
123133

124134
"""
125-
integrate_term is the central part of the code that tries different
126-
methods to integrate eq
127-
128-
eq: the integrand
129-
x: the indepedent variable
130-
l: a logger
131-
132-
output is the same as integrate
135+
integrate_term(eq, x, l; kwargs...)
136+
137+
is the central part of the code that tries different methods to integrate `eq`,
138+
which is assume to be a single term.
139+
140+
inputs:
141+
-------
142+
eq: the integrand
143+
x: the indepedent variable
144+
l: a logger
145+
146+
output is the same as `integrate`
133147
"""
134148
function integrate_term(eq, x, l; kwargs...)
135149
args = Dict(kwargs)
@@ -230,13 +244,15 @@ end
230244
###############################################################################
231245

232246
"""
233-
1try_integrate` is the main dispatch point to call different sparse solvers
234-
`try_integrate` tries to find a linear combination of the basis, whose
235-
derivative is equal to eq
236-
237-
output
238-
-------
239-
integral, error
247+
try_integrate(eq, x, basis, radius; kwargs...)
248+
249+
is the main dispatch point to call different sparse solvers. It tries to
250+
find a linear combination of the basis, whose derivative is equal to eq
251+
252+
output:
253+
-------
254+
solved: the solved integration problem or 0 otherwise
255+
err: the numerical error in reaching the solution
240256
"""
241257
function try_integrate(eq, x, basis, radius; kwargs...)
242258
args = Dict(kwargs)
@@ -256,7 +272,9 @@ end
256272
#################################################################################
257273

258274
"""
259-
integrate_basis is used for debugging and should not be called in the course of normal execution
275+
integrate_basis(eq, x; kwargs...)
276+
277+
is used for debugging and should not be called in the course of normal execution
260278
"""
261279
function integrate_basis(eq, x = var(eq); abstol = 1e-6, radius = 1.0, complex_plane = true)
262280
eq = cache(expand(eq))

0 commit comments

Comments
 (0)