3   Applications of the Derivative

3.1 Velocity, Acceleration, and Rectilinear Motion  (starting on page 69)

Example 3.1.1a

s[t_] := (t-2)^3 -2t+8

Show[ Plot[ s[t], {t,0,4}, PlotStyle-> Black],
Plot[ s[0] + ((s[3]-s[0])/(3-0))(t-0), {t,0,3}, PlotStyle->Blue],
Plot[s[0] +((s[4]-s[0])/(4-0))(t-0), {t,0,4}, PlotStyle->Red] ]

Example 3.1.1b

Plot[ {s[t],s'[t]}, {t,0,4}]

Example 3.1.1c

Plot[ {s[t],s'[t],s''[t]},{t,0,4}]

Simulating Motion (page 71)

"The second argument is a three-element list that specifies the variable, its starting, and ending velues."

motion[positionf_, {t_,tmin_,tmax_},{htmin_,htmax_}] := 
Modulel[{track, ball, level, pt, grf, s, c, d}, 
s[tt_]:= positionf /. t->tt;
c=tmin - (tmax - tmin)/4; d= tmin - (tmax-tmin)/5; track = Graphics[{Gray, Line[{{d,htmin}, {d,htmax}}]}];
ball[y_] = Graphics[{PointSize[.03], Red, Point[{d,y}]}];
level[tt_,y_] = Graphics[{Gray, Line[{{d,y},{tt,y}}]}];
pt[tt_,y_] = Graphics[{PointSize[.02], Blue, Point[{tt,y}]}];
grf=Plot[s[t], {t,0,tmax},PlotStyle->Gray];
Animate[Show[grf, Plot[s[t], {t,tmin -.001,t2}],
Plot[Evaluate[s[t2]+s'[t2](t-t2)],
{t,t2-d,t2+d}, PlotStyle->Green],
track, level[t2, s[t2]], ball[s[t2]],pt[t2,s[t2]],
Axes->True, PlotRange->{{c,tmax},{htmin,htmax}},
Ticks->{Range[Floor[tmin],tmax], Automatic}], 
{t2,tmin,tmax}]]

Clear[s];  s[t_] := (t-2)^3-2t+8

motion[s[t],{t,0,4.1},{-.5,8.5}]

motion[ Sin[t], {t,0,4Pi}, {-1.3,1.3}]

For the second element to be a four-element list that specifies the variable, its starting and ending velues, and the time-step between frames (as in earlier editions of this book) you could have something like

Exercise 1. (page 72)

Clear[ s ]; s[t_] := (t-3)/((t-3)^4+1)

Plot[{s[t],s'[t],s''[t]},{t,0,6}]

motion[s[t], {t,0,6}, {-1,1}]

In the second edition, there was a four-element list.  
It amounted to replacing 
                  {t_, tmin_, tmax_}      with      {t_, tmin_, tmax_, step_}
in the first line and replacing 
                    {t2, tmin, tmax}       with      {t2, tmin, tmax, step}
in the last line defining  motion  on page 71 of our sixth edition.

3.2  Implicit Differentiation and Related Rates       (starting on page 73)

Implicit Differentiation  (page 73)

Clear[ eqn ]; eqn[x_,y_] = ( (x^2 +2y^2)^2 == x - 3x*y +y )

curve = ContourPlot[Evaluate[eqn[x,y]],{x,-1,1.5},{y,-1,1}]

Example 3.2.1   (on page 74)

This is a continuation of the input commands that appear on pages 73-74 (and are assumed to have already been evaluated by the kernel).

yprimeEq = D[ eqn[ x, y[x] ], x]

sol =  Solve[yprimeEq, y'[x] ]

?First

sol1 =First[ sol ]

?->

?/.

{u^2 /. u->v,   x^2+x+1 /. x->a,   z^6+2 /. z->2}

sol2 = y'[x] /. sol1

dydx = sol2 /. y[x]->y

Clear[sol, sol1, sol2];    xprimeEq = D[ eqn[ x[y], y], y]

sol = Solve[ xprimeEq, x'[y] ]

sol1 = First[sol]

sol2 = x'[y] /. sol1

dxdy = sol2 /. x[y]->x

horzpts = Solve[ {eqn[x,y], dydx==0}, {x,y}] //N

horzpts[[{1}]]

horzpts[[{2}]]

horzpts[[{1,2,5}]]

horzpts[[{1,2}]]

pts = {x,y} /. horzpts[[{1,2}]]

vertpts = NSolve[{eqn[x,y], dxdy==0},{x,y}]

vertpts[[{1,2}]]

{x,y} /. vertpts[[{1,2}]]

pts = Join[ pts, {x,y} /. vertpts[[{1,2}]] ]

Show[curve,Graphics[{PointSize[0.03],Blue,Map[Point,pts]}]]

Example 3.2.2      (on page 76)

Clear[ eqn, dydx,dxdy,sol, sol1, sol2, curve, yprimeEq, xprimeEq ]

Show[ ContourPlot[(x^3)+x-(y^3)-y==8,{x,-3,4},{y,-3,3}],
Graphics[{PointSize[.03], Red, Point[{2,1}]}],
AspectRatio->Automatic]

eqn = x[t]^3+x[t]-y[t]^3-y[t] == 8

dtEqn = D[ eqn, t]

Solve[ dtEqn, y'[t] ]

Solve[ dtEqn, y'[t]]

Flatten[ Solve[ dtEqn, y'[t]] ]

dydt = y'[t] /. (Solve[ dtEqn, y'[t] ] //Flatten)

dydt = dydt /. x'[t]->1

dydt = dydt /. {x[t]->2,y[t]->1}

Example 3.2.3   (on page 77)

Clear[ volEq, yprimeEq, dydt]

volEq = Pi*r[t]^2*y[t] == 1

D[ volEq, t]

yprimeEq = D[ volEq, t] /. y[t]->1/(Pi*r[t]^2)

Solve[ yprimeEq, y'[t] ]

Flatten[ Solve[ yprimeEq, y'[t] ] ]

dydt = y'[t] /.  (Solve[ yprimeEq, y'[t] ] //Flatten)

dydt = dydt /. r'[t]->1/2

dydt /. {r[t]->5}

dydt /. {r[t]->5}  //N

Exercises on pages 77-78

Exercise 2 on pages 77-78.  (parts (a) and (b) are misprinted)

In  part (a) and part (b) of Exercise 2, the given point is not on the given curve.  
In part (a), take the point to be  (1, 2).  
In part (b), let us take the curve to be  2 sin( κ y cos(κ x)) +3 x y = 3  at the point (1/3, 1).

Solution for Part (a) of Exercise 2 on pages 77-78.     ( Intelligible rather than elegant)
Successsively evaluate the following Input statements.

eqn1[x_,y_]= x*y^2-y*x^3==2

?ContourPlot

ContourPlot[ Evaluate[eqn1[x,y]],{x,-5,5},{y,-5,5}]

derivOFeqn1 = D[  eqn1[x,y[x]],x]

Solve[ derivOFeqn1, y'[x] ]

sol1 = Solve[ derivOFeqn1, y'[x] ] //Flatten

expr1 = y'[x] /. sol1

dydx[x_,y_]  = (expr1 /. y[x]->y)

dydx[1,2]

ContourPlot[Evaluate[eqn1[x,y]],{x,0.5,1.5},{y,1.5,2.5}]

From this viewpoint, a slope of  2/3 at (1, 2)  seems reasonable.

Solution for Part (b) of Exercise 2 on page 78.     ( Intelligible rather than elegant)
Successively evaluate the following Input statements.

eqn2[x_,y_]:= 2Sin[Pi*y*Cos[Pi*x]] + 3x*y == 3

eqn2[1/3,1]

So,  (1/3, 1)  is a point on the curve.

ContourPlot[Evaluate[eqn2[x,y]],{x,0,3},{y,0,2}]

derivOFeqn2 = D[  eqn2[x,y[x]],x]

Solve[ derivOFeqn2, y'[x] ]

sol2 = Solve[ derivOFeqn2, y'[x] ] //Flatten

expr2 = y'[x] /. sol2

Clear[ dydx ]

dydx[x_,y_]  = (expr2 /. y[x]->y)

dydx[1/3,1] //N

ContourPlot[Evaluate[eqn2[x,y]],{x,0.3`,0.35`},{y,0.97,1.03}]

Thus, a slope of  -3  at  (1/3, 1) is belivable.

Exercise 3 on page 78.

Clear[x,y,expr,dydt]

eqn = y[t] == x[t]^2

x'[t] = 2

derivOFeqn = D[ eqn, t]

Solve[ derivOFeqn, y'[t] ]

sol = Solve[ derivOFeqn, y'[t] ] //Flatten

expr = y'[t] /. sol

dydt[x_,y_] = (expr /. {x[t]->x})

{  dydt[-1,1], dydt[0,0], dydt[1,1], dydt[2,4] }

Clear[ expr1, expr2, expr, sol1, sol2, sol, dydx, dydt, derivOFeqn1, derivOFeqn2, derivOFeqn ]

Exercise 4 on page 78.

eqn = x[t]^2+y[t]^2==1

x'[t] = 1

derivOFeqn = D[ eqn, t]

Solve[ derivOFeqn, y'[t] ]

?Flatten

?Part

sol = Solve[ derivOFeqn, y'[t] ][[1]]  

(* or,    Solve[ derivOFeqn, y'[t] ]  // Flatten  *)

expr = y'[t] /. sol

dydt[x_,y_] = expr /. {x[t]->x,y[t]->y}

dydt[-Sqrt[2],Sqrt[2]]

dydt[0,1]

dydt[Sqrt[3]/2, 1/2]

Clear[ dydt, expr, sol,eqn, derivOFeqn]

Exercise 5 (a) on page 78.

eqn = V[t] == (4*Pi/3)r[t]^3

DerivOFeqn = D[ eqn, t]

sol =Solve[ DerivOFeqn, r'[t] ] //Flatten

r'[t_] =  r'[t] /. sol

r'[13]

3.3  Linear and Quadratic Approximation    (starting on page 78)

Example 3.3.1   (on page 79)

Clear[f, λ]

f[x_] = x^2

λ[x_] = f[3/4]+f'[3/4]*(x-3/4)

Plot[{f[x],λ[x]},{x,0,1},PlotRange->{-0.1,1},PlotStyle->{{},Red}]

GraphicsRow[{Plot[{f[x],λ[x]},{x,0.6,0.9},PlotStyle->{{},Red}],Plot[Abs[f[x]-λ[x]],{x,0.6,0.9}]}]

GraphicsRow[{Plot[{f[x],λ[x]},{x,0.7,0.8},PlotStyle->{{},Red}],Plot[Abs[f[x]-λ[x]],{x,0.7,0.8}]}]

Example 3.3.2

Clear[f,λ]

f[x_] = Cos[x];  { f[x], f'[x]}

λ[x_] = f[Pi/3] + f'[Pi/3]*(x-Pi/3)

λ[1.]

Cos[1.]

Quadratic Approximation  (beginning on page 80)

Example 3.3.3

f[x_] = Cos[x];

a = 0;

q[x_] = f[a] + f'[a]*(x-a)+ (1/2)*f''[a]*(x-a)^2

Plot[{f[x],q[x]},{x,-Pi,Pi},PlotRange->{-1.5,1.5}]

GraphicsRow[{Plot[{f[x],q[x]},{x,-1,1}],Plot[Abs[f[x]-q[x]],{x,-1,1},PlotRange->All]}]

GraphicsRow[{Plot[{f[x],q[x]},{x,-.5,.5}],Plot[Abs[f[x]-q[x]],{x,-.5,.5},PlotRange->All]}]

3.4  Newton's Method  (starting on page 83)

Example 3.4.1

Clear[f,g,λ,q,P];   f[x_] = x^2 - Cos[Pi*x]

Plot[f[x],{x,-2,2}]

newt[x_] = x - f[x]/f'[x]

NestList[ newt, .5, 6 ]

NestList[ newt, .5000000000000000, 6 ]

Clear[newt]

newt[x_] := N[ x-f[x]/f'[x], 16]

?N

N[  NestList[ newt, .500000000000000000, 6 ],  16] //TableForm

Clear[newt]

newt[x_] = x - f[x]/f'[x]

NestList[newt, 1/2, 2]

Exercises    ( for Newton's Method -----on pages 83-84)       (Be able to do Exercises 2, 3, 4, 7.)

Exercise 1.

?NestList

More information with helpful examples can be found by clicking:  HELP  then  DOCUMENTATION CENTER  then  INDEX OF FUNCTIONS  then  NESTLIST.
.

Exercise 5.

Clear[f, newt];   f[x_] = x - 2.95Cos[x]

?NSolve

Since  NSolve  applies only to polynomial equations,  something like Newton's Method is needed.  Actually,  FindRoot  is an improvement on Newton's Method  (that automatically changes slightly the initial guess when the derivative is zero there; and etc.).  However,  we continue now with Newton's Method to illustrate the subject in our Calculus textbook and to obtain good results on the next quiz.

Plot[ f[x], {x,-30,30}]

Plot[ f[x], {x,0,2}]

x0 = 1.2;  newt[x_] = x - f[x]/f'[x]

N[  NestList[newt, x0, 6], 16 ]

It might appear from the first graph that there are two zeros and one of them is approximately   1.16487.  To see that this is the only zero, we need detail about the graph near  x = -2.8 .

Plot[ f[x], {x,-3,-2.5},AxesOrigin->{0,0}]

Options[Plot]

?AxesOrigin

and click the preceding  >>

Exercise 6  (on page 85)

Clear[f, newt, x0];  f[x_] = x^2 - ArcTan[x]

Plot[ f[x], {x, -5, 5}]

Plot[ f[x], {x, -.5, 1.5}]

{ f[0], f'[0] }

One zero is  x = 0.  To approximate the other, we select  x0 = .8 .

x0 = .8;   newt[x_] = x - f[x]/f'[x]

NestList[newt, .8, 10]

Thus, in adddition to  x = 0  the remaining zero is approximately   x  = .833606 .

For the quiz on the part of Chapter 3 up to this point,  expect questions about

the use of  ContourPlot, and
the use of NestList and Newton's Method  (or FindRoot) for approximating a solution of something like   cos(x) = x .