Calculus I
Lesson 5: Tangent Lines and Differentiability
Example 1 For each of the following functions, we draw the graph of f(x) along with a secant and tangent line for x = a.
a) f(x) = cos(x)
> restart:
> a := 1;
> f := x->cos(x);
> h := 2.2; q:= (f(a+h) - f(a))/h; secline:= x -> f(a) + q*(x - a); m:= D(f)(a); tanline:= x -> f(a) + m*(x - a);
> plot([tanline(x), f(x), secline(x)], x=-5..5, color=[blue,green,magenta]);
b) and a = 3.
> f:= x -> x^4 -1;
> a:= 3;
> h:= 2;
> q:= (f(a+h) - f(a))/h; secline:= x -> f(a) + q*(x - a); m:= D(f)(a); tanline:= x -> f(a) + m*(x - a);
> plot({f(x), secline(x), tanline(x)}, x = a-1..a+3, color=[blue,red,magenta]);
c) and a = 5.
> f:= x -> sqrt(x) ;
> a:=5;
> h:=7;
> plot({f(x), secline(x), tanline(x)}, x= a-4..a+8, color=[blue,violet,magenta]);
Example 2 For each of the following functions, plot f(x) and Df(x) on the same axes.
a) .
> f:= x -> x^3 - 7* x^2 + 12*x;
> D(f);
> plot({D(f)(x), f(x)}, x = 0..5, color=[magenta,brown]);
b) f(x) = |x|.
> f:= x -> abs(x);
> plot({D(f)(x), f(x)}, x = -4..4, color=[magenta,brown]);
Example 3 Let ; where x is from [-14,14].
a) Plot f(x) for x in [-14,1 4]. What is the period of f(x)?
> f:= x -> 2 *sin(x) - cos(3*x);
> plot(f(x), x = -14..14);
Period is .
b) Since the period of f(x) is , plot f(x) and D(f) on the same axes
for x in [-1,7].
> plot({f(x), D(f)(x)}, x = -.1..7, color=[magenta,brown]);
c) When f(x) has a max or min at x = a, what is D(f)(a)?
d) When f(x) is increasing (decreasing) what is the sign of D(f)?
When f is increasing D(f) >0, and when f is decreasing D(f) <0.
Example 4 Let f(x) = if x > 0 and 0 if .
Plot f(x). Use the graph to determine whether D(f)(0) exists.
> f:= x -> piecewise( x > 0, x*sin(1/x), 0);
> plot(f(x), x = -0.1..0.1);
> plot(f(x), x = -.0001...0001);
Based on the plots, we conjecture that f is not differentiable when x = 0.
Example 5 Let f(x) = for x > 0 and 0 for x <= 0.
Plot f(x). Use the graph to determine if D(f)(0) exits.
> f:= x -> piecewise(x>0, x^2 * sin(1/x), 0);
> plot(f(x), x = -.00001...00001);
Based on the plot, we conjecture that D(f)(0) = 0.
Example 6 Let f(x) = . Plot f(x), the tangent line when x = .5 and
the normal line when x =.5 on the same axes.
> f:=x -> 3 - 2*x^2;
> D(f)(.5);
> f(.5);
> t:= x -> -2*(x - .5) + 2.5;
> n:= x -> (1/2)*(x - .5) + 2.5;
> plot({f(x), t(x), n(x)}, x = -1..1, color=[magenta,brown, wheat]);
Example 7 Let f(x) = |cos(x)|. Determine where f(x) is not differentaible.
> f:= x -> abs(cos(x));
> plot(f(x), x = -7..7);
From the plot we conjecture that f(x) is not differentiable at multiples of and .