11using LinearAlgebra
22using Statistics: mean, std
3+ using Symbolics
34
45Base. signbit (z:: Complex{T} ) where {T <: Number } = signbit (real (z))
56Base. signbit (x:: SymbolicUtils.Sym{Number} ) = false
@@ -21,6 +22,7 @@ Arguments:
2122----------
2223- `eq`: a univariate expression
2324- `x`: the independent variable (optional)
25+ - `domain`: the domain upon which to evaluate a definite integral (optional)
2426
2527Keyword Arguments:
2628------------------
@@ -44,7 +46,7 @@ Output:
4446- `unsolved`: the residual unsolved portion of the input
4547- `err`: the numerical error in reaching the solution
4648"""
47- function integrate (eq, x = nothing ; abstol = 1e-6 , num_steps = 2 , num_trials = 10 ,
49+ function integrate (eq, x = nothing , domain :: Vector{<:Number} = nothing ; abstol = 1e-6 , num_steps = 2 , num_trials = 10 ,
4850 radius = 1.0 ,
4951 show_basis = false , opt = STLSQ (exp .(- 10 : 1 : 0 )), bypass = false ,
5052 symbolic = true , max_basis = 100 , verbose = false , complex_plane = true ,
@@ -71,6 +73,9 @@ function integrate(eq, x = nothing; abstol = 1e-6, num_steps = 2, num_trials = 1
7173 s, u, ϵ = integrate_sum (eq, x, l; bypass, abstol, num_trials, num_steps,
7274 radius, show_basis, opt, symbolic,
7375 max_basis, verbose, complex_plane, use_optim)
76+ if domain != nothing
77+ s = substitute ( s, Dict ( [ x=> domain[1 ] ] ) ) - substitute ( s, Dict ( [ x=> domain[2 ] ] ) )
78+ end
7479 # return simplify(s), u, ϵ
7580 return s, u, ϵ
7681end
0 commit comments