# The linear approximation to a function.

## Purpose

The purpose of this lab is to use Maple to become more familiar with the linear approximation to a differentiable function.

## Background

Suppose that is a differentiable function and that a is some fixed number in the domain of f. We define the linear approximation to at x=a, by the equation

In this equation, the parameter a is called the base point, and x is the independent variable. It might help you understand the definition better if you keep in mind that a stands for a fixed number.

For example if , then would be the straight line that is tangent to the graph of at x=1. We can use the definition to find this tangent line by evaluating and and then plugging these numbers into the definition to obtain

The straight line has the two properties that and . That is, intersects the graph of at x=a and has the same slope as at x=a. To see this, first set x=a in the definition, giving

Then differentiate the definition with respect to x to get the slope of the line, which is

Unfortunately, Maple does not provide the linear approximation directly, so a procedure called tangentline has been written as part of the CalcP package. Its syntax is similar to that of the secantline command introduced in the previous lab. The Maple commands below show how to load the CalcP package into your Maple session and provide several examples of how to use the tangentline function.

```  > with(CalcP);
```

```  > f := x -> x^5+4*x^2+1;
```

```  > tangentline(f,x=-1);
```

```  > plot(f(x),tangentline(f,x=-1),x=-2..2);
```

```  > plot(f(x),tangentline(f,x=-1),tangentline(f,x=1),x=-2..2);
```

The tangentline procedure produces an expression, which can be manipulated using standard Maple commands. In the next example, we show how to use the Maple unapply command to turn the result of tangentline into a function.

```  > f_T := unapply(tangentline(f,x=-1),x);
```

```  > f_T(x);
```

As shown in the next example, the animate command from the plots package can be used to see how the tangent line changes as the base point is changed.

```  > with(plots):
```

```  > animate(x^2,tangentline(x^2,x=t),x=-2..2,t=-1..1);
```

The next two examples show how to apply tangentline to arbitrary functions and . Note that Maple uses the notation D(g) to stand for the derivative of g, and the notation D(g)(a) to stand for the derivative of g evaluated at x=a.

```  > tangentline(g(x),x=a);
```

```  > tangentline(g(x)+h(x),x=a);
```

```  > tangentline(g(x),x=a) + tangentline(h(x),x=a);
```

The last Maple command in the previous example shows that if is the sum of two functions, , then , which means that is tangent to at x=a. To check that this is true, you need to show that the values and are equal at x=a and that the derivatives of and are equal at x=a. Maple commands that do this are shown below.

```  > t1 := tangentline(g(x),x=a) + tangentline(h(x),x=a);
```

```  > subs(x=a,t1);
```

```  > subs(x=a,diff(t1,x));
```

## Exercises

1. Try out tangentline on the following examples. This part of the lab is only to help you become familiar with the concept of the tangent line to a function at a point x=a. Some suggested values of a are given, but feel free to try other values of a and/or other functions.
1. with a = 2 and a = -3.
2. with a = 0 and .
3. with a = 2 and a = -1.

2. More generally, the graphs of two functions and are tangent at x=a if and . For example, the functions and are tangent at x=0, but the functions and are not tangent at x=0, even though they have the same slope, because and so the graphs of p and q don't intersect at x=0.

Show that is tangent to at x=a under this more general definition.

3. Suppose that and . Determine if the following statements are true or not.
1. is tangent to at x=-1.
2. is tangent to at x=1.
3. is tangent to at x=1.