There is a function "parameterplot" in Euler, which calls a plot routine with a parameter under user control. The user can increment and decrement the paramter using the cursor up/down key.
>expr &= x^3-x;
Then we define the plot routine. It plots - the function expr, centered at (x0,expr(x0)) - the tangent at x0 in red - the point (x0,expr(x0)) - a label at the tangent - a title with instructions Note, that we pass the expression, and the expression for the tangent to this function.
>function plotall (x0,expr,texpr,r=1) ...
plot2d(expr,a=x0-r,b=x0+r,c=expr(x0)-r,d=expr(x0)+r); plot2d(texpr;x0,add=1,color=2); plot2d(x0,expr(x0),points=1,add=1); label("(a,f(a))",x0,expr(x0)); title("Press up/down, space, or return!"); endfunction
Now we define a function, which computes the tangent expression, and calls parameterplot. The expressions are passed to parameterplot as additional parameters.
>function animatetangent (expr,x0,dx=0.1,r=1) ...
texpr := &at(expr,x=x0)+diffat(expr,x=x0)*(x-x0); parameterplot("plotall",x0,dx;expr,texpr,r); endfunction
>animatetangent("x^3-x",0); >insimg;