Q6.4.2Classifying the stationary points of a polynomial
Find and classify the stationary points of the polynomial
\[f(x) = (x^2 + x - 11)^2 + (x^2 + x - 7)^2.\]
Show solution
Using numpy.polynomial.Polynomial,
In [x]: p1 = Polynomial([-11,1,1])
In [x]: p2 = Polynomial([-7,1,1])
In [x]: p = p1**2 + p2**2
In [x]: dp = p.deriv() # first derivative
In [x]: stationary_points = dp.roots()
In [x]: ddp = dp.deriv() # second derivative
In [x]: minima = stationary_points[ddp(stationary_points) > 0]
In [x]: maxima = stationary_points[ddp(stationary_points) < 0]
In [x]: inflections = stationary_points[np.isclose(ddp(stationary_points),0)]
In [x]: print(np.array((minima, p(minima))).T)
[[-3.54138127 8. ]
[ 2.54138127 8. ]]
In [x]: print(np.array((maxima, p(maxima))).T)
[[ -0.5 , 179.125]]
In [x]: print(np.array((inflections, p(inflections))).T)
[]
That, is the function has two minima,
\[\begin{align*}
f(-3.54138127) &= 8\\
f( 2.54138127) &= 8
\end{align*}\]
one maximum,
\[f(-0.5) = 179.125\]
and no points of inflection / undulation.