I am using Python 3.7 to write a program that requires me to calculate the root of the Hermite interpolating polynomial, given two points $\epsilon_0$, $\epsilon_1$, the function ($d(\epsilon_0)$,$d(\epsilon_1)$) and the derivative values ($d'(\epsilon_1)$, $d'(\epsilon_1)$) at those points. I am using Scipy v1.3.0 and using the CubicHermiteSpline function from the scipy.interpolate library. The relevant extracts from the code are:
import numpy as np
from scipy.interpolate import BPoly,CubicHermiteSpline
#somewhere below inside a while loop with a counter variable k is this part
r=CubicHermiteSpline(eps[k-1:k+1],abs(l[k-1:k+1]), d1[k-1:k+1]).roots()
epsk=(np.abs(r - eps[k])).argmin()
Whereabs(l)
contains the values for the polynomial and d1
contains the derivative values. The problem is the .roots() returns an empty array for the interval ($\epsilon_0$,$\epsilon_1$).
ValueError: attempt to get argmin of an empty sequence
This is because the interpolated polynomial from this interval looks like this:
How do I get all the three roots of the interpolated polynomial, which may not necessarily be inside the interval?
Edit: The numerical values:
$$d(\epsilon_0)=1.00000188\\
d(\epsilon_1)=1.09393556\\
d'(\epsilon_0)=-4.30116854\\
d'(\epsilon_1)=-4.30428889
$$
Find the roots of the hermite intpolation polynomial.
Interpolated polynomial graph: