Skip to content

Commit

Permalink
Taylor expand systems of equations
Browse files Browse the repository at this point in the history
  • Loading branch information
hersle committed Oct 9, 2024
1 parent cf81667 commit 8c97e5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/taylor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ true
```
"""
function taylor(f, x, ns; kwargs...)
if f isa Equation
if f isa AbstractArray
return taylor.(f, Ref(x), Ref(ns); kwargs...)
elseif f isa Equation
return taylor(f.lhs, x, ns; kwargs...) ~ taylor(f.rhs, x, ns; kwargs...)
end

Expand Down
3 changes: 3 additions & 0 deletions test/taylor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ eqs = taylor_coeff(substitute(eq, x => x_series), ϵ, 0:3)
sol = x_coeffs .=> [1, -1//5, -1//25, -1//125] # e.g. https://ekamperi.github.io/mathematics/2020/06/21/perturbation-theory.html#MathJax-Element-39-Frame
eqs = substitute(eqs, Dict(sol))
@test all(isequal(eq.lhs, eq.rhs) for eq in eqs)

# system of equations
@test taylor(exp(im*x) ~ 0, x, 0:5) == taylor([cos(x) ~ 0, sin(x) ~ 0], x, 0:5)

0 comments on commit 8c97e5b

Please sign in to comment.