CoCalc Public Files04 - Tangent Lines Assignment / Tangent Lines Notes.sagewsOpen with one click!
Author: Aaron Tresham
Views : 323
License: Other -- explicitly state in your code
Compute Environment: Ubuntu 20.04 (Default)
This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is Creative Commons License
licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


  • Intro to Sage
  • Graphing and Solving Equations
  • Limits

Local Linearity and Tangent Lines

This week we will zoom in on graphs of functions to explore the "local linearity" property. Then we will find and graph tangent lines.

Example 1

Consider the function f(x)=2ln(x)f(x)=2\ln(x). Here is a typical graph:

f(x)=2*ln(x) plot(f,xmin=0,xmax=10)

What happens when we zoom in on a particular point? What does the graph look like? For example, let's zoom in on the point (1,0)(1,0).


On the first graph above, it is easy to see that the graph is not straight, but when we zoom in the curvature is much harder to see. Let's zoom in once more:


When we are this close to the graph of ff, it appears that the graph is a straight line. We know this is not the case, but very close to the point (1,0)(1,0) the graph is almost a line. This is called the local linearity property. Not every function has this property, but there are many important functions that do have this property.

Example 2

Consider the graph of g(x)=cos(x)g(x)=\cos(x) near the point (0,1)(0,1).

In the animation below, we will zoom in on this graph near this point. Note that both the x- and y-axes will change to maintain the scale.

It appears that the graph of cos(x)\cos(x) has the local linearity property at (0,1)(0,1).

Example 3

Now let's consider the graph of h(x)=xh(x)=|x| near the point (0,0)(0,0).

plot(abs(x),xmin=-.01,xmax=.01,ymin=0,ymax=.02) #I have adjusted the ymin and ymax again to keep the scales the same

For this function, it does not matter how much you zoom in. You will always get a sharp corner, never a straight line. This is an example of a function that does not have the local linearity property at a point. [Note: this function does have the local linearity property at every other point on the graph - it's already a straight line everywhere else.]

From what we've seen above, it's safe to conclude that graphs alone are not sufficient for determining local linearity (depending on the viewing window, the picture can look very different). We want an algebraic way of determining local linearity.

Tangent Lines

If a function ff has the local linearity property at a particular point (x0,f(x0))(x_0,f(x_0)), then the graph of ff looks like a line near that point. But which line does it look like?

The line that ff is "close to" at (x0,f(x0))(x_0,f(x_0)) is called the "tangent line" at that point, and the point (x0,f(x0))(x_0,f(x_0)) is called the "point of tangency." In order to find the equation of a line, we need two pieces of information, either two points on the line or one point on the line and the slope of the line. We know one point on the tangent line: (x0,f(x0))(x_0,f(x_0)). We don't know a second point on the tangent line, but we can find the slope of the tangent line.

First, we will approximate the slope of the tangent line by choosing a second point close to (x0,f(x0))(x_0,f(x_0)). Say the distance away from x0x_0 is hh, then the second point is (x0+h,f(x0+h))(x_0+h,f(x_0+h)). We'll find the slope of the line through these two points (called a "secant line").

Here is a sample graph.

Now we will improve our approximation by making hh closer and closer to 00, moving (x0+h,f(x0+h))(x_0+h,f(x_0+h)) closer to (x0,f(x0))(x_0,f(x_0)).

This process sounds like a limit, so that's how we'll find our answer. The slope of the secant line through (x0+h,f(x0+h))(x_0+h,f(x_0+h)) and (x0,f(x0))(x_0,f(x_0)) is f(x0+h)f(x0)x0+hx0=f(x0+h)f(x0)h\displaystyle\frac{f(x_0+h)-f(x_0)}{x_0+h-x_0}=\frac{f(x_0+h)-f(x_0)}{h} (rise over run).

We want to know what happens to this slope as hh approaches 00. In limit notation, we want to find limh0f(x0+h)f(x0)h\displaystyle\lim_{h\to 0}\frac{f(x_0+h)-f(x_0)}{h}.

If the function ff has the local linearity property at (x0,f(x0))(x_0,f(x_0)), then this limit will exist (and conversely). The value of this limit is the slope of the tangent line.

Now that we have a point on the line and the slope of the line, we can find the equation of the line. Remember point-slope form?

Point-Slope Form of a Line: yy0=m(xx0)y-y_0=m\cdot(x-x_0), where mm is the slope and (x0,y0)(x_0,y_0) is a point on the line.

In this case, (x0,y0)=(x0,f(x0))(x_0,y_0)=(x_0,f(x_0)) and m=limh0f(x0+h)f(x0)hm=\displaystyle\lim_{h\to 0}\frac{f(x_0+h)-f(x_0)}{h}.

Therefore, an equation for the tangent line is yf(x0)=m(xx0)y-f(x_0)=m\cdot(x-x_0). Adding f(x0)f(x_0) to both sides produces:

Equation for the Tangent Line at x=x0x=x_0:


where m=limh0f(x0+h)f(x0)hm=\displaystyle\lim_{h\to 0}\frac{f(x_0+h)-f(x_0)}{h}.

This is a general formula for finding an equation for the line tangent to the graph of ff at the point (x0,f(x0))(x_0,f(x_0)).

Example 4

To see how secant lines approach the tangent line graphically, let's look at the animation below.

You will see secant lines for the curve f(x)=2ln(x)f(x)=2\ln(x) through the point (x0,f(x0))=(1,0)(x_0,f(x_0))=(1,0) and (x0+h,f(x0+h))(x_0+h,f(x_0+h)), where hh starts at 11 and approaches 00.

You can see that the secant lines (in green) approach the tangent line (in red) as hh approaches 00.

Now hh can also be negative, so we'll also look at secant lines when hh starts at 34-\frac{3}{4} and approaches 00.

Note: We can't start at h=1h=-1, since that gives us x0+h=0x_0+h=0, which is not in the domain.

Once again, the secant lines approach the tangent line as hh approaches 00.

Example 5

Now consider f(x)=cos(x)f(x)=\cos(x) and (x0,f(x0))=(0,1)(x_0,f(x_0))=(0,1). We'll start at h=1h=1 and let hh approach 00.

Now we'll start at h=1h=-1 and let hh approach 00.

Whether hh approaches 00 from the left or right, the secant lines approach the tangent line.

Example 6 (your assignment is like this example)

Now let's find the equation of the line tangent to the graph of f(x)=2ln(x)f(x)=2\ln(x) at the point (1,0)(1,0).

First, we need the slope. As we saw above, the slope is limh0f(1+h)f(1)h\displaystyle\lim_{h\to0}\frac{f(1+h)-f(1)}{h}.

%var h f(x)=2*ln(x) limit((f(1+h)-f(1))/h,h=0) #Don't forget parentheses around the numerator

So the slope is 2.

Now use the equation of a tangent line: y=f(x0)+m(xx0)y=f(x_0)+m\cdot(x-x_0).

TL(x)=f(1)+2*(x-1) #I'll use TL for "tangent line" show(TL(x))
2x2\displaystyle 2 \, x - 2

Now I'll plot the function and the tangent line.


Example 7

Now let's try to find the tangent line to g(x)=xg(x)=|x| at (0,0)(0,0). We saw above that this function does not have the local linearity property here, so something should go wrong.

Let's try to calculate the slope: m=limh00+h0h\displaystyle m=\lim_{h\to 0}\frac{|0+h|-|0|}{h}.

We find that the limit does not exist (Sage returns "und").

%var h g(x)=abs(x) limit((g(0+h)-g(0))/h,h=0)

Notice that the one-sided limits exist but are not equal:

limh0+0+h0h=limh0+hh=limh0+hh=1\displaystyle \lim_{h\to 0^+}\frac{|0+h|-|0|}{h}=\lim_{h\to 0^+}\frac{|h|}{h}=\lim_{h\to 0^+}\frac{h}{h}=1

limh00+h0h=limh0hh=limh0hh=1\displaystyle \lim_{h\to 0^-}\frac{|0+h|-|0|}{h}=\lim_{h\to 0^-}\frac{|h|}{h}=\lim_{h\to 0^-}\frac{-h}{h}=-1

So the two-sided limit does not exist.

If we try to find the slope at any point other than x=0x=0, it works fine. Let's use (5,5)(-5,5).

m=limh05+h5h\displaystyle m=\lim_{h\to 0}\frac{|-5+h|-|-5|}{h}

%var h limit((g(-5+h)-g(-5))/h,h=0)

Now we see the slope of the tangent line is 1-1, so the tangent line has equation y=g(5)+(1)(x(5))=5(x+5)y=g(-5)+(-1)(x-(-5))=5-(x+5), or y=xy=-x.

TL(x)=g(-5)+(-1)*(x-(-5)) show(TL(x))
x\displaystyle -x

Now I'll plot the function and the tangent line.