I need to calculate and graph a function and it's first two derivatives. Then, I need to graph the minimum and maximum points of the original function on the graph. I have calculated these, but am lost as to how to graph the data.
The x values for the minimum/maximum points are
criticalPoints[]
with the y values being
criticalPointsY[]
Here is the segment of code where the error appears.
equation=CreateFunction();
firstDeriv=equation.diff(x);
secondDeriv=firstDeriv.diff(x);
print(equation);
criticalPoints=solveset(firstDeriv,x);
criticalPointsY=[];
for a in criticalPoints:
criticalPointsY.append(equation.subs(x,a));
p=plot(equation,firstDeriv,secondDeriv,(x,-10,10));
# Need to add the critical points to the graph. We have them, and the
# y values, but need to put them on the graphs.
print(criticalPoints)
print(criticalPointsY);
for a in range(0, len(criticalPoints)):
xval=criticalPoints[a];
yval=criticalPointsY[a];
plt.plot(xval, yval, 'ro')
p.show();
plt.show();
When I run the program, I get this error. `
Traceback (most recent call last):
File "--------", line 58, in <module>
xval=criticalPoints[a];
TypeError: 'FiniteSet' object does not support indexing
I have tried plotting the points on p and get a different error
p.plot(criticalPoints,criticalPointsY);
AttributeError: 'Plot' object has no attribute 'plot'
Is there a way to plot points on this graph? (p)