Differentials & Approximations

> restart:

Definition : (page 262, Stewart) Let [Maple Math] where f is any differentiable function. The differential dx is considered as an independent variable (i.e. can be given any Real value) and the differential dy is defined by the equation dy = f' ( x ) dx .

Notice: 1) the definition means that dy is a dependent variable since its value depends on the choices for x and dx (and, of course, on the function f).

2) if [Maple Math] , then f'(x) is the ratio of differentials: f'(x) = [Maple Math] .

e.g. Find dy if f(x) = [Maple Math] , x = 1, dx = 0.1

> f:=x->x^2+x;

[Maple Math]

> dy:=diff(f(x),x)*dx;

[Maple Math]

> subs({x=1,dx=0.1},dy);

[Maple Math]

Recall: f'(x) = [Maple Math] . This definition means that if [Maple Math] is close to zero then [Maple Math] should be close to f'(x): [Maple Math] is almost f'(x) when [Maple Math] is "small." Let's use the last e.g. with [Maple Math] = 0.1 to illustrate.

e.g.

> f(x);

[Maple Math]

> almost_fprime:=(f(x+1/10)-f(x))/(1/10);

[Maple Math]

> simplify(%);

[Maple Math]

> fprime:=diff(f(x),x);

[Maple Math]

> fprime-almost_fprime;

[Maple Math]

> simplify(%);

[Maple Math]

Not a bad approximation. If you try it with a smaller [Maple Math] it will be even closer.

Now, recall: [Maple Math] = [Maple Math] . If [Maple Math] then the above approximation can be written as f'(x) [Maple Math] ~ [Maple Math] if [Maple Math] is "small." Since dx was defined as an independent variable, we are free to say "let dx = [Maple Math] " and the equation becomes [Maple Math] ~ f'(x) dx. i.e. [Maple Math] ~ dy . Another approach would yield [Maple Math] so [Maple Math] ~ [Maple Math] .

See the blackboard for a geometric interpretation of these variables.

e.g. Approximate the change in y when x changes from 1 to 1.1 if y = [Maple Math] .

For this, f is as in the previous e.g. and we want dy when x = 1 and dx = 1/10.

> dy:=diff(f(x),x)*dx;

[Maple Math]

> dy:=subs({x=1,dx=1/10},dy);

[Maple Math]

To see how closely dy approximates [Maple Math] :

> DELTA_Y:=f(1+1/10)-f(1);

[Maple Math]

DELTA_Y-dy;

[Maple Math]

e.g. Use [Maple Math] ~ [Maple Math] to approximate the cube root of 63.5

Notice, if f(x) = [Maple Math] , x = 64 and dx = -0.5 then the equation above gives us [Maple Math] = f(64 - 0.5) ~ dy +f(64)

> f:=x->x^(1/3);f_prime:=diff(f(x),x);

[Maple Math]

[Maple Math]

> expr:=f_prime*dx+f(x);

[Maple Math]

> approx:=subs({dx=-1/2,x=64},expr);

[Maple Math]

> simplify(%);evalf(%);

[Maple Math]

[Maple Math]

Check the approximation:

> evalf((approx)^3);63.5^(1/3);evalf(63.5^(1/3)-approx);

[Maple Math]

[Maple Math]

[Maple Math]

Approximation by Linearization

As another way to look at this "local" function approximation technique consider approximating the square root function "near" x = 1 by using the tangent line to y = [Maple Math] at (1,1).

> h:=x->sqrt(x);slope:=D(h)(1);line:=y-1=slope*(x-1);

[Maple Math]

[Maple Math]

[Maple Math]

> Tline:=solve(line,y);

[Maple Math]

The plots below should convince you that tangent line at (1,1) is a good approximation to the function as long as you don't stray to far from x = 1. This is because the tangent line has the same value and the same slope at (1,1).

> plot({h(x),Tline},x=0..2,colour=[blue,red],thickness=2);

[Maple Plot]

The tangent line to f(x) at (a,f(a)) is called the linearization of f at x = a. If you call the linearization L then we have L(x) = f(a) + f'(a)(x - a) and "near" x = a we have f(x) ~ L(x). Using the preceeding example it follows that near x = 1, [Maple Math] ~ [Maple Math] .

e.g. Use the linearization of [Maple Math] at x = 1 to approximate [Maple Math] .

> L:=unapply(Tline,x);

[Maple Math]

> L(0.95);sqrt(0.95);L(0.95)-sqrt(0.95);

[Maple Math]

[Maple Math]

[Maple Math]

Another example !

If [Maple Math] , estimate the y-coordinate when x changes from 1 to 1.01 given that (1,1) is a point on the curve.

> restart:with(plots):

> piri:=x^2=y^3*(2-y); # "piri" is short for piriform curve.

[Maple Math]

We first confirm that (1,1) is, indeed, on the curve:

> subs({x=1,y=1},piri);

[Maple Math]

The following shows that Maple cannot readily use the equation to solve for y as an implicit function of x. Nevertheless, we assume that the equation defines y implicitly as a function of x, [Maple Math] , and use differentials: [Maple Math] ~ [Maple Math] , choosing x = 1 and [Maple Math] = [Maple Math] and realizing that f(1) = 1 (why?).

> solve(piri,y);

[Maple Math]

> f_prime:=implicitdiff(piri,y,x);

[Maple Math]

> dy:=subs({x=1,y=1},f_prime)*1/100;

[Maple Math]

=> f(x) + dy = f(1) + dy = ...

> 1+dy;evalf(1+dy);

[Maple Math]

[Maple Math]

It follows that (1.01,1.01) is almost on the curve:

> subs({x=1.01,y=1.01},piri);

[Maple Math]

As an alternative, you can find the linearization of f at (1,1) (even though you cannot find f!) to estimate f(1.1). You should confirm that you get the same answer (L(x) = x is the linearization!). The following plot should convince you.

> P1:=implicitplot(piri,x=-2..2,y=0..2,numpoints=10000,colour=blue,thickness=2):

> P2:=plot(x,x=-2..2,y=0..2,colour=red,thickness=3):

> display(P1,P2,title="A Piriform curve and it's Linearization at x = 1");

[Maple Plot]

Quadratic Approximation

Suppose f(x) is any function and we are interested in approximating f near x = a by a quadratic. We begin by letting [Maple Math] . [Maple Math] is chosen this way to make it easy to make p and f agree at x = a.

We proceed to find the coefficients of p by forcing the two functions and their first and second derivatives to agree at x = a (this means that the two functions will have the same value at x = a, will have the same slope at x = a and will have the curvature at x = a) .

e.g. Find a quadratic function that approximates [Maple Math] "close to" x = 0.

> p:=x->A*x^2+B*x+C;f:=x->cos(x); # in this e.g., a = 0.

[Maple Math]

[Maple Math]

> D(p)(x);D(f)(x);

[Maple Math]

[Maple Math]

> D(D(p))(x);D(D(f))(x);

[Maple Math]

[Maple Math]

> p(0);f(0);

[Maple Math]

[Maple Math]

=> p(0) = f(0) <=> C = 1

> D(p)(0);D(f)(0);

[Maple Math]

[Maple Math]

=> p'(0) = f'(0) <=> B = 0

> D(D(p))(0);D(D(f))(0);

[Maple Math]

[Maple Math]

p''(0) = f''(0) <=> A = [Maple Math] .

=> let p(x) = [Maple Math] .

> A:=-1/2: B:=0: C:=1:

> p(x);

[Maple Math]

> plot([f(x),p(x)],x=-6..6,y=-1..1,colour=[blue,red],thickness=3);

[Maple Plot]

> p(0.1);cos(0.1);

[Maple Math]

[Maple Math]

> p(0.01);cos(0.01);

[Maple Math]

[Maple Math]