Mathematica Lab #3: Linear Approximations
Michael Pelsmajer, September 30, 2013

There will be no lecture on Linear Approximations, which is covered in Section 2.9.  Instead, there will only be this lab (required) and an optional WebAssign assignment.
Today, you will alternate reading and doing exercises.
Start reading here:

What is a linear approximation and what is it good for?

The Linear Approximation to y=f(x) at a is the function:   

				L(x) = f’(a)(x-a) + f(a)

It’s also called the Tangent Line Approximation to y=f(x) at a, and it’s also called the Linearization of f(x) at a.  

It’s really just the tangent line in disguise (written as a function):

The tangent line to f(x) at a:  The slope is f’(a) and it goes through the point (a,f(a)), so the line is:
				y - f(a) = f’(a) (x - a)
Rewritten:
				y = f’(a) (x - a) + f(a)
The right-hand side is what
we’ve called L(x), so:
				y = L(x) is the tangent line at x=a.

Example.

f[x_] := x^2;
L[x_]:=f'[3](x-3)+f[3];

The Linear approximation to (x^2) at x=3 is:

L[x]

which simplifies to 6x - 9.

The Linear Approximation to (x^2) at x=3 is	L(x) = 6x - 9,
and the tangent line to (x^2) at x=3 is		 y = 6x - 9.

Plot[{f[x],L[x]},{x,0,5}]

Exercise 1

(a) Find the Linear Approximation L(x) to f(x) =  (x^3)-(Sqrt[x]) at x = 4.
(b) Graph y=L(x) together with y=f(x).  (The visible domain must include x = 4.)
(c) Find the Linear Approximation L(x) to f(x) =  (x^3)-(Sqrt[x]) at x = 13.
(d) Graph y=L(x) together with y=f(x).  (The visible domain must include x = 13.)
(e) Find the Linear Approximation L(x) to f(x) =  (((x-1))^(1/3)) at x = 2.
(f) Graph y=L(x) together with y=f(x).  (The visible domain must include x = 2.)

What is the point?  

	 L(x) ≈ f(x)	(they are approximately equal)

at x-values close to x=a.

Example, continued.

The Linear approximation to (x^2) at x=3:

f[x_] := x^2;
L[x_]:=f'[3](x-3)+f[3];

Trying some x-values near 3:

f[3.17] 
L[3.17]

f[2.95333] 
L[2.95333]

Plotting the functions with x near to 3:

f[x_] := x^2;
L[x_]:=f'[3](x-3)+f[3];
Plot[{f[x],L[x]},{x,2.75,3.25}]

On the other hand, trying some x-values that are not close to 3:

f[10]
L[10]

f[-4]
L[-4]

Plot[{f[x],L[x]},{x,-10,10}]

Caution!  The approximation only is good near x = a (in this case near x = 3).

Exercise 2

Repeat Exercise 1 parts (b),(d),(e) but change the visible domain of the graphs so that it only shows x-values where L(x) ≈ f(x) is rather good.  (It’s a bit of a judgement call.)

If I asked you to approximate (Sqrt[99]), you might say  (Sqrt[99])≈ (Sqrt[100])=10.  Similarly, you could say that (Sqrt[102])≈ (Sqrt[100])=10.  Perhaps that’s good enough.

But it might not be good enough.  (For example, if you need to estimate (Sqrt[102])-(Sqrt[99]), the answer 10-10 = 0 is probably not helpful.)


So instead, try a Linear Approximation to  (Sqrt[x]).  Since 102 and 99 are close to 100, and since the square root function is “nice” at 100, 
		let L(x) be the Linear Approximation to  (Sqrt[x]) at x = 100.

f[x_]:=Sqrt[x];
L[x_]:=f'[100](x-100)+f[100];

Let’s see whether L(99) and L(102)  are good approximations of (Sqrt[99]) and (Sqrt[102]):

L[99]
f[99]
N[L[99]-f[99]]

L[102]
f[102]
N[L[102]-f[102]]

In both cases the error (the difference between the approximation and the original function) is small.  That is, the approximations are good!

Exercise 3

(a) Approximate (Sqrt[24]), (Sqrt[26]), and (Sqrt[24.9])using a well-chosen Linear Approximation.
(b) Measure the accuracy (measure the error) of each of those three approximations.  
(c) Approximate  (((6.99995))^10)and(((7.0003))^10) with a well-chosen Linear Approximation.  
(d) Measure the accuracy (measure the error) of those approximations.

Note: You’ll need to mimic the previous discussion, as usual, but you will also have to understand it properly.  If you are getting confused, reread the discussion and try to understand it all.  If you are confused, seek help.
Note: all these approximations should be fairly good.

One situation where Linear Approximations are useful is in astronomy.  Since the objects are so far away, when they move, the change in the angle from the earth is tiny.  In other words, the angle x is very close to x=0. 

Thus, we should use Linear approximations at x = 0.

Exercise 4

Here is a complicated-looking function involving trigonometric functions.

MrUgly[x_]:= (2Sin[x]Cos[x] -(Cos[x])^2)/(5Cos[x]-Tan[x]+(Sin[x])^2);
MrUgly[x]

We’ll replace each trigonometric function with a linear approximation at x = 0, and hopefully overall we’ll get a good approximation to the function.

(a) Find linear approximations for sin(x), cos(x), and tan(x) at x=0. 

We’ll call these functions “LSin”, “LCos”, “LTan”.
Use your answers to fill in the blanks:

LSin[x_]=

LCos[x_]=

LTan[x_]=

Using these in place of the trigonometric functions, we modify MrUgly and hopefully get a simpler function:

MrLessUgly[x_] := (2LSin[x]LCos[x] -(LCos[x])^2)/(5LCos[x]-LTan[x]+(LSin[x])^2);
MrLessUgly[x]

(b) Compare a few values of MrUgly and MrLessUgly near x=0, and compare to check the accuracy.  (You choose which values!)