Find Taylor Series of a Function

I think you want taylor_expand:

julia> t = taylor_expand(cos, pi/2, order=2)
 6.123233995736766e-17 - 1.0 t - 3.061616997868383e-17 t² + 𝒪(t³)

julia> t(22pi/45 - pi/2)
0.0349065850398867

julia> cos(22pi/45)
0.03489949670250108

(note that the expansion needs to be shifted by subtracting the point it’s expanded about)

4 Likes