Numeric Taylor expansion

I have the problem that a certain software only handles polynomials as input data and I have some experimental data/non polynomial solutions, which I would like to convert.

Is there a package that can do a Taylor expansion of a function?

A numeric solution would be fine I think, but I am not sure if there is one except calculating derivatives using AD. My first idea would be using ForwardDiff to get the derivative at x0 and then construct a taylor series.

The other option would be fitting a polynomial, I guess.

Is there a better way of doing this?

It sounds like you want a polynomial fit, not a Taylor expansion?

2 Likes

As @stevengj said if you have some experimental data you probably want a fitting library, ie. Polynomials.jl‘s fit function.
If you need something more sophisticated perhaps PolyFit.jl could be of interest as it provides some extended fitting facilities which expand Polynomials.jl.

If you actually want to calculate a Taylor series of a known function, you can do this numerically using TaylorSeries.jl

Hope that helps,

1 Like