From 8c97e5b3f13e01aee4cf46aebe580c010e59bb96 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Wed, 9 Oct 2024 22:49:33 +0200 Subject: [PATCH] Taylor expand systems of equations --- src/taylor.jl | 4 +++- test/taylor.jl | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/taylor.jl b/src/taylor.jl index eb7c33735..dc3ecd8d1 100644 --- a/src/taylor.jl +++ b/src/taylor.jl @@ -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 diff --git a/test/taylor.jl b/test/taylor.jl index 3d6363e66..6f995dda2 100644 --- a/test/taylor.jl +++ b/test/taylor.jl @@ -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)