| Hosted by CoCalc | Download
Kernel: Python 3 (system-wide)

Cubic Polynomial Derivatives

The function cubic_derivcubic\_deriv defines two sets of data points to plot:

[x,y][x,y] represents the cubic function f(x)=ax3+bx2+cx+df(x)=ax^3+bx^2+cx+d

[x,z][x,z], represents the above cubic function's first derivative, f(x)=3ax2+2bx+cf'(x)=3ax^2+2bx+c

import matplotlib.pyplot as plt import numpy as np def cube_deriv(a, b, c, d): x=np.linspace(-10, 10, 1000) y=a*x**3+b*x**2+c*x+d z=3*a*x**2+2*b*x+c plt.plot(x,y,color='blue', label='f (x)') plt.plot(x,z, color='red', label='f \' (x)') plt.xlabel('x') plt.ylabel('y') plt.title('Plot of f (x) and f \' (x)') plt.legend() plt.show()
cube_deriv(3,-2,0,5)
Image in a Jupyter notebook