Skip to content

Add support for definite integration #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/integral.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LinearAlgebra
using Statistics: mean, std
using Symbolics

Base.signbit(z::Complex{T}) where {T <: Number} = signbit(real(z))
Base.signbit(x::SymbolicUtils.Sym{Number}) = false
Expand All @@ -21,6 +22,7 @@ Arguments:
----------
- `eq`: a univariate expression
- `x`: the independent variable (optional)
- `domain`: the domain upon which to evaluate a definite integral (optional)

Keyword Arguments:
------------------
Expand All @@ -44,7 +46,7 @@ Output:
- `unsolved`: the residual unsolved portion of the input
- `err`: the numerical error in reaching the solution
"""
function integrate(eq, x = nothing; abstol = 1e-6, num_steps = 2, num_trials = 10,
function integrate(eq, x = nothing, domain::Vector{<:Number} = nothing; abstol = 1e-6, num_steps = 2, num_trials = 10,
radius = 1.0,
show_basis = false, opt = STLSQ(exp.(-10:1:0)), bypass = false,
symbolic = true, max_basis = 100, verbose = false, complex_plane = true,
Expand All @@ -71,6 +73,9 @@ function integrate(eq, x = nothing; abstol = 1e-6, num_steps = 2, num_trials = 1
s, u, ϵ = integrate_sum(eq, x, l; bypass, abstol, num_trials, num_steps,
radius, show_basis, opt, symbolic,
max_basis, verbose, complex_plane, use_optim)
if domain != nothing
s = substitute( s, Dict( [ x=>domain[1] ] ) ) - substitute( s, Dict( [ x=>domain[2] ] ) )
end
# return simplify(s), u, ϵ
return s, u, ϵ
end
Expand Down