Differentials & Approximations
> restart:
Definition
: (page 262, Stewart) Let
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
, then f'(x) is the ratio of differentials: f'(x) =
.
e.g. Find dy if f(x) =
, x = 1, dx = 0.1
> f:=x->x^2+x;
> dy:=diff(f(x),x)*dx;
> subs({x=1,dx=0.1},dy);
Recall: f'(x) =
. This definition means that if
is
close
to zero then
should be
close
to f'(x):
is almost f'(x) when
is "small." Let's use the last e.g. with
= 0.1 to illustrate.
e.g.
> f(x);
> almost_fprime:=(f(x+1/10)-f(x))/(1/10);
> simplify(%);
> fprime:=diff(f(x),x);
> fprime-almost_fprime;
> simplify(%);
Not a bad approximation. If you try it with a smaller
it will be even closer.
Now, recall:
=
. If
then the above approximation can be written as f'(x)
~
if
is "small." Since
dx
was defined as an
independent
variable, we are free to say "let
dx
=
" and the equation becomes
~ f'(x)
dx.
i.e.
~
dy
.
Another approach would yield
so
~
.
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 =
.
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;
> dy:=subs({x=1,dx=1/10},dy);
To see how closely dy approximates
:
> DELTA_Y:=f(1+1/10)-f(1);
DELTA_Y-dy;
e.g. Use
~
to approximate the cube root of 63.5
Notice, if f(x) =
, x = 64 and dx = -0.5 then the equation above gives us
= f(64 - 0.5) ~
dy
+f(64)
> f:=x->x^(1/3);f_prime:=diff(f(x),x);
> expr:=f_prime*dx+f(x);
> approx:=subs({dx=-1/2,x=64},expr);
> simplify(%);evalf(%);
Check the approximation:
> evalf((approx)^3);63.5^(1/3);evalf(63.5^(1/3)-approx);
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 =
at (1,1).
> h:=x->sqrt(x);slope:=D(h)(1);line:=y-1=slope*(x-1);
> Tline:=solve(line,y);
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);
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,
~
.
e.g.
Use the linearization of
at x = 1 to approximate
.
> L:=unapply(Tline,x);
> L(0.95);sqrt(0.95);L(0.95)-sqrt(0.95);
Another example !
If
, 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.
We first confirm that (1,1) is, indeed, on the curve:
> subs({x=1,y=1},piri);
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,
, and use differentials:
~
, choosing x = 1 and
=
and realizing that f(1) = 1 (why?).
> solve(piri,y);
> f_prime:=implicitdiff(piri,y,x);
> dy:=subs({x=1,y=1},f_prime)*1/100;
=> f(x) + dy = f(1) + dy = ...
> 1+dy;evalf(1+dy);
It follows that (1.01,1.01) is almost on the curve:
> subs({x=1.01,y=1.01},piri);
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");
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
.
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
"close to"
x
= 0.
> p:=x->A*x^2+B*x+C;f:=x->cos(x); # in this e.g., a = 0.
> D(p)(x);D(f)(x);
> D(D(p))(x);D(D(f))(x);
> p(0);f(0);
=> p(0) = f(0) <=> C = 1
> D(p)(0);D(f)(0);
=> p'(0) = f'(0) <=> B = 0
> D(D(p))(0);D(D(f))(0);
p''(0) = f''(0) <=> A =
.
=> let p(x) =
.
> A:=-1/2: B:=0: C:=1:
> p(x);
> plot([f(x),p(x)],x=-6..6,y=-1..1,colour=[blue,red],thickness=3);
> p(0.1);cos(0.1);
> p(0.01);cos(0.01);