Q6.4.1Derivative of a polynomial
The third derivative of the polynomial function \(P(x) = 3x^3 + 2x - 7\) is \(18\), so why does the following evaluate as False?
In [x]: from numpy.polynomial import Polynomial
In [x]: Polynomial((-7, 2, 0, 3)).deriv(3) == 18
Out[x]: False
Show solution
The Polynomial deriv method returns a Polynomial object (in this case with a single term, the coefficient of \(x^0\), equal to 18. This object is not equal to the integer object with value 18:
In [x]: Polynomial((-7, 2, 0, 3)).deriv(3)
Out[x]: Polynomial([18.], domain=[-1., 1.], window=[-1., 1.], symbol='x')