Skip to content

Commit

Permalink
Taylor expand equations
Browse files Browse the repository at this point in the history
  • Loading branch information
hersle committed Oct 8, 2024
1 parent 92dfd5f commit c7c68b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/taylor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ function taylor(f, x, x0, n; kwargs...)
# 3) substitute back x = x′ + x0
return substitute(s, x′ => x - x0)
end
function taylor(eq::Equation, args...; kwargs...)
return taylor(eq.lhs, args...; kwargs...) ~ taylor(eq.rhs, args...; kwargs...)
end
5 changes: 5 additions & 0 deletions test/taylor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ end

# around x ≠ 0
@test substitute(taylor((x), x, 1, 0:6), x => x + 1) - taylor((1+x), x, 0:6) == 0

# equations
eq = sin(2*x) ~ 2*sin(x)*cos(x)
eq = taylor(eq, x, 0:7)
@test eq.lhs - eq.rhs == 0

0 comments on commit c7c68b7

Please sign in to comment.