Skip to content

Commit a3a8182

Browse files
Merge pull request #35 from ArnoStrouwen/docs
various doc and style improvements
2 parents 8c1e4cd + dd2b59e commit a3a8182

File tree

6 files changed

+127
-64
lines changed

6 files changed

+127
-64
lines changed

.JuliaFormatter.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
style = "sciml"
1+
style = "sciml"
2+
format_markdown = true

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![codecov](https://codecov.io/gh/SciML/SymbolicNumericIntegration.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/SymbolicNumericIntegration.jl)
77
[![Build Status](https://github.com/SciML/SymbolicNumericIntegration.jl/workflows/CI/badge.svg)](https://github.com/SciML/SymbolicNumericIntegration.jl/actions?query=workflow%3ACI)
88

9-
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
9+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
1010
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
1111

1212
**SymbolicNumericIntegration.jl** is a hybrid symbolic/numerical integration package that works on the [Julia Symbolics](https://github.com/JuliaSymbolics/Symbolics.jl) expressions.
@@ -26,19 +26,29 @@ using SymbolicNumericIntegration
2626

2727
@variables x
2828

29-
julia> integrate(3x^3 + 2x - 5)
29+
integrate(3x^3 + 2x - 5)
30+
```
31+
32+
```
3033
(x^2 + (3//4)*(x^4) - (5x), 0, 0)
3134
```
3235

3336
# Citation
37+
3438
If you use SymbolicNumericIntegration.jl in your research, please cite [this paper](https://arxiv.org/abs/2201.12468):
39+
3540
```
36-
@article{Iravanian2022,
37-
author = {Shahriar Iravanian and Carl Julius Martensen and Alessandro Cheli and Shashi Gowda and Anand Jain and Julia Computing and Yingbo Ma and Chris Rackauckas},
38-
doi = {10.48550/arxiv.2201.12468},
39-
month = {1},
40-
title = {Symbolic-Numeric Integration of Univariate Expressions based on Sparse Regression},
41-
url = {https://arxiv.org/abs/2201.12468v2},
42-
year = {2022},
41+
42+
@article{Iravanian2022,
43+
author = {Shahriar Iravanian and Carl Julius Martensen and Alessandro Cheli and Shashi Gowda and Anand Jain and Julia Computing and Yingbo Ma and Chris Rackauckas},
44+
doi = {10.48550/arxiv.2201.12468},
45+
month = {1},
46+
title = {Symbolic-Numeric Integration of Univariate Expressions based on Sparse Regression},
47+
url = {https://arxiv.org/abs/2201.12468v2},
48+
year = {2022},
4349
}
50+
51+
```
52+
53+
```
4454
```

docs/make.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ include("pages.jl")
88
makedocs(sitename = "SymbolicNumericIntegration.jl",
99
authors = "Shahriar Iravanian",
1010
modules = [SymbolicNumericIntegration],
11-
clean = true, doctest = false,
11+
clean = true, doctest = false, linkcheck = true,
12+
strict = [
13+
:doctest,
14+
:linkcheck,
15+
:parse_error,
16+
:example_block,
17+
# Other available options are
18+
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
19+
],
1220
format = Documenter.HTML(analytics = "UA-90474609-3",
1321
assets = ["assets/favicon.ico"],
1422
canonical = "https://docs.sciml.ai/SymbolicNumericIntegration/stable/"),

docs/src/index.md

Lines changed: 94 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
# SymbolicNumericIntegration.jl
2+
23
**SymbolicNumericIntegration.jl** is a hybrid symbolic/numerical integration package that works on the [Julia Symbolics](https://docs.sciml.ai/Symbolics/stable/) expressions.
34

4-
**SymbolicNumericIntegration.jl** uses a randomized algorithm based on a hybrid of the *method of undetermined coefficients* and *sparse regression* and is able to solve a large subset of basic standard integrals (polynomials, exponential/logarithmic, trigonometric and hyperbolic, inverse trigonometric and hyperbolic, rational and square root).
5-
The basis of how it works and the theory of integration using the Symbolic-Numeric methods refer to [Basis of Symbolic-Numeric Integration](docs/theory.ipynb).
5+
**SymbolicNumericIntegration.jl** uses a randomized algorithm based on a hybrid of the *method of undetermined coefficients* and *sparse regression* and can solve a large subset of basic standard integrals (polynomials, exponential/logarithmic, trigonometric and hyperbolic, inverse trigonometric and hyperbolic, rational and square root).
6+
The basis of how it works and the theory of integration using the Symbolic-Numeric methods refer to [Basis of Symbolic-Numeric Integration](https://github.com/SciML/SymbolicNumericIntegration.jl/blob/main/docs/theory.ipynb).
67

78
Function `integrate` returns the integral of a univariate expression with *constant* real or complex coefficients. `integrate` returns a tuple with three values. The first one is the solved integral, the second one is the sum of the unsolved terms, and the third value is the residual error. If `integrate` is successful, the unsolved portion is reported as 0.
89

10+
## Installation
11+
12+
To install SymbolicNumericIntegration.jl, use the Julia package manager:
13+
14+
```julia
15+
using Pkg
16+
Pkg.add("SymbolicNumericIntegration")
17+
```
18+
919
```julia
1020
using Symbolics
1121
using SymbolicNumericIntegration
1222

1323
@variables x
24+
```
1425

26+
```julia
1527
julia> integrate(3x^3 + 2x - 5)
1628
(x^2 + (3//4)*(x^4) - (5x), 0, 0)
1729

@@ -21,37 +33,37 @@ julia> integrate((5 + 2x)^-1)
2133
julia> integrate(1 / (6 + x^2 - (5x)))
2234
(log(x - 3) - log(x - 2), 0, 3.339372764128952e-16)
2335

24-
y = integrate(1 / (x^2 - 16))
36+
julia> integrate(1 / (x^2 - 16))
2537
((1//8)*log(x - 4) - ((1//8)*log(4 + x)), 0, 1.546926788028958e-16)
2638

27-
julia> integrate(x^2/(16 + x^2))
39+
julia> integrate(x^2 / (16 + x^2))
2840
(x + 4atan((-1//4)*x), 0, 1.3318788420751984e-16)
2941

30-
julia> integrate(x^2/sqrt(4 + x^2))
42+
julia> integrate(x^2 / sqrt(4 + x^2))
3143
((1//2)*x*((4 + x^2)^0.5) - ((2//1)*log(x + sqrt(4 + x^2))), 0, 8.702422633074313e-17)
3244

33-
julia> integrate(x^2*log(x))
45+
julia> integrate(x^2 * log(x))
3446
((1//3)*log(x)*(x^3) - ((1//9)*(x^3)), 0, 0)
3547

36-
julia> integrate(x^2*exp(x))
48+
julia> integrate(x^2 * exp(x))
3749
(2exp(x) + exp(x)*(x^2) - (2x*exp(x)), 0, 0)
3850

3951
julia> integrate(tan(2x))
4052
((-1//2)*log(cos(2x)), 0, 0)
4153

42-
julia> integrate(sec(x)*tan(x))
54+
julia> integrate(sec(x) * tan(x))
4355
(cos(x)^-1, 0, 0)
4456

45-
julia> integrate(cosh(2x)*exp(x))
57+
julia> integrate(cosh(2x) * exp(x))
4658
((2//3)*exp(x)*sinh(2x) - ((1//3)*exp(x)*cosh(2x)), 0, 7.073930088880992e-8)
4759

48-
julia> integrate(cosh(x)*sin(x))
60+
julia> integrate(cosh(x) * sin(x))
4961
((1//2)*sin(x)*sinh(x) - ((1//2)*cos(x)*cosh(x)), 0, 4.8956233716268386e-17)
5062

51-
julia> integrate(cosh(2x)*sin(3x))
63+
julia> integrate(cosh(2x) * sin(3x))
5264
(0.153845sinh(2x)*sin(3x) - (0.23077cosh(2x)*cos(3x)), 0, 4.9807620877373405e-6)
5365

54-
julia> integrate(log(log(x))*(x^-1))
66+
julia> integrate(log(log(x)) * (x^-1))
5567
(log(x)*log(log(x)) - log(x), 0, 0)
5668

5769
julia> integrate(exp(x^2))
@@ -60,18 +72,18 @@ julia> integrate(exp(x^2))
6072

6173
`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:
6274

63-
* `abstol` (default `1e-6`): the error tolerance to accept a solution.
64-
* `symbolic` (default `true`): if true, pure symbolic integration is attempted first.
65-
* `bypass` (default `false`): if true, the whole expression is considered at once and not per term.
66-
* `num_steps` (default `2`): one plus the number of expanded basis to check (if `num_steps` is 1, only the main basis is checked).
67-
* `num_trials` (default `5`): the number of attempts to solve the integration numerically for each basis set.
68-
* `show_basis` (default `false`): print the basis set, useful for debugging. Only works if `verbose` is also set.
69-
* `homotopy` (default: `true` as of version 0.7.0): uses the continuous Homotopy operators to generate the integration candidates.
70-
* `verbose` (default `false`): if true, prints extra (and voluminous!) debugging information.
71-
* `radius` (default `1.0`): the starting radius to generate random test points.
72-
* `opt` (default `STLSQ(exp.(-10:1:0))`): the optimizer passed to `sparse_regression!`.
73-
* `max_basis` (default `110`): the maximum number of expression in the basis.
74-
* `complex_plane` (default `true`): random test points are generated on the complex plane (only over the real axis if `complex_plane` is `false`).
75+
- `abstol` (default `1e-6`): the error tolerance to accept a solution.
76+
- `symbolic` (default `true`): if true, pure symbolic integration is attempted first.
77+
- `bypass` (default `false`): if true, the whole expression is considered at once and not per term.
78+
- `num_steps` (default `2`): one plus the number of expanded basis to check (if `num_steps` is 1, only the main basis is checked).
79+
- `num_trials` (default `5`): the number of attempts to solve the integration numerically for each basis set.
80+
- `show_basis` (default `false`): print the basis set, useful for debugging. Only works if `verbose` is also set.
81+
- `homotopy` (default: `true` as of version 0.7.0): uses the continuous Homotopy operators to generate the integration candidates.
82+
- `verbose` (default `false`): if true, prints extra (and voluminous!) debugging information.
83+
- `radius` (default `1.0`): the starting radius to generate random test points.
84+
- `opt` (default `STLSQ(exp.(-10:1:0))`): the optimizer passed to `sparse_regression!`.
85+
- `max_basis` (default `110`): the maximum number of expression in the basis.
86+
- `complex_plane` (default `true`): random test points are generated on the complex plane (only over the real axis if `complex_plane` is `false`).
7587

7688
## Testing
7789

@@ -80,29 +92,29 @@ julia> integrate(exp(x^2))
8092
Additionally, 12 test suites from the *Rule-based Integrator* ([Rubi](https://rulebasedintegration.org/)) are included in the `/test` directory. For example, we can test the first one as below ([Axiom](http://www.axiom-developer.org/) refers to the format of the test files)
8193

8294
```julia
83-
using SymbolicNumericIntegration
84-
include("test/axiom.jl") # note, you may need to use the correct path
95+
using SymbolicNumericIntegration
96+
include("test/axiom.jl") # note, you may need to use the correct path
8597

86-
L = convert_axiom(:Apostle) # can also use L = convert_axiom(1)
87-
test_axiom(L, false; bypass=false, verbose=false, homotopy=true)
98+
L = convert_axiom(:Apostle) # can also use L = convert_axiom(1)
99+
test_axiom(L, false; bypass = false, verbose = false, homotopy = true)
88100
```
89101

90102
The test suites description based on the header of the files in the Rubi directory are
91103

92-
| name | id | comment |
93-
|-------------|----|------------------------------------------|
94-
|:Apostle | 1 | Tom M. Apostol - Calculus, Volume I, Second Edition (1967) |
95-
|:Bondarenko | 2 | Vladimir Bondarenko Integration Problems |
96-
|:Bronstein | 3 | Manuel Bronstein - Symbolic Integration Tutorial (1998) |
97-
|:Charlwood | 4 | Kevin Charlwood - Integration on Computer Algebra Systems (2008) |
98-
|:Hearn | 5 | Anthony Hearn - Reduce Integration Test Package |
99-
|:Hebisch | 6 | Waldek Hebisch - email May 2013 |
100-
|:Jeffrey | 7 | David Jeffrey - Rectifying Transformations for Trig Integration (1997) |
101-
|:Moses | 8 | Joel Moses - Symbolic Integration Ph.D. Thesis (1967) |
102-
|:Stewart | 9 | James Stewart - Calculus (1987) |
103-
|:Timofeev | 10 | A. F. Timofeev - Integration of Functions (1948) |
104-
|:Welz | 11 | Martin Welz - posts on Sci.Math.Symbolic |
105-
|:Webster | 12 | Michael Wester |
104+
| name | id | comment |
105+
|:----------- |:-- |:---------------------------------------------------------------------- |
106+
| :Apostle | 1 | Tom M. Apostol - Calculus, Volume I, Second Edition (1967) |
107+
| :Bondarenko | 2 | Vladimir Bondarenko Integration Problems |
108+
| :Bronstein | 3 | Manuel Bronstein - Symbolic Integration Tutorial (1998) |
109+
| :Charlwood | 4 | Kevin Charlwood - Integration on Computer Algebra Systems (2008) |
110+
| :Hearn | 5 | Anthony Hearn - Reduce Integration Test Package |
111+
| :Hebisch | 6 | Waldek Hebisch - email May 2013 |
112+
| :Jeffrey | 7 | David Jeffrey - Rectifying Transformations for Trig Integration (1997) |
113+
| :Moses | 8 | Joel Moses - Symbolic Integration Ph.D. Thesis (1967) |
114+
| :Stewart | 9 | James Stewart - Calculus (1987) |
115+
| :Timofeev | 10 | A. F. Timofeev - Integration of Functions (1948) |
116+
| :Welz | 11 | Martin Welz - posts on Sci.Math.Symbolic |
117+
| :Webster | 12 | Michael Wester |
106118

107119
## Citation
108120

@@ -119,57 +131,89 @@ If you use **SymbolicNumericIntegration.jl**, please cite [Symbolic-Numeric Inte
119131
}
120132
```
121133

134+
## Contributing
135+
136+
- Please refer to the
137+
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
138+
for guidance on PRs, issues, and other matters relating to contributing to SciML.
139+
140+
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
141+
- There are a few community forums:
142+
143+
+ The #diffeq-bridged and #sciml-bridged channels in the
144+
[Julia Slack](https://julialang.org/slack/)
145+
+ The #diffeq-bridged and #sciml-bridged channels in the
146+
[Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
147+
+ On the [Julia Discourse forums](https://discourse.julialang.org)
148+
+ See also [SciML Community page](https://sciml.ai/community/)
149+
122150
## Reproducibility
151+
123152
```@raw html
124153
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
125154
```
155+
126156
```@example
127157
using Pkg # hide
128158
Pkg.status() # hide
129159
```
160+
130161
```@raw html
131162
</details>
132163
```
164+
133165
```@raw html
134166
<details><summary>and using this machine and Julia version.</summary>
135167
```
168+
136169
```@example
137170
using InteractiveUtils # hide
138171
versioninfo() # hide
139172
```
173+
140174
```@raw html
141175
</details>
142176
```
177+
143178
```@raw html
144179
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
145180
```
181+
146182
```@example
147183
using Pkg # hide
148-
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
184+
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
149185
```
186+
150187
```@raw html
151188
</details>
152189
```
190+
153191
```@raw html
154192
You can also download the
155193
<a href="
156194
```
195+
157196
```@eval
158197
using TOML
159-
version = TOML.parse(read("../../Project.toml",String))["version"]
160-
name = TOML.parse(read("../../Project.toml",String))["name"]
161-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Manifest.toml"
198+
version = TOML.parse(read("../../Project.toml", String))["version"]
199+
name = TOML.parse(read("../../Project.toml", String))["name"]
200+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
201+
"/assets/Manifest.toml"
162202
```
203+
163204
```@raw html
164205
">manifest</a> file and the
165206
<a href="
166207
```
208+
167209
```@eval
168210
using TOML
169-
version = TOML.parse(read("../../Project.toml",String))["version"]
170-
name = TOML.parse(read("../../Project.toml",String))["name"]
171-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Project.toml"
211+
version = TOML.parse(read("../../Project.toml", String))["version"]
212+
name = TOML.parse(read("../../Project.toml", String))["name"]
213+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
214+
"/assets/Project.toml"
172215
```
216+
173217
```@raw html
174218
">project</a> file.
175-
```
219+
```

src/integral.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Base.signbit(x::SymbolicUtils.Sym{Number, Nothing}) = false
2323
max_basis: the maximum number of candidate terms to consider
2424
verbose: print a detailed report
2525
complex_plane: generate random test points on the complex plane (if false, the points will be on real axis)
26-
homotomy: use the homotopy algorithm to generat the basis
26+
homotopy: use the homotopy algorithm to generate the basis
2727
2828
output:
2929
-------
@@ -335,7 +335,7 @@ function sparse_fit(T, A, x, basis, Δbasis, opt; abstol = 1e-6)
335335
if sum(iscomplex.(q)) > 2
336336
return nothing, Inf
337337
end # eliminating complex coefficients
338-
return sum(q[i] * basis[i] for i = 1:length(basis) if q[i] != 0; init = zero(x)),
338+
return sum(q[i] * basis[i] for i in 1:length(basis) if q[i] != 0; init = zero(x)),
339339
abs(ϵ)
340340
catch e
341341
println("Error from sparse_fit", e)

src/rules.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function decompose_rational(eq)
220220

221221
q₀ = A \ b
222222
q = nice_parameter.(q₀)
223-
p = sum(F[i] * q[i] for i = 1:n if q[i] != 0; init = zero(x))
223+
p = sum(F[i] * q[i] for i in 1:n if q[i] != 0; init = zero(x))
224224
return p
225225
end
226226

0 commit comments

Comments
 (0)