I'm having to create lots of plots for my calculus class (I'm a tutor for the class), and I'm wanting to reduce typing by creating a function of another function and a numeric argument. To make this more concrete: I want to plot a function and plot points at extrema of the function and at points of inflection. To do this currently, I use the Plot function to get the trace of whatever function, saving it to a variable, like so:
p1=Plot[f[x],{x,0,1}]:
Where the function f[x_] was previously defined. If the function has a maximum at a value A, I then do something like:
p2=Graphics[{{PointSize[Large], Point[{A,f[A]}]}}];
Then I use the Show command to show the final plot:
Show[p1, p2]
This works beautifully, but it's a lot of typing. It occurred to me that I could write a function like this for the point to be plotted (sometimes several points are required):
mypoint[f, x] := Graphics[{{PointSize[Large], Point[{x, f[x]}]}}];
So, when I execute the Show command:
Show[Plot[f[x], {x, 0, 2}], mypoint[f, 1]]
it seems to work, unless f[x] is something like x Exp[-3x]. When that is the case, the my point function returns symbolic results. Changing the function to be:
mypoint[f, x] := Graphics[{{PointSize[Large], Point[{N[x], N[f[x]]}]}}]
does not seem to help, because I get the following:
Show::gcomb: Could not combine the graphics objects in Show[<plot>, Graphics[{{PointSize[Large],Point[{0.666667,0.0902235}]},GrayLevel[1],\ PointSize[Medium],Point[{0.666667,0.0902235}]}]]. >>
Which is pretty much the error I get when the values are symbolic.
Any suggestions would be most welcome. Thanks.