Skip to content

Commit 4a11131

Browse files
Merge pull request #123 from shahriariravanian/main
ver 1.9.1. Mainly fixing definite integration. Downgrade test fails, likely related to a bug in Pkg.jl during parallel pre-compilation.
2 parents 4462ecc + 1961140 commit 4a11131

File tree

6 files changed

+58
-40
lines changed

6 files changed

+58
-40
lines changed

Project.toml

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

66
[deps]
77
DataDrivenDiffEq = "2445eb08-9709-466a-b3fc-47e12bd697a2"
88
DataDrivenSparse = "5b588203-7d8b-4fab-a537-c31a7f73f46b"
99
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
10+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1011
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1112
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1213
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,26 @@ integrate(sin(a * x) * cos(b * x), x; symbolic = true, detailed = false)
3838

3939
# Citation
4040

41-
If you use SymbolicNumericIntegration.jl in your research, please cite [this paper](https://arxiv.org/abs/2201.12468):
41+
If you use SymbolicNumericIntegration.jl in your research, please cite the [arxiv](https://arxiv.org/abs/2201.12468) and/or [ISSAC'24](https://dl.acm.org/doi/abs/10.1145/3666000.3669714) papers:
4242

4343
```
4444
45+
@inproceedings{10.1145/3666000.3669714,
46+
author = {Iravanian, Shahriar and Gowda, Shashi and Rackauckas, Christopher},
47+
title = {Hybrid Symbolic-Numeric and Numerically-Assisted Symbolic Integration},
48+
year = {2024},
49+
isbn = {9798400706967},
50+
publisher = {Association for Computing Machinery},
51+
address = {New York, NY, USA},
52+
url = {https://doi.org/10.1145/3666000.3669714},
53+
doi = {10.1145/3666000.3669714},
54+
pages = {410–418},
55+
numpages = {9},
56+
keywords = {sparse regression, symbolic integration, symbolic-numeric computation},
57+
location = {Raleigh, NC, USA},
58+
series = {ISSAC '24}
59+
}
60+
4561
@article{Iravanian2022,
4662
author = {Shahriar Iravanian and Carl Julius Martensen and Alessandro Cheli and Shashi Gowda and Anand Jain and Yingbo Ma and Chris Rackauckas},
4763
doi = {10.48550/arxiv.2201.12468},

src/SymbolicNumericIntegration.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module SymbolicNumericIntegration
22

3+
using ForwardDiff
34
using TermInterface: iscall
45
using SymbolicUtils
56
using SymbolicUtils: operation, arguments

src/homotopy.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ partial_int_rules = [
133133
@rule 𝛷(~x, coth(~u)) => (log(sinh(~u)), ~u)
134134
# 1/trigonometric functions
135135
@rule 𝛷(~x, 1 /
136-
sin(~u)) => (log(csc(~u) + cot(~u)) + log(sin(~u)), ~u)
136+
sin(~u)) => (log(csc(~u) + cot(~u)) + log(sin(~u)), ~u)
137137
@rule 𝛷(~x, 1 /
138-
cos(~u)) => (log(sec(~u) + tan(~u)) + log(cos(~u)), ~u)
138+
cos(~u)) => (log(sec(~u) + tan(~u)) + log(cos(~u)), ~u)
139139
@rule 𝛷(~x, 1 / tan(~u)) => (log(sin(~u)) + log(tan(~u)), ~u)
140140
@rule 𝛷(~x, 1 / csc(~u)) => (cos(~u) + log(csc(~u)), ~u)
141141
@rule 𝛷(~x, 1 / sec(~u)) => (sin(~u) + log(sec(~u)), ~u)
@@ -163,7 +163,7 @@ partial_int_rules = [
163163
@rule 𝛷(~x, acoth(~u)) => (~u * acot(~u) + log(~u + 1), ~u)
164164
# logarithmic and exponential functions
165165
@rule 𝛷(~x,
166-
log(~u)) => (
166+
log(~u)) => (
167167
~u + ~u * log(~u) +
168168
sum(pow_minus_rule(~u, ~x, -1); init = one(~u)),
169169
~u)
@@ -176,18 +176,18 @@ partial_int_rules = [
176176
@rule 𝛷(~x, sqrt(~u)) => (
177177
sum(sqrt_rule(~u, ~x, 0.5); init = one(~u)), ~u)
178178
@rule 𝛷(~x, 1 /
179-
sqrt(~u)) => (
179+
sqrt(~u)) => (
180180
sum(sqrt_rule(~u, ~x, -0.5); init = one(~u)), ~u)
181181
# rational functions
182182
@rule 𝛷(~x,
183-
1 / ^(~u::is_univar_poly, ~k::is_pos_int)) => (
183+
1 / ^(~u::is_univar_poly, ~k::is_pos_int)) => (
184184
sum(pow_minus_rule(~u,
185185
~x,
186186
-~k);
187187
init = one(~u)),
188188
~u)
189189
@rule 𝛷(
190-
~x, 1 / ~u::is_univar_poly) => (
190+
~x, 1 / ~u::is_univar_poly) => (
191191
sum(pow_minus_rule(~u, ~x, -1); init = one(~u)),
192192
~u)
193193
@rule 𝛷(~x, ^(~u, -1)) => (log(~u) + ~u * log(~u), ~u)
@@ -245,7 +245,7 @@ function pow_minus_rule(p, x, k; abstol = 1e-8)
245245
end
246246

247247
function sqrt_rule(p, x, k)
248-
h = Any[p ^ k, p ^ (k + 1)]
248+
h = Any[p^k, p^(k + 1)]
249249

250250
Δ = diff(p, x)
251251
push!(h, log/ 2 + sqrt(p)))

src/integral.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ julia> integrate(x * sin(a * x), (x, 0, 1); symbolic = true, detailed = false)
4949
5050
Returns a tuple of (solved, unsolved, err) if `detailed == true`, where
5151
52-
solved: the solved integral
52+
solved: the solved integral
5353
unsolved: the residual unsolved portion of the input
5454
err: the numerical error in reaching the solution
5555
@@ -122,7 +122,7 @@ function integrate(eq, xx::Tuple; kwargs...)
122122
sol = integrate(eq, x; kwargs...)
123123

124124
if sol isa Tuple
125-
if first(sol) != 0 && sol[2] == 0
125+
if !isequal(first(sol), 0) && sol[2] == 0
126126
return substitute(first(sol), Dict(x => hi)) -
127127
substitute(first(sol), Dict(x => lo))
128128
else
@@ -200,7 +200,7 @@ function integrate_sum(eq, x; bypass = false, kwargs...)
200200
return expand(solved), unsolved, ε₀
201201
end
202202

203-
# integrate_term is the central part of the univariate integration code that
203+
# integrate_term is the central part of the univariate integration code that
204204
# tries different methods to integrate `eq`.
205205
#
206206
# note: this function will be replaced with solver(prob::Problem) in symbolic.jl
@@ -295,8 +295,8 @@ function integrate_term(eq, x; kwargs...)
295295
end
296296
end
297297

298-
# try_integrate is the main dispatch point to call different sparse solvers.
299-
# It tries to find a linear combination of the basis, whose derivative is
298+
# try_integrate is the main dispatch point to call different sparse solvers.
299+
# It tries to find a linear combination of the basis, whose derivative is
300300
# equal to eq
301301
function try_integrate(eq, x, basis; plan = default_plan())
302302
if isempty(basis)

src/rules.jl

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,27 @@ trigs_rules = [@rule tan(~x) => sin(~x) / cos(~x)
110110
@rule csc(~x) => one(~x) / sin(~x)
111111
@rule cot(~x) => cos(~x) / sin(~x)
112112
@rule sin(~n::is_int_gt_one *
113-
~x) => sin((~n - 1) * ~x) * cos(~x) +
114-
cos((~n - 1) * ~x) * sin(~x)
113+
~x) => sin((~n - 1) * ~x) * cos(~x) +
114+
cos((~n - 1) * ~x) * sin(~x)
115115
@rule cos(~n::is_int_gt_one *
116-
~x) => cos((~n - 1) * ~x) * cos(~x) -
117-
sin((~n - 1) * ~x) * sin(~x)
116+
~x) => cos((~n - 1) * ~x) * cos(~x) -
117+
sin((~n - 1) * ~x) * sin(~x)
118118
@rule tan(~n::is_int_gt_one *
119-
~x) => (tan((~n - 1) * ~x) + tan(~x)) /
120-
(1 - tan((~n - 1) * ~x) * tan(~x))
119+
~x) => (tan((~n - 1) * ~x) + tan(~x)) /
120+
(1 - tan((~n - 1) * ~x) * tan(~x))
121121
@rule csc(~n::is_int_gt_one *
122-
~x) => sec((~n - 1) * ~x) * sec(~x) *
123-
csc((~n - 1) * ~x) * csc(~x) /
124-
(sec((~n - 1) * ~x) * csc(~x) +
125-
csc((~n - 1) * ~x) * sec(~x))
122+
~x) => sec((~n - 1) * ~x) * sec(~x) *
123+
csc((~n - 1) * ~x) * csc(~x) /
124+
(sec((~n - 1) * ~x) * csc(~x) +
125+
csc((~n - 1) * ~x) * sec(~x))
126126
@rule sec(~n::is_int_gt_one *
127-
~x) => sec((~n - 1) * ~x) * sec(~x) *
128-
csc((~n - 1) * ~x) * csc(~x) /
129-
(csc((~n - 1) * ~x) * csc(~x) -
130-
sec((~n - 1) * ~x) * sec(~x))
127+
~x) => sec((~n - 1) * ~x) * sec(~x) *
128+
csc((~n - 1) * ~x) * csc(~x) /
129+
(csc((~n - 1) * ~x) * csc(~x) -
130+
sec((~n - 1) * ~x) * sec(~x))
131131
@rule cot(~n::is_int_gt_one *
132-
~x) => (cot((~n - 1) * ~x) * cot(~x) - 1) /
133-
(cot((~n - 1) * ~x) + cot(~x))
132+
~x) => (cot((~n - 1) * ~x) * cot(~x) - 1) /
133+
(cot((~n - 1) * ~x) + cot(~x))
134134
@rule 1 / sin(~x) => csc(~x)
135135
@rule 1 / cos(~x) => sec(~x)
136136
@rule 1 / tan(~x) => cot(~x)
@@ -147,21 +147,21 @@ trigs_rules = [@rule tan(~x) => sin(~x) / cos(~x)
147147
@rule cos(~x + ~y) => cos(~x) * cos(~y) - sin(~x) * sin(~y)
148148
@rule tan(~x + ~y) => (tan(~x) + tan(~y)) / (1 - tan(~x) * tan(~y))
149149
@rule csc(~x +
150-
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
151-
(sec(~x) * csc(~y) + csc(~x) * sec(~y))
150+
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
151+
(sec(~x) * csc(~y) + csc(~x) * sec(~y))
152152
@rule sec(~x +
153-
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
154-
(csc(~x) * csc(~y) - sec(~x) * sec(~y))
153+
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
154+
(csc(~x) * csc(~y) - sec(~x) * sec(~y))
155155
@rule cot(~x + ~y) => (cot(~x) * cot(~y) - 1) / (cot(~x) + cot(~y))
156156
@rule sin(~x - ~y) => sin(~x) * cos(~y) - cos(~x) * sin(~y)
157157
@rule cos(~x - ~y) => cos(~x) * cos(~y) + sin(~x) * sin(~y)
158158
@rule tan(~x - ~y) => (tan(~x) - tan(~y)) / (1 + tan(~x) * tan(~y))
159159
@rule csc(~x -
160-
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
161-
(sec(~x) * csc(~y) - csc(~x) * sec(~y))
160+
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
161+
(sec(~x) * csc(~y) - csc(~x) * sec(~y))
162162
@rule sec(~x -
163-
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
164-
(csc(~x) * csc(~y) + sec(~x) * sec(~y))
163+
~y) => sec(~x) * sec(~y) * csc(~x) * csc(~y) /
164+
(csc(~x) * csc(~y) + sec(~x) * sec(~y))
165165
@rule cot(~x - ~y) => (cot(~x) * cot(~y) + 1) / (cot(~x) - cot(~y))
166166

167167
# @rule sin(2*~x) => 2*sin(~x)*cos(~x)
@@ -250,8 +250,8 @@ rational_rules = [@rule Ω(+(~~xs)) => sum(map(Ω, ~~xs))
250250
decompose_rational(~x),
251251
-~k))
252252
@rule Ω(~x /
253-
^(~y::is_poly, ~k::is_pos_int)) => expand(~x *
254-
^(
253+
^(~y::is_poly, ~k::is_pos_int)) => expand(~x *
254+
^(
255255
decompose_rational(~y),
256256
~k))
257257
@rule Ω(~x / ~y::is_poly) => expand(~x * decompose_rational(~y))

0 commit comments

Comments
 (0)