@@ -33,7 +33,7 @@ Base.signbit(x::SymbolicUtils.Sym{Number, Nothing}) = false
3333 solved is the solved integral and unsolved is the residual unsolved portion of the input
3434 err is the numerical error in reaching the solution
3535"""
36- function integrate (eq, x = nothing ; abstol = 1e-6 , num_steps = 2 , num_trials = 5 ,
36+ function integrate (eq, x = nothing ; abstol = 1e-6 , num_steps = 2 , num_trials = 10 ,
3737 radius = 1.0 ,
3838 show_basis = false , opt = STLSQ (exp .(- 10 : 1 : 0 )), bypass = false ,
3939 symbolic = true , max_basis = 100 , verbose = false , complex_plane = true ,
@@ -150,13 +150,14 @@ function integrate_term(eq, x, l; kwargs...)
150150 end
151151
152152 eq = cache (eq)
153- basis = generate_basis (eq, x; homotopy)
153+ basis1 = generate_basis (eq, x, true ; homotopy)
154+ basis2 = generate_basis (eq, x, false ; homotopy)
154155
155156 if show_basis
156- inform (l, " Generating basis (|β| = $(length (basis)) )" , basis )
157+ inform (l, " Generating basis (|β| = $(length (basis)) )" , basis1 )
157158 end
158159
159- if length (basis ) > max_basis
160+ if length (basis1 ) > max_basis
160161 result (l, " |β| = $(length (basis)) is too large" )
161162 return 0 , expr (eq), Inf
162163 end
@@ -170,12 +171,12 @@ function integrate_term(eq, x, l; kwargs...)
170171 yᵣ = 0
171172
172173 for i in 1 : num_steps
173- if length (basis ) > max_basis
174+ if length (basis1 ) > max_basis
174175 break
175176 end
176177
177178 if symbolic
178- y, ϵ = try_symbolic (Float64, expr (eq), x, expr .(basis ), deriv! .(basis , x);
179+ y, ϵ = try_symbolic (Float64, expr (eq), x, expr .(basis1 ), deriv! .(basis1 , x);
179180 kwargs... )
180181
181182 if ! isequal (y, 0 ) && accept_solution (eq, x, y, radius) < abstol
@@ -187,6 +188,7 @@ function integrate_term(eq, x, l; kwargs...)
187188 end
188189
189190 for j in 1 : num_trials
191+ basis = isodd (j) ? basis1 : basis2
190192 r = radius # *sqrt(2)^j
191193 y, ϵ = try_integrate (Float64, eq, x, basis, r; kwargs... )
192194
@@ -203,10 +205,11 @@ function integrate_term(eq, x, l; kwargs...)
203205 inform (l, " Failed numeric" )
204206
205207 if i < num_steps
206- basis = expand_basis (basis, x)
208+ basis1 = expand_basis (basis1, x)
209+ basis2 = expand_basis (basis2, x)
207210
208211 if show_basis
209- inform (l, " Expanding the basis (|β| = $(length (basis)) )" , basis )
212+ inform (l, " Expanding the basis (|β| = $(length (basis)) )" , basis1 )
210213 elseif verbose
211214 inform (l, " Expanding the basis (|β| = $(length (basis)) )" )
212215 end
0 commit comments