# How to find all roots and maxima and minima and graph them

I need to find all the roots of this function. I know it is simple to find by hand, however, I wish to learn how to do it so I can apply it later. The problem is that it only gives me one root.

Distance[t_] := t*(t - 1)*(t - 1.5)^2*(t - 3)
Velocity[t_] := Simplify[Distance'[t]]
FindRoot[Velocity[t], {t, -100, 100}]

{t -> 2.63641}


I can find the minimum and maximum. However, how would I plot them on the same graph as the function without copy and pasting the points manually into a list?

-
Any reason you can't just use Solve[Velocity[t] == 0, t]? –  Andy Ross Nov 14 '12 at 22:21
Gah! You might as well close the question now. –  General Stubbs Nov 14 '12 at 22:32

As Andy said, you can simply use

solutions = Solve[velocity[t] == 0, t]


to find the extrema: {{t -> 0.291169}, {t -> 1.17242}, {t -> 1.5}, {t -> 2.63641}}

However, how would I plot them on the same graph as the function without copy and pasting the points manually into a list?

You can use Show to draw multiple plots or graphics in the same coordinate system:

Show[
Plot[distance[t], {t, 0, 3}],
Graphics[{Red, PointSize[Large],
Point[{t, distance[t]} /. solutions]}]]


Result:

-
You could also use Epilog to plot the points. –  wxffles Nov 14 '12 at 23:06
Thank you so much. When I find the maximum and minimum, I'll just define it as a variable. –  General Stubbs Nov 15 '12 at 0:52