Tangent Curves in (x,y)-Coordinates

by
K. D.  Stroyan
University of Iowa

copyright 1997 by Academic Press, Inc. - All rights reserved.

Special Mathematica Functions used in this NoteBook

SetOptions[Plot, AspectRatio->Automatic];
Needs["Graphics`Colors`"];

Notebook Overview

This NoteBook expresses the differential in regular coordinates and applies that idea to several problems.  We start with an explicit curve,

y = f[x]

The differential

dy = f'[x] dx

can be thought of as the equation of the tangent line in "local" (dx,dy)-coordinates, where  dx represents the change in the independent variable from a fixed value, x, and  dy represents the change in dependent variable from a fixed value, y = f[x].  The tangent approximation can be compared in either the new local coordinates, as we did in the program Micro1D from Chapter 5, or in the original coordinate system.  In this NoteBook, we convert to the original system.

References to the Text

This NoteBook goes with Chapter 6 of the text.

Step-by-step Tangent Lines

The tangent to  y = f[x]  in local coordinates

The symbolic differential

Given a defined function  f[x] calculate the symbolic differential like:

\(Clear[f, x, y, dx, dy]; 
f[x_] := Cos[x]\/x; 

    dy\  = \ \(f'\)[x]\ dx\)

Specify the (x,y)-point of tangency

The equation  dy = f'[x] dx is the tangent line in the local coordinates  (dx,dy)  parallel to (x,y)-coordinates that go through a fixed point.  We need to specify a particular point.

\(x\  = \ π/3; 
dy\)N[dy]

Graph  f  and dy  in local coordinates:

Plot[{f[x + dx] - f[x], dy}, {dx, -1, 1}, 
      PlotRange -> {-2, 2}, AxesLabel -> {"dx", "dy"}, 
      PlotStyle -> {{Thickness[0.02], Red}, Blue}];

A combined local tangent plot

\(Clear[f, x, dx, dy]; 
f[x_] := \ x\^3\ E\^\(-x\^2\); 

    dy\  = \ \(f'\)[x]\ dx; 
Print["The graph of ", f[x]]; 

    Print[" with differential dy = ", dy]; 
x\  = \ 1; 

    Print["and its tangent dy = ", dy]; 

    Print["at (x,y)= (", x, ",", f[x], ")"]; 

    Plot[{f[x + dx] - f[x], dy}, {dx, \(-1\), 1}, 
      AxesLabel -> {"dx", "dy"}, 
      PlotStyle -> {{Thickness[0.02], Red}, Blue}]; \)

Steps to finding the tangent line to y = f[x] in regular coordinates

The symbolic Differential

First we compute the symbolic differential using the rules of Chapter 6 to find  f'[x]:

dy = f'[x] dx

Specify a particular x = a

Second we specify a particular value of  x,  x = a, and find the number  m = f'[a], giving the equation

dy = m dx

with a specific numerical slope, m.

Find the specific  b = f[a]

Third, we compute  b = f[a]

Change Coordinates

Finally, we change

dy = m dx

to

y - b = m*(x - a)

or

y = b + m*(x-a)

A Combined Approach

This can all be combined in a single formula

y = f[a] + f'[a]*(x - a)

but you should understand that this single combined formula must be computed in steps.  (You can skip writing the dx, dy, but you still must first compute  f'[x] symbolically, then evaluate it at the fixed  x, evaluate  f[x] at the same  x=a  and then plug it all in.)

An Example with the steps separate

The following steps do the procedure outlined just before here:

Clear[x, y, dx, dy]f[x_] := (x^3); Print["The function y = ", f[x]]; Print["has derivative ",f'[x]];Print["and differential  dy = ",f'[x]," dx"];

a = (2/3); b = f[a]; m=f'[a];Print["We want the tangent at (x,y) = (", a, ",", b, ")."]; 
    Print["where the slope is ", m];

y = b + m (x - a); line = Plot[y, {x, a - 2, a + 2}, PlotRange -> {b - 2, b + 2}]; 
    curve = 
      Plot[f[x], {x, a - 2, a + 2}, PlotRange -> {b - 2, b + 2}]; Show[line, curve];

Practice Exercises

Modify the step-by-step computation above to plot the tangent line to

y = (x^3)  at  x = 3/4.

Combined Tangent Lines in (x,y)-coordinates

The combined program above at the end of the step-by-step explanation can be programmed directly:

Clear[x, y, dx, dy, f]; f[x_] := Cos[x]; a = (π/2); y=f[a]+f'[a] (x - a);
Print["The graph of  y = ", f[x], " near (x,y) = (", a, 
        " , ", f[a], ")"];
Print["and its tangent  y = ", y, "  ≈ ", 
        N[Expand[y]]];
Plot[{f[x], y}, {x, a - 3, a + 3}, 
        PlotRange -> {f[a] - 3, f[a] + 3}, 
        AxesLabel -> {"x", "y"}, 
        PlotStyle -> {{Thickness[0.02], Red}, Blue}];

Practice Exercise

Compute the tangent line to

y = (Sqrt[x])  at  x = 25

by hand and verify that you and the computer agree by modifying the computation above to plot the tangent line to  y = (Sqrt[x]) at  x = 25.

Exercises on Tangent Lines

Exercise 6.8.2

Find the (x,y)-equation and plot of the tangent to

a

y = (x^3)  at  x = -2

\(Clear[f, x, dx, dy]; 
f[x_] := \ x\^3\ ; 
dy\  = \ \(f'\)[x]\ dx; 

    Print["The graph of ", f[x]]; 

    Print[" with differential dy = ", dy]; 
x\  = \ \(-2\); 

    Print["and its tangent dy = ", dy]; 

    Print["at (x,y)= (", x, ",", f[x], ")"]; 

    Plot[{f[x + dx] - f[x], dy}, {dx, \(-1\), 1}, PlotRange -> {\(-2\), 2}, 
      AxesLabel -> {"dx", "dy"}, 
      PlotStyle -> {{Thickness[0.02], Red}, Blue}]; \)

\(Clear[f, x, dx, dy]; 
f[x_] := \ x\^3\ ; 
dy\  = \ \(f'\)[x]\ dx; 

    Print["The graph of ", f[x]]; 

    Print[" with differential dy = ", dy]; 
x\  = \ \(-2\); 

    Print["and its tangent dy = ", dy]; 

    Print["at (x,y)= (", x, ",", f[x], ")"]; 

    Plot[{f[x + dx] - f[x], dy}, {dx, \(-1\), 1}, AspectRatio -> 1, 
      AxesLabel -> {"dx", "dy"}, 
      PlotStyle -> {{Thickness[0.02], Red}, Blue}]; \)

b

y = Sin[x]  at  x = π/3

Clear[x, y, dx, dy, f]; \(f[x_] := Sin[x]; 
\(a = π\/3; \)\)y=f[a]+f'[a] (x - a);
Print["The graph of  y = ", f[x], " near (x,y) = (", a, 
        " , ", f[a], ")"];
Print["and its tangent  y = ", y, "  ≈ ", 
        N[Expand[y]]];
Plot[{f[x], y}, {x, a - 3, a + 3}, 
        PlotRange -> {f[a] - 3, f[a] + 3}, 
        AxesLabel -> {"x", "y"}, 
        PlotStyle -> {{Thickness[0.02], Red}, Blue}];

c

y = Log[x] at  x = 1

Problem 6.13: A General Formula?

y = (a^2) + 2 x (x - a)

What is wrong with the following "general formual" for the tangent?  For the curve

y = (x^2)

we have derivative  dy/dx = 2x, so  dy = 2x dx.

We know that dx = x-a   and  dy = y - (a^2), so the equation of the tangent to y = (x^2) is

y = (a^2) + 2 x (x - a)

Check it out:

Clear[x, y, dx, dy, f]; f[x_] := (x^2)a = 1; y = (a^2) + 2 x (x - a)Plot[{y, f[x]}, {x, -1, 2.5}, PlotStyle -> {Blue, Red}];

What is wrong with this "tangent" program?  Why isn't the graph of  y  a line?

Tangent Curves

Suppose we want to find a parbola tangent to y = f[x] = Sin[x]  at x = Pi/4.

The parabola has equation

y = g[x] = a (x^2) + b x + c

and tangency means that both curves:

1) go through the same point, f[x] = g[x]

and

2) have the same tangent at that point  f'[x] = g'[x]

Specifically in this case, f[x] == g[x]  is the Mathematica  equation (written with == ):

a ((((π/4)))^2) + ((b π)/4) + c == Sin[(π/4)] = 
      (1/(Sqrt[2]))

and  f'[x] == g'[x]  is the equation

((2 a π)/4) + b == Cos[(π/4)] = (1/(Sqrt[2]))

We want to solve the pair of equations for the parameters a, b, c.  Here is the Mathematica command to solve equations:

Clear[x, f, g, a, b, c]; f[x_] := Sin[x]; g[x_] := a (x^2) + b x + c; x = (π/4); equns={f[x] == g[x],f'[x]==g'[x]}Solve[equns]NSolve[equns]

Notice that the solution leaves a arbitrary.  Let's see why.

Algebraically, there are three unknowns: a, b, c and only  2  equations.  This exmple can be easily solved by hand.  The second equation

((2 a π)/4) + b == (1/(Sqrt[2]))

can be solved for

b = (1/(Sqrt[2])) - ((2 a π)/4)

and this can be subsitiuted for  b  in the first equation giving a fromula for  c  in terms of  a.

Geometrically, there are many tangent parabolas:

Do[b = (1/(Sqrt[2])) - ((a π)/2); 
      c = (1/(Sqrt[2])) - (π/(4 (Sqrt[2]))) + ((a (π^2))/16); 
      Plot[{f[x], g[x]}, {x, (π/4) - 2, (π/4) + 2}, 
        PlotRange -> {-1, 2}, PlotStyle -> {Red, Blue}]; 
      , {a, -1, 1,  .2}]

Practice Exercise

Find the parabola that is tangent to  y = Sin[x]  at  x = π/4 AND HAS THE SAME SECOND DERIVATIVE as  Sine  at  x = π/4. (HINT: Add another equation and solve.)

Exercises on Tangent Curves

Problem 6.14

Find the circle of unit radius centered on the  y-axis that is tangent to the parabola

y = (x^2)

(Note: The equation of the circle is

(x^2) + (((y - c))^2) == 1

but you can plot  y = c + (Sqrt[1 - (x^2)])  and  y = c - (Sqrt[1 - (x^2)]).)

Problem 6.15 (a)

Find the radius of the circle centered at  (0,1)  that is tangent to the parabola

y = (x^2)

(Note: The equation of the circle is

(x^2) + (((y - 1))^2) == (r^2)

but you can plot  y = 1 + (Sqrt[(r^2) - (x^2)])  and  y = 1 - (Sqrt[(r^2) - (x^2)]).)

Problem 6.15 (b)

Find the line through the origin that is tangent to  y = 1 + (x^2).  Plot both curves.