# Numeric Taylor expansion

**URL:** <https://discourse.julialang.org/t/numeric-taylor-expansion/64162>\
**Category:** New to Julia\
**Created:** [July 6, 2021, 5:13pm UTC](https://discourse.julialang.org/t/numeric-taylor-expansion/64162 "2021-07-06T17:13:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [July 6, 2021, 5:13pm UTC](https://discourse.julialang.org/t/numeric-taylor-expansion/64162/1 "2021-07-06T17:13:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 6, 2021, 5:17pm UTC](https://discourse.julialang.org/t/numeric-taylor-expansion/64162/2 "2021-07-06T17:17:18Z")

</div>

> [@feanor12](#):
>
> 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?

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

---

<div class="post-metadata">

**Author:** ![ess3sq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ess3sq/32/26834_2.png) [@ess3sq](https://discourse.julialang.org/u/ess3sq)\
**Post date:** [July 6, 2021, 9:00pm UTC](https://discourse.julialang.org/t/numeric-taylor-expansion/64162/3 "2021-07-06T21:00:37Z")

</div>

> [@feanor12](#):
>
> experimental data/non polynomial solutions

As @stevengj said if you have some experimental data you probably want a fitting library, ie. `Polynomials.jl`‘s [`fit` function](https://juliamath.github.io/Polynomials.jl/stable/reference/#Polynomials.fit).  
If you need something more sophisticated perhaps [PolyFit.jl](https://github.com/jishnub/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`](https://github.com/JuliaDiff/TaylorSeries.jl)…

Hope that helps,
