Skip to content

Commit 0e3771d

Browse files
upgraded to version 0.7.0; homotopy is true by default
1 parent b725a0c commit 0e3771d

File tree

11 files changed

+140
-231
lines changed

11 files changed

+140
-231
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.6.3"
4+
version = "0.7.0"
55

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

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ julia> integrate(exp(x^2))
6363
* `abstol` (default `1e-6`): the error tolerance to accept a solution.
6464
* `symbolic` (default `true`): if true, pure symbolic integration is attempted first.
6565
* `bypass` (default `false`): if true, the whole expression is considered at once and not per term.
66-
* `bypart` (default `true`): if true, integration by parts is tried.
66+
* `bypart` (default `false`, turned off in version 0.7.0): if true, integration by parts is tried.
6767
* `num_steps` (default `2`): one plus the number of expanded basis to check (if `num_steps` is 1, only the main basis is checked).
6868
* `num_trials` (default `5`): the number of attempts to solve the integration numerically for each basis set.
6969
* `show_basis` (default `false`): print the basis set, useful for debugging. Only works if `verbose` is also set.
70+
* `homotopy` (default: `true` as of version 0.7.0): uses the continuous Homotopy operators to generate the integration candidates.
7071
* `verbose` (default `false`): if true, prints extra (and voluminous!) debugging information.
7172
* `radius` (default `1.0`): the starting radius to generate random test points.
7273
* `opt` (default `STLSQ(exp.(-10:1:0))`): the optimizer passed to `sparse_regression!`.
@@ -84,8 +85,8 @@ Additionally, 12 test suites from the *Rule-based Integrator* ([Rubi](https://ru
8485
using SymbolicNumericIntegration
8586
include("test/axiom.jl") # note, you may need to use the correct path
8687

87-
L = convert_axiom(:Apostle) # can also use L = convert_axiom(1)
88-
test_axiom(L, false; bypart=true, bypass=false, verbose=true)
88+
L = convert_axiom(:Apostle) # can also use L = convert_axiom(1)
89+
test_axiom(L, false; bypart=false, bypass=false, verbose=false, homotopy=true)
8990
```
9091

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

src/SymbolicNumericIntegration.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# module SymbolicNumericIntegration
1+
module SymbolicNumericIntegration
22

33
using SymbolicUtils
44
using SymbolicUtils: istree, operation, arguments
@@ -27,4 +27,4 @@ include("integration_by_parts.jl")
2727
include("logger.jl")
2828
include("prune.jl")
2929

30-
# end # module
30+
end # module

src/candidates.jl

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ function generate_basis(eq, x; homotopy=false)
1414

1515
if homotopy
1616
if isdependent(p, x)
17-
C₂ = generate_homotopy2(p, x)
17+
C₂ = generate_homotopy(p, x)
1818
else
1919
C₂ = 1
2020
end
2121
else
22-
C₂ = find_candidates_nonsolvable(p, x)
22+
C₂ = find_candidates(p, x)
2323
end
2424

2525
for c₁ in C₁
26-
enqueue_expr_ex!(S, c₁, x)
26+
enqueue_expr!(S, c₁, x)
2727
end
2828

2929
for c₂ in C₂
30-
enqueue_expr_ex!(S, c₂, x)
30+
enqueue_expr!(S, c₂, x)
3131
end
3232

3333
for c₁ in C₁
3434
for c₂ in C₂
35-
enqueue_expr_ex!(S, expand(c₁*c₂), x)
35+
enqueue_expr!(S, expand(c₁*c₂), x)
3636
end
3737
end
3838
end
@@ -53,26 +53,26 @@ function closure(eq, x; max_terms=50)
5353
D = Differential(x)
5454
S = Set{Any}()
5555
q = Queue{Any}()
56-
enqueue_expr_ex!(S, q, eq, x)
56+
enqueue_expr!(S, q, eq, x)
5757

5858
while !isempty(q) && length(S) < max_terms
5959
y = dequeue!(q)
60-
enqueue_expr_ex!(S, q, expand_derivatives(D(y)), x)
60+
enqueue_expr!(S, q, expand_derivatives(D(y)), x)
6161
end
6262
unique([one(x); [s for s in S]; [s*x for s in S]])
6363
end
6464

65-
function find_candidates_nonsolvable(eq, x)
65+
function find_candidates(eq, x)
6666
eq = apply_d_rules(eq)
6767
D = Differential(x)
6868

6969
S = Set{Any}()
7070
q = Queue{Any}()
71-
enqueue_expr_ex!(S, q, eq, x)
71+
enqueue_expr!(S, q, eq, x)
7272

7373
for y in q
7474
∂y = expand_derivatives(D(y))
75-
enqueue_expr_ex!(S, ∂y, x)
75+
enqueue_expr!(S, ∂y, x)
7676
end
7777

7878
return unique([one(x); [s for s in S]])
@@ -146,43 +146,22 @@ function enqueue_expr!(S, q, eq::SymbolicUtils.Add, x)
146146
end
147147

148148
function enqueue_expr!(S, q, eq, x)
149-
y = eq / coef(eq, x)
150-
if y S && isdependent(y, x) # && all(u->u>=0, extract_power(y))
151-
enqueue!(q, y)
152-
push!(S, y)
153-
end
154-
end
155-
156-
function enqueue_expr_ex!(S, q, eq::SymbolicUtils.Add, x)
157-
for t in arguments(eq)
158-
enqueue_expr_ex!(S, q, t, x)
159-
end
160-
end
161-
162-
function enqueue_expr_ex!(S, q, eq, x)
163149
y = eq / coef(eq, x)
164150
if y S && isdependent(y, x)
165151
enqueue!(q, y)
166152
push!(S, y)
167153
end
168154
end
169155

170-
function enqueue_expr_ex!(S, eq::SymbolicUtils.Add, x)
156+
function enqueue_expr!(S, eq::SymbolicUtils.Add, x)
171157
for t in arguments(eq)
172-
enqueue_expr_ex!(S, t, x)
158+
enqueue_expr!(S, t, x)
173159
end
174160
end
175161

176-
function enqueue_expr_ex!(S, eq, x)
162+
function enqueue_expr!(S, eq, x)
177163
y = eq / coef(eq, x)
178164
if y S && isdependent(y, x)
179165
push!(S, y)
180166
end
181167
end
182-
183-
###############################################################################
184-
185-
extract_power(eq::SymbolicUtils.Pow) = [arguments(eq)[2]]
186-
extract_power(eq::SymbolicUtils.Term) = [1]
187-
extract_power(eq::SymbolicUtils.Mul) = union([extract_power(t) for t in arguments(eq)]...)
188-
extract_power(eq) = []

0 commit comments

Comments
 (0)