In An introduction to programming with Mathematica by Paul R. Wellin, Richard J. Gaylord, Samuel N. Kamin, there is a section in page 279 that about root finding with this code:
RootPlot[fun_, {x_, xmin_, xmax_}] :=
Module[{z, fplot, pts, spts, roots, points,
f = Function[{x, Evaluate[fun]}]},
fplot = Plot [f [x], {x, xmin, xmax}, DisplayFunction -> Identity];
pts = Cases[fplot, Line[{ z__ }] -> z, Infinity];
spts = Map[First,
Select[Split[pts, Sign[Last[# 2]] == -Sign[Last[# 1]] &],
Length[# 1] == 2 &], {2}];
roots = Map[FindRoot[f[x] == 0, {x, # [[ 1]], # [[2]]}] &, spts];
points = Map[Point[{#, 0}] &, x /. roots];
Show[fplot, DisplayFunction -> $DisplayFunction,
Epilog -> {RGBColor[ 0, 0, 1], PointSize[.02], points}]; roots]
Actually when i made an effort to test this code for Sin[2x] something happened wrong! Please check it out and tell what is mistake!?

