- #1
ver_mathstats
- 260
- 21
The function is f(x)=x5-12x3+7x2+2x+7.
I found the minimum of the function and compared the value to a calculator and it seemed okay. But I am confused as to how to incorporate the interval into my code. Has my code already sufficiently answered the question?
Thank you.
I found the minimum of the function and compared the value to a calculator and it seemed okay. But I am confused as to how to incorporate the interval into my code. Has my code already sufficiently answered the question?
Code:
from scipy import optimize
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return (x**5)-12*(x**3)+7*(x**2)+2*x+7
xdom=np.linspace(-2,2,1000)
plt.plot(xdom,f(xdom))
minimum=optimize.fmin(f,1)
print('The minimum:',minimum)
Thank you.