# How to find crossing point using Spline1D in julia?

I have fitted a spline function using Spline1D from the package Dierckx to the data:

``````x = [0.0, 0.25167322597331027, 1.6518531853618088, 4.032506892599284, 6.871304792339401, 10.090447889235595, 13.686254426579751, 17.610747596745075, 21.841405037619722, 26.366938232563164, 31.26706047764439, 37.49545103557282, 42.61189318926405, 48.0]
y = [50000.0, 53623.40794496114, 79163.0777300414, 153678.85449922792, 339502.75898037956, 835557.6724498648, 2.2886514929222167e6, 6.875522505010054e6, 2.239578715528581e7, 7.732681212840894e7, 2.691022277972607e8, 8.835297472095971e8, 1.4420590677965815e9, 1.7488564860223794e9]
spl = Spline1D(x, y, k=3)
``````

I would like to know the abscissa value that gets an ordinate of let’s say 100 000. I tried with:

``````julia> fit_x = Spline1D(x, y)(100000)
1.7488564860223794e9
``````

but it is obviously wrong. Is there an inverse function for spline and how to implement it in julia?

I think you were already provided with a solution here.
But here it goes again:

``````y0 = 100_000
spl = Spline1D(x, y .- y0)
x0 = roots(spl)   # 2.49089
``````

Yes, sorry, I overlooked the subtraction term… It worked!