1. Definition of the Derivative: The following code generates the graph of a function and its secant lines in "n" incrementing (or decrementing) positions. The secant lines should slow down as they approach the tangent line, and the last secant line should look so close that it can be mistaken for the tangent line. The point "p" is the point at which the derivative is to be taken, and the point "q" is the furthest point from which the secant lines are drawn.

    Note that each "(1-k)^2" can be replaced by a simple "(1-k)," and the animation will not change drastically. The squaring was used to stress the idea that the closer points are more important in taking the derivative than the further points; they make the animation slow down as it approaches p.
  2. restart: with(plots):
    
    a := 0: b := 2*Pi: c := -2: d := 2:   # domain & range
    p := 2.2: q := 5: n := 20:            # begin & end, frames
    f := x -> sin(2*x)*cos(x)+
              cos(3/2*x)*sin(2*x):        # the function
    
    an1 := plot(f(x),x=a..b,y=c..d,color=RED):
    an2 := animate([x,(f(q*(1-k)^2+p-p*(1-k)^2)-f(p))/
           (q*(1-k)^2-p*(1-k)^2)*(x-p)+f(p),x=a..b ],
           k=0..0.999,view=c..d,frames=n,color=GREEN):
    an3 := animate([p*(1-x/(b-a))+(q*(1-k)^2+p*(1-(1-k)^2))*x/(b-a),
           (f(q*(1-k)^2+p-p*(1-k)^2)-f(p))/(q*(1-k)^2-p*(1-k)^2)*
           (p*(1-x/(b-a))+(q*(1-k)^2+p*(1-(1-k)^2))*x/(b-a)-p)+f(p),
           x=a..b],k=0..0.999,view=c..d,frames=n,color=BLUE):
    display(an3,an2,an1);
  3. The Derivative Function: The following code generates the graph of a function, its tangent lines in "n" incrementing positions, and its derivative function, which is shown being created simultaneously with the tangent lines.

    To change the code for a new function, consider the example of y=x1/2 on the interval [0,4]. Then a=0 and b=4. The range of x1/2 on that interval is [0,2], and its derivative has a range from [1/4, infinity), so the natural range for both would be [0,infinity). It is easy to choose c=0. MAPLE can graph to infinity (d=infinity), but it might be better to choose a more reasonable range, say d=10. This can be reset later if the graph is not sufficient. The second through fifth lines below are replaced with the following: "a:=0: b:=4: c:=0: d:=4: n:=10: f:=x->x^(1/2);". After one attempt, it is noted that MAPLE does something strange at the point a=0. Replacing the troublesome point with a=.01 solves the problem.
  4. restart: with(plots):
    
    a := -Pi: b := Pi:  # domain
    c := -2: d := 2:    # range
    n := 40:            # frames
    f := x -> sin(x):   # function
    
    g := x -> D(f)(x):
    an1 := plot( f(x), x=a..b, y=c..d, color=RED ):
    an2 := animate( g(k)*(x-k)+f(k), x=a..b, k=a..b,
           view=c..d, frames=n, color=GREEN):
    an3 := animate( [a+(x-a)*(k-a)/(b-a),
           g(a+(x-a)*(k-a)/(b-a)), x=a..b],
           k=a..b, frames=n, color=BLUE):
    display(an3, an2, an1);
  5. The Second Derivative Function: In this animation, the green line segment represents the acceleration vector; it points up when the curve is concave up and points down when the curve is concave down. The norm of the vector represents the magnitude of the second derivative function, which is graphed simultaneously in blue. It should be noted that as concavity is changing, the green acceleration vector disappears and the blue 2nd-derivative function crosses the x-axis.
  6. restart: with(plots):
    
    a := -1: b := 3:                 # domain
    c := -3: d := 10:                # range
    n := 29:                         # frames
    f := x -> (x^2)^(1/3)*(x - 2)^2: # function
    
    g := x -> D(f)(x): h := x -> D(g)(x):
    an1 := plot( f(x),x=a..b,y=c..d,color=RED):
    an2 := animate([k,f(k)+(x-a)/(b-a)*h(k),x=a..b],
           k=a..b,frames=n,color=GREEN):
    an3 := animate([a+(x-a)*(k-a)/(b-a),
           h(a+(x-a)*(k-a)/(b-a)),x=a..b],
           k=a..b,view=c..d,frames=n,color=BLUE):
    display(an3, an2, an1);
  7. Implicit Differentiation: The point here is that the derivative can be taken regardless of whether the curve is defined by a function or not. This is a difficult point for some students.

    The following code generates the graph of the parametrically defined curve {t2-1,t3-t} (known as Newton's Knot) in red, its tangent lines in "n" incrementing positions (shown in green), and its derivative curve in blue, which is shown being created simultaneously with the tangent lines.

    Here p is the starting point for the parameter t, and q is the ending point.
  8. restart: with(plots):
    
    p := -1.5: q := 1.5:    # t domain
    a := -1.5: b := 1.5:    # x range
    c := -1.5: d := 1.5:    # y range
    n := 20:                # frames
    xx := t ->  t^2 - 1:    # x function
    yy := t -> t^3 - t:     # y function
    
    dx := t -> D(xx)(t): dy := t -> D(yy)(t):
    an1 := plot([xx(t),yy(t),t=p..q],
           view=[a..b,c..d], color=RED,tickmarks=[0,0]):
    an2 := animate([xx((k-p)*(t-p)/(q-p)+p),
           dy((k-p)*(t-p)/(q-p)+p)/dx((k-p)*(t-p)/(q-p)+p),
           t=p..q],k=p..q, frames=n, color=BLUE):
    an3 := animate([t, dy(k)/dx(k)*(t-xx(k))+yy(k),t=p..q],
           k=p..q, frames=n, color=GREEN):
    display(an3,an2,an1,scaling=constrained);
  9. Optimization: Here are a few animations that visually demonstrate functions which have a maximum, even though it is not clear exactly where the maximum is.