Skip to content

Commit 07e7e82

Browse files
committed
format markdown
1 parent 8c1e4cd commit 07e7e82

File tree

5 files changed

+90
-60
lines changed

5 files changed

+90
-60
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/src/index.md

Lines changed: 67 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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

45
**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).
@@ -11,7 +12,9 @@ using Symbolics
1112
using SymbolicNumericIntegration
1213

1314
@variables x
15+
```
1416

17+
```julia
1518
julia> integrate(3x^3 + 2x - 5)
1619
(x^2 + (3//4)*(x^4) - (5x), 0, 0)
1720

@@ -21,37 +24,37 @@ julia> integrate((5 + 2x)^-1)
2124
julia> integrate(1 / (6 + x^2 - (5x)))
2225
(log(x - 3) - log(x - 2), 0, 3.339372764128952e-16)
2326

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

27-
julia> integrate(x^2/(16 + x^2))
30+
julia> integrate(x^2 / (16 + x^2))
2831
(x + 4atan((-1//4)*x), 0, 1.3318788420751984e-16)
2932

30-
julia> integrate(x^2/sqrt(4 + x^2))
33+
julia> integrate(x^2 / sqrt(4 + x^2))
3134
((1//2)*x*((4 + x^2)^0.5) - ((2//1)*log(x + sqrt(4 + x^2))), 0, 8.702422633074313e-17)
3235

33-
julia> integrate(x^2*log(x))
36+
julia> integrate(x^2 * log(x))
3437
((1//3)*log(x)*(x^3) - ((1//9)*(x^3)), 0, 0)
3538

36-
julia> integrate(x^2*exp(x))
39+
julia> integrate(x^2 * exp(x))
3740
(2exp(x) + exp(x)*(x^2) - (2x*exp(x)), 0, 0)
3841

3942
julia> integrate(tan(2x))
4043
((-1//2)*log(cos(2x)), 0, 0)
4144

42-
julia> integrate(sec(x)*tan(x))
45+
julia> integrate(sec(x) * tan(x))
4346
(cos(x)^-1, 0, 0)
4447

45-
julia> integrate(cosh(2x)*exp(x))
48+
julia> integrate(cosh(2x) * exp(x))
4649
((2//3)*exp(x)*sinh(2x) - ((1//3)*exp(x)*cosh(2x)), 0, 7.073930088880992e-8)
4750

48-
julia> integrate(cosh(x)*sin(x))
51+
julia> integrate(cosh(x) * sin(x))
4952
((1//2)*sin(x)*sinh(x) - ((1//2)*cos(x)*cosh(x)), 0, 4.8956233716268386e-17)
5053

51-
julia> integrate(cosh(2x)*sin(3x))
54+
julia> integrate(cosh(2x) * sin(3x))
5255
(0.153845sinh(2x)*sin(3x) - (0.23077cosh(2x)*cos(3x)), 0, 4.9807620877373405e-6)
5356

54-
julia> integrate(log(log(x))*(x^-1))
57+
julia> integrate(log(log(x)) * (x^-1))
5558
(log(x)*log(log(x)) - log(x), 0, 0)
5659

5760
julia> integrate(exp(x^2))
@@ -60,18 +63,18 @@ julia> integrate(exp(x^2))
6063

6164
`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:
6265

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

7679
## Testing
7780

@@ -80,29 +83,29 @@ julia> integrate(exp(x^2))
8083
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)
8184

8285
```julia
83-
using SymbolicNumericIntegration
84-
include("test/axiom.jl") # note, you may need to use the correct path
86+
using SymbolicNumericIntegration
87+
include("test/axiom.jl") # note, you may need to use the correct path
8588

86-
L = convert_axiom(:Apostle) # can also use L = convert_axiom(1)
87-
test_axiom(L, false; bypass=false, verbose=false, homotopy=true)
89+
L = convert_axiom(:Apostle) # can also use L = convert_axiom(1)
90+
test_axiom(L, false; bypass = false, verbose = false, homotopy = true)
8891
```
8992

9093
The test suites description based on the header of the files in the Rubi directory are
9194

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

107110
## Citation
108111

@@ -120,56 +123,72 @@ If you use **SymbolicNumericIntegration.jl**, please cite [Symbolic-Numeric Inte
120123
```
121124

122125
## Reproducibility
126+
123127
```@raw html
124128
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
125129
```
130+
126131
```@example
127132
using Pkg # hide
128133
Pkg.status() # hide
129134
```
135+
130136
```@raw html
131137
</details>
132138
```
139+
133140
```@raw html
134141
<details><summary>and using this machine and Julia version.</summary>
135142
```
143+
136144
```@example
137145
using InteractiveUtils # hide
138146
versioninfo() # hide
139147
```
148+
140149
```@raw html
141150
</details>
142151
```
152+
143153
```@raw html
144154
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
145155
```
156+
146157
```@example
147158
using Pkg # hide
148-
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
159+
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
149160
```
161+
150162
```@raw html
151163
</details>
152164
```
165+
153166
```@raw html
154167
You can also download the
155168
<a href="
156169
```
170+
157171
```@eval
158172
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"
173+
version = TOML.parse(read("../../Project.toml", String))["version"]
174+
name = TOML.parse(read("../../Project.toml", String))["name"]
175+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
176+
"/assets/Manifest.toml"
162177
```
178+
163179
```@raw html
164180
">manifest</a> file and the
165181
<a href="
166182
```
183+
167184
```@eval
168185
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"
186+
version = TOML.parse(read("../../Project.toml", String))["version"]
187+
name = TOML.parse(read("../../Project.toml", String))["name"]
188+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
189+
"/assets/Project.toml"
172190
```
191+
173192
```@raw html
174193
">project</a> file.
175-
```
194+
```

src/integral.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)