The Slope Machine

f[x_]:=1.5 Sin[.2(x^3-6x+5)];
xlo=-3.;
xhi=3.;
sloperange={-3.,3.};
steps=25.;

pic1=Plot[f[x],{x,xlo,xhi},
PlotStyle->{{Red,AbsoluteThickness[2]}},
PlotRange->{{xlo,xhi},sloperange}];

dx := (xhi - xlo)/7 /Sqrt[(f'[x])^2 + 1]

pic2[x_]:=Graphics[{
{Blue,AbsoluteThickness[2],
Prepend[Prepend[Table[Point[{a,f'[a]}],{a,xlo,x,(xhi-xlo)/steps}],
    AbsolutePointSize[4]],Blue],
{Blue,Text[PaddedForm[N[f'[x]],{3,1}],{x,f[x]},{0,-2}]},
Line[{{x-dx,f[x]-dx f'[x]},{x+dx,f[x]+dx f'[x]}}]},
{Red,AbsolutePointSize[7],Point[{x,f[x]}]}}];

Table[Show[pic1,pic2[x],
PlotRange->{{xlo,xhi},sloperange}],
{x,xlo,xhi,(xhi-xlo)/steps}
];

Helmut Knaust, 3-3-1999