L6-equationOfTangentLine.mws
Calculus I
Lesson 6: Finding the Equation of a Tangent Line
>
restart: with(plots):
Warning, the name changecoords has been redefined
First we'll demonstrate graphically the meaning of a tangent line in an animation. Afterwards, we'll show how to find the equation of a line tangent to a function at a given point.
>
f := x -> x^3 - 4*x^2 + x - 1;
>
T := (x,a) -> f(a) + (x - a) * D(f)(a) :
>
display(plot(f(x), x=-2..6, y= -20..15, thickness = 3, color = red),
animate(T(x,t), x=-2..6, t=-2..5, view = -20.. 15, color = blue, frames=60));
Let's find the equation of the tangent line for the following
functions at the indicated points. Plot the function and tangent
line on the same plot.
a) x = 2, f(x) =
b) x = 1, g(x) =
c) x =
/6, h(x) =
d) x = 0, f(x) =
a)
>
f := x -> 3*x - x^2;
>
D(f);
>
df:= x -> 3 - 2*x;
>
f(2);
>
df(2);
The tangent line passes through the point (2,2) and has slope -1.
>
tl:= x -> 2 -(x - 2);
>
plot({f(x), tl(x)}, x = 0..4, color=[blue,brown]);
b)
>
restart:
>
g:=x -> x^3 - sqrt(x);
>
D(g);
>
dg:= x -> 3*x^2 - (0.5)*(1 / (sqrt(x)));
>
g(1);
>
dg(1);
The tangent line passed through the point (1,0) and has slope 2.5
>
tl:= x -> (2.5)*(x - 1);
>
plot({g(x),tl(x)}, x = -1..3, color=[brown, blue]);
c)
>
restart:
>
h:= x-> 1 + 3*cos(x);
>
D(h);
>
dh:= x ->-3 * sin(x);
>
h(Pi/6);
>
evalf(%);
>
dh(Pi/6);
The tangent line passes through the point (
) and has slope
.
>
tl:= x -> 1 + (3/2)*(sqrt(3)) - (3/2)*(x - Pi/6);
>
plot({tl(x),h(x)}, x = 0..Pi, color=[blue,brown]);
d)
>
restart:
>
f := x -> (3 + x)/(1 - x^2);
>
D(f);
>
df:= x -> 1/(1 - x^2) + 2* ( ((3 + x)*x)/( ( 1 - x^2)^2));
>
f(0);
>
df(0);
The tangent line passes through the point (0,3) and has slope 1.
>
>
tl:= x -> 3 + x;
>
plot({f(x),tl(x)}, x = -0.5..0.5, color=[blue,brown]);
2) Find the derivative of each of the following functions.
Plot the function and the derivative on the same axes.
a) g (x) = -2 for x > 0
= 3 - x for x <= 0
b) f(x) =
for x < 1
=
for x >= 1
c) f(x) =
for x < -1
=
for -1 <= x < 2
=
for x >= 2
a)
>
restart:
>
g:= x -> piecewise(x > 0, -2, 3 - x);
>
D(g);
>
dg:= x -> piecewise(x > 0, 0, -1);
>
plot({g(x),dg(x)}, x = -3..3, discont=true, color=[blue, brown]);
From the plot, we see that g has a derivative everywhere except x = 0.
b)
>
restart:
>
f:= x -> piecewise(x < 1, x^2, 2*x - 1);
>
D(f);
>
df:= x -> piecewise(x < 1, 2*x, 2);
>
>
plot({f(x),df(x)}, x = -2..2, discont=true, color=[blue,brown]);
From the plot we see that f has a derivative for all x.
c)
>
restart:
>
f:= x -> piecewise( x < -1, x^3, -1 <= x and x < 2, 1 + 2*x^2, 4*x + 1);
>
D(f);
>
df:= x -> piecewise( x < -1, 3*x^2, -1 <= x and x < 2, 4*x, 4);
>
plot({f(x), df(x)}, x = -2..3, discont=true, color=[blue,brown]);
From the plot we see that f has a derivative everywhere except x = -1,2.
3) The following function gives the position p at time t of a
particle moving along a coordinate line.
p =
a) Find the velocity and acceleration functions
b) On what intervals for t is the particle moving in the
positive direction? the negative direction?
a)
>
restart:
>
P:= t -> t^4 - 4*t^2 + 4;
>
D(P);
>
D(D(P));
P'(t) =
and P''(t) =
.
b)
>
dP:= t -> 4*t^3 - 8*t;
>
plot({P(t),dP(t)}, t = 0..1, color=[brown,blue]);
>
plot({P(t),dP(t)}, t = 1..2, color=[brown,blue]);
>
plot({P(t),dP(t)}, t = 2..5, color=[brown,blue]);
>
solve(dP(t)=0, t);
>
evalf(%);
Conclusion: the particle moves to the left for t in
and to the
right for
.