Skip to content

Commit

Permalink
Merge pull request #1430 from hersle/forward_kwargs_taylor
Browse files Browse the repository at this point in the history
Forward taylor() kwargs to substitute()
  • Loading branch information
ChrisRackauckas authored Feb 6, 2025
2 parents 95e4016 + a47ff54 commit f8108e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/taylor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ function taylor(f, x, x0, n; rationalize=true, kwargs...)
# 1) substitute dummy x′ = x - x0
name = Symbol(nameof(x), "") # e.g. Symbol("x′")
x′ = only(@variables $name)
f = substitute(f, x => x′ + x0)
f = substitute(f, x => x′ + x0; kwargs...)

# 2) expand f around x′ = 0
s = taylor(f, x′, n; rationalize, kwargs...)

# 3) substitute back x = x′ + x0
return substitute(s, x′ => x - x0)
return substitute(s, x′ => x - x0; kwargs...)
end
2 changes: 1 addition & 1 deletion test/taylor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ eqs = substitute(eqs, Dict(sol))

# don't evaluate numerical expressions
eq = y ~ 2*Num(π)*x
eq = taylor(eq, x, 1; rationalize=false, fold=false)
eq = taylor(eq, x, 0, 1; rationalize=false, fold=false)
@test contains(string(eq), "π") # should not turn 2*π into 6.28...

0 comments on commit f8108e4

Please sign in to comment.