Skip to content

Commit 4069a87

Browse files
transition from @syms to @variables
1 parent 423e3e0 commit 4069a87

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
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 = "0.8.0"
4+
version = "0.8.1"
55

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

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Function `integrate` returns the integral of a univariate expression with *const
1111
using SymbolicUtils
1212
using SymbolicNumericIntegration
1313

14-
@syms x
14+
@variables x
1515

1616
julia> integrate(3x^3 + 2x - 5)
1717
(x^2 + (3//4)*(x^4) - (5x), 0, 0)
@@ -104,3 +104,18 @@ The test suites description based on the header of the files in the Rubi directo
104104
|:Timofeev | 10 | A. F. Timofeev - Integration of Functions (1948) |
105105
|:Welz | 11 | Martin Welz - posts on Sci.Math.Symbolic |
106106
|:Webster | 12 | Michael Wester |
107+
108+
## Citation
109+
110+
If you use **SymbolicNumericIntegration.jl**, please cite [Symbolic-Numeric Integration of Univariate Expressions based on Sparse Regression](https://arxiv.org/abs/2201.12468):
111+
112+
```
113+
@article{Iravanian2022,
114+
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},
115+
doi = {10.48550/arxiv.2201.12468},
116+
month = {1},
117+
title = {Symbolic-Numeric Integration of Univariate Expressions based on Sparse Regression},
118+
url = {https://arxiv.org/abs/2201.12468v2},
119+
year = {2022},
120+
}
121+
```

src/integral.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ function integrate(eq, x=nothing; abstol=1e-6, num_steps=2, num_trials=5, radius
4444
@syms 𝑥
4545
x = 𝑥
4646
end
47+
else
48+
x = value(x) # needed for the transition from @syms to @variables
4749
end
4850

4951
l = Logger(verbose)

src/symbolic.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
function try_symbolic(T, eq, x, basis, Δbasis; kwargs...)
2+
eq isa Num || return 0, 0
23
n = length(basis)
3-
@syms θ[1:n]
4+
# @syms θ[1:n]
5+
@variables θ[1:n]
46

5-
Δeq = sum(θ[j]*Δbasis[j] for j=1:n) - eq
7+
Δeq = sum(θ[j]*Δbasis[j] for j=1:n) - eq
68
Δeq = expand(Δeq)
79

810
terms = collect_terms(Δeq, x)
@@ -85,6 +87,7 @@ function solve_symbolic(eqs)
8587
end
8688

8789
function collect_terms(eq::SymbolicUtils.Add, x)
90+
println(eq)
8891
d = Dict{Any,Any}(1 => 0)
8992
for t in arguments(eq)
9093
if isdependent(t, x)

test/axiom.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ using Symbolics
66
using PyCall
77
sympy = pyimport("sympy")
88

9-
@syms x 𝐞 a b c d e p t m n z
9+
# @syms x 𝐞 a b c d e p t m n z
10+
@variables x 𝐞 a b c d e p t m n z
1011

1112
axion_rules = [
1213
@rule ^(𝐞, ~k) => exp(~k)
@@ -122,7 +123,7 @@ function test_axiom(L, try_sympy=true; kwargs...)
122123
n_catch = 0
123124

124125
for (i,p) in enumerate(L)
125-
try
126+
# try
126127
printstyled(i, ": "; color=:yellow)
127128
eq = p[1]
128129
x = p[2]
@@ -131,6 +132,8 @@ function test_axiom(L, try_sympy=true; kwargs...)
131132
printstyled(eq, '\n'; color=:green)
132133
sol = integrate(eq, x; kwargs...)[1]
133134

135+
println(">>>>", sol)
136+
134137
if isequal(sol, 0)
135138
printstyled("\tFailure\n"; color=:red)
136139
n_fail += 1
@@ -149,10 +152,10 @@ function test_axiom(L, try_sympy=true; kwargs...)
149152
end
150153

151154
printstyled("\tAnswer: \t", ans, '\n'; color=:blue)
152-
catch e
153-
printstyled(i, ": ", e, '\n'; color=:red)
154-
n_catch += 1
155-
end
155+
# catch e
156+
# printstyled(i, ": ", e, '\n'; color=:red)
157+
# n_catch += 1
158+
#end
156159
end
157160

158161
println()

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ include("axiom.jl")
66

77
##############################################################################
88

9-
@syms x β
9+
# @syms x β
10+
@variables x β
1011

1112
"""
1213
a list of basic standard integral tests

0 commit comments

Comments
 (0)