# Is it possible to get coefficients from interpolation function?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-get-coefficients-from-interpolation-function/92862>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 12, 2023, 10:26am UTC](https://discourse.julialang.org/t/is-it-possible-to-get-coefficients-from-interpolation-function/92862 "2023-01-12T10:26:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tatiana\_P](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tatiana_p/32/45801_2.png) [@Tatiana\_P](https://discourse.julialang.org/u/Tatiana_P)\
**Post date:** [January 12, 2023, 10:26am UTC](https://discourse.julialang.org/t/is-it-possible-to-get-coefficients-from-interpolation-function/92862/1 "2023-01-12T10:26:24Z")

</div>

I use method ‘interpolate’ from Interpolation.jl library with interpmode=FritschCarlsonMonotonicInterpolation, for example,

y\_spline = interpolate(x, y\_initial\_curve.(x), FritschCarlsonMonotonicInterpolation())

How to get coefficients of all equations or equation expression of interpolation function, like y\_spline, if it is possible.  
Thank you.

---

<div class="post-metadata">

**Author:** ![CodeGodz](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Post date:** [January 12, 2023, 11:27am UTC](https://discourse.julialang.org/t/is-it-possible-to-get-coefficients-from-interpolation-function/92862/2 "2023-01-12T11:27:53Z")

</div>

Not familiar with the package but the [tests](https://github.com/JuliaMath/Interpolations.jl/blob/617a6666e76328283e8d32f39202542bf69de295/test/lanczos/runtests.jl) show a function `coefficients`:

```julia
using Interpolations
using Interpolations: coefficients
itp = interpolate(log.(1:0.2:5), BSpline(Linear()))
coefficients(itp)

21-element Vector{Float64}:
 0.0
 0.1823215567939546
 0.3364722366212129
 0.47000362924573563
.....

```

Is that what you mean?

---

<div class="post-metadata">

**Author:** ![Tatiana\_P](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tatiana_p/32/45801_2.png) [@Tatiana\_P](https://discourse.julialang.org/u/Tatiana_P)\
**Post date:** [January 12, 2023, 1:13pm UTC](https://discourse.julialang.org/t/is-it-possible-to-get-coefficients-from-interpolation-function/92862/3 "2023-01-12T13:13:06Z")

</div>

Thanks a lot, I found the answer in source code. ‘coefficients’ function gives only constant parts of piecewise polynomials. If linear, quadratic and cubic parts of polynomials are needed to get, ‘itp.m’, ‘itp.c’, ‘itp.d’ should be written, respectively.

---

<div class="post-metadata">

**Author:** ![CodeGodz](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Post date:** [January 12, 2023, 2:46pm UTC](https://discourse.julialang.org/t/is-it-possible-to-get-coefficients-from-interpolation-function/92862/4 "2023-01-12T14:46:40Z")

</div>

You can press the Solution tickbox for your own answer to let everybody know it’s solved 🙂
