L - Calclab

advertisement
Spring 2004 Math 253/501–503
12 Multivariable Differential Calculus
12.3 Partial Derivatives
c
Tue, 03/Feb
2004,
Art Belmonte
NOTE Computer algebra systems have superb capabilities when
it comes to partial derivatives. This includes the Symbolic Math
Toolbox in MATLAB as well as the TI-89. The drudgery involved
in computing derivatives by hand is avoided.
Hand Examples
Summary
746/2
With x = [x 1 , . . . , x n ], let u = f (x) be a real-valued function of n
variables defined on a subset D of Rn . Let ek be the standard unit
basis vector along the k th coordinate axis (as described in the
§11.2 lecture). The partial derivative of u with respect to (w.r.t.)
x k is
f (x + hek ) − f (x)
∂u
,
= lim
∂ xk
h
h→0
provided this limit exists. Here we are holding all variables except
x k constant and only allowing x k to vary. Hence we have a one
variable limit of a real difference quotient, just like in Calc 1, only
embedded in n-dimensional space.
Let f (x, y) =
p
1/2
4 − x 2 − 4y 2 = 4 − x 2 − 4y 2
.
• Find the partial derivatives f x (1, 0) and f y (1, 0).
• Interpret these numbers as slopes.
• Illustrate with sketches.
Solution
• First compute the derivatives in general.
−1/2
x
f x = 12 4 − x 2 − 4y 2
(−2x) = − p
4 − x 2 − 4y 2
4y
−1/2
f y = 12 4 − x 2 − 4y 2
(−8y) = − p
4 − x 2 − 4y 2
• practical partial differentiation: Differentiate w.r.t. the
variable in question, treating all other variables as constants.
• partial derivative notations:
∂u
∂f
= u xk = Dk (u) =
= f x k = Dk ( f )
∂ xk
∂ xk
1
• Thus f x (1, 0) = − √ and f y (1, 0) = 0. The cross-sectional
3
planes y = 0 and x = 1 intersect the surface z = f (x, y) in
curves. The slopes of the tangent lines of these curves at the
specified point are the respective partial derivatives of f .
• geometrical meaning of a partial derivative: Let’s illustrate
with a function of two variables, z = f (x, y). The graph of f
is a surface in x yz-space, a point on which is (a, b, f (a, b)).
The vertical plane y = b intersects the surface in a space
curve r(t) = [t, b, f (t, b)]. The partial derivative f x (a, b) is
just the slope of this curve at x = a. See the revisitation of
746/2 in the MATLAB examples below where this is shown
quite nicely via Cooper’s xslice and yslice commands.
• See the corresponding MATLAB example for pictures
illustrating these concepts.
• higher order partial derivatives (HOPD): Provided that the
relevant limits exist, higher order partial derivatives may be
computed using the aforementioned practical partial
differentiation method.
746/12
Let x y 2 z 3 + x 3 y 2 z = x + y + z. Compute
• HOPD subscript notation: The order of differentiation
corresponds to reading the subscripts left-to-right, as we read
English. For example, to compute f xy , first differentiate f
w.r.t. x, then differentiate the result w.r.t. y.
∂z
∂z
and
.
∂x
∂y
Solution
Implicitly differentiate like you did in Calc 1. (We’ll learn an
easier hand technique for implicit differentiation in Section 12.4.
Also see the corresponding MATLAB example that uses the fully
automatic idiff command I wrote.)
• HOPD squiggly-d notation: The order of differentiation
corresponds to reading the subscripts right-to-left, as we read
∂2 f
, the same
Hebrew or Arabic. For example, to compute
∂y∂ x
derivative as f xy , first differentiate f w.r.t. x, then
differentiate the result w.r.t. y.
• The equation implicitly defines z as a function of x and y.
Partially implicitly differentiate said equation w.r.t. x.
∂z
∂z
+ z3 y2 + x 3 y2
+ z 3x 2 y 2
xy 2 3z 2
∂x
∂x
∂z
3xy 2 z 2 + x 3 y 2 − 1
∂x
∂z
∂x
• Clairaut’s Theorem: If f (x, y) is defined on a circular disk
D containing (a, b) such that f xy and f yx are continuous on
D, then f xy (a, b) = f yx (a, b). [In other words, the mixed
partials are equal.]
1
∂z
∂x
=
1+
=
1 − y 2 z 3 − 3x 2 y 2 z
=
1 − y 2 z 3 − 3x 2 y 2 z
3xy 2 z 2 + x 3 y 2 − 1
•
Similarly,
1 − 2x yz 3 − 2x 3 yz
∂z
=
.
∂y
3x y 2 z 2 + x 3 y 2 − 1
746/43
Let u =
746/16
n
X
!1/2
x k2
. Compute first partial derivatives.
k=1
Let u = x 2 y 3 t 4 . Compute u x , u y , and u t .
Solution
∂u
=
We have
∂x j
Solution
We have u x = 2x y 3 t 4 , u y = 3x 2 y 2 t 4 , and u t = 4x 2 y 3 t 3 .
1
2
n
X
!−1/2
x k2
k=1
xj
2x j = v
.
uX
u n 2
t
x
k
k=1
746/20
746/44
Let f (x, y) = ln x 2 + y 2 . Compute first partial derivatives.
Let u = sin
!
kx k . Compute first partial derivatives.
k=1
Solution
We have
n
X
1
2y
2x
∂f
∂f
= 2
= 2
(2x) = 2
and
.
2
2
∂x
∂y
x +y
x +y
x + y2
Solution
!
n
X
∂u
= j cos
kx k .
We have
∂x j
746/27
k=1
Let g(x, y) = y tan x 2 y 3 . Compute first partial derivatives.
MATLAB Examples
Solution
s746x02 [746/2 revisited]
We have g x = y sec2 x 2 y 3 · 2x y 3 = 2x y 4 sec2 x 2 y 3 and
Let f (x, y) =
gy
y sec2 x 2 y 3 · 3x 2 y 2 + tan x 2 y 3
3x 2 y 3 sec2 x 2 y 3 + tan x 2 y 3 .
=
=
p
1/2
4 − x 2 − 4y 2 = 4 − x 2 − 4y 2
.
• Find the partial derivatives f x (1, 0) and f y (1, 0)
• Interpret these numbers as slopes.
• Illustrate with sketches.
746/32
Z
x
Let f (x, y) =
y
Solution
et
dt. Compute first partial derivatives.
t
1
• We have f x (1, 0) = − √ and f y (1, 0) = 0.
3
Solution
%
% Stewart 746/2
%
syms x y
f = sqrt(4 - xˆ2 -4*yˆ2); pretty(f)
• Treating y as a constant, apply the Fundamental Theorem of
ex
Calculus to obtain f x = .
x
Z y t
e
d y.
• Treating x as a constant, first write f (x, y) = −
x t
Now apply the Fundamental Theorem of Calculus to obtain
ey
fy = − .
y
2
(4 - x
2 1/2
- 4 y )
f x = diff(f,x);
f y = diff(f,y);
%
fx10 = subs(f x, [x y], sym([1 0])); pretty(fx10)
1/2
- 1/3 3
2
s746x12 [746/12 revisited]
fy10 = subs(f y, [x y], sym([1 0]))
fy10 =
Let x y 2 z 3 + x 3 y 2 z = x + y + z. Compute
0
∂z
∂z
and
.
∂x
∂y
%
echo off; diary off
Solution
• The cross-sectional planes y = 0 and x = 1 intersect the
surface z = f (x, y) in curves. The slopes of the tangent lines Here z is an implicit function of x and y. Rewrite the equation as
of these curves at the specified point are the respective partial x y 2 z 3 + x 3 y 2 z − (x + y + z) = 0; i.e., a left-hand side which we
derivatives of f .
understand to be set to zero. Now use the idiff command I wrote.
• The pictures tell the story. (The lengthy code to produce
these graphics is omitted.)
%
%
% Stewart 746/12
%
%
syms x y z
eq0 = x*yˆ2*zˆ3 - xˆ3*yˆ2*z - (x+y+z);
pretty(eq0)
Stewart 746/2: fy(1,0) = 0
Stewart 746/2: fx(1,0) = − 1 / 31/2
1.8
1.8
1.6
2 3
3 2
x y z - x y z - x - y - z
z x = idiff(eq0, z, x); pretty(z x)
1.4
z
z
1.6
1.4
1.2
1.2
1
0.5
2 3
2 2
-y z + 3 x y z + 1
---------------------2 2
3 2
3 x y z - x y - 1
z y = idiff(eq0, z, y); pretty(z y)
1
1.5
0
y
1
−0.5 0.5
0.5
1
x
−0.5
1.5
y
0
0.5
3
3
-2 x y z + 2 x y z + 1
-----------------------2 2
3 2
3 x y z - x y - 1
s746x08
Let z = x
√
∂z
∂z
y
and
.
y − √ . Compute
∂x
∂y
x
%
echo off; diary off
Solution
s746x22
MATLAB’s diff command renders the needful.
Let f (x, y) = x y . Compute first partial derivatives.
%
% Stewart 746/8
%
syms x y
z = x*sqrt(y) - y/sqrt(x); pretty(z)
Solution
1/2
x y
%
% Stewart 746/22
%
syms x y
f = xˆy; pretty(f)
y
- ---1/2
x
z x = diff(z,x); pretty(z x)
y
x
y
+ 1/2 ---3/2
x
f x = diff(f,x); pretty(f x)
x
1
1/2 ---- - ---1/2
1/2
y
x
f y = diff(f,y); pretty(f y)
1/2
y
y
x y
---x
z y = diff(z,y); pretty(z y)
y
x
%
%
echo off; diary off
echo off; diary off
3
log(x)
s746x27 [746/27 revisited]
s747x76
Let g(x, y) = y tan x 2 y 3 . Compute first partial derivatives.
Determine whether each of the following functions is a solution of
Laplace’s equation u x x + u yy = 0.
Solution
(a) u = x 2 + y 2
The results returned by MATLAB are trigonometrically equivalent
to those obtained by hand.
(b) u = x 2 − y 2
(c) u = x 3 + 3x y 2
p
(d) u = ln x 2 + y 2
%
% Stewart 746/27
%
syms x y
g = y * tan(xˆ2 * yˆ3); pretty(g)
(e) u = sin x cosh y + cos x sinh y
2
y tan(x
(f) u = e−x cos y − e−y cos x
3
y )
g x = diff(g,x); pretty(g x)
4
2 y
g y = diff(g,y); pretty(g y)
2
tan(x
2
(1 + tan(x
3 2
y ) ) x
Solution
We see that (b), (d), (e), (f) are solutions; (a) and (c) are not.
3
3
2 3 2
2
y ) + 3 y (1 + tan(x y ) ) x
%
%
% Stewart 747/76
%
syms x y
a = xˆ2 +yˆ2;
b = xˆ2 - yˆ2;
c = xˆ3 + 3*x*yˆ2;
d = log(sqrt(xˆ2 + yˆ2));
e = sin(x)*cosh(y) + cos(x)*sinh(y);
f = exp(-x)*cos(y) - exp(-y)*cos(x);
%
G = [a b c d e f]; L = sym(zeros(1,6));
for k = 1:6
u = G(k);
L(k) = simple(diff(u,x,2) + diff(u,y,2));
echo off
end; echo on
L
echo off; diary off
s747x60
Let z = cos2 (5x + 2y). Find all second partial derivatives.
Solution
Just use diff repeatedly. Notice that the mixed partials z xy and z yx
are equal, a corroboration of Clairaut’s Theorem.
%
% Stewart 747/60
%
syms x y
z = cos(5*x + 2*y)ˆ2; pretty(z)
L =
[
4,
0, 12*x,
0,
0,
0]
%
2
echo off; diary off
cos(5 x + 2 y)
z x = diff(z,x); pretty(z x)
-10 cos(5 x + 2 y) sin(5 x + 2 y)
z y = diff(z,y); pretty(z y)
s747x78
-4 cos(5 x + 2 y) sin(5 x + 2 y)
%
z xx = diff(z x, x); pretty(z xx)
Determine whether each of the following functions is a solution of
the wave equation u tt = a 2 u x x .
2
2
- 50 cos(5 x + 2 y)
2
2
- 20 cos(5 x + 2 y)
50 sin(5 x + 2 y)
z xy = diff(z x, y); pretty(z xy)
20 sin(5 x + 2 y)
z yx = diff(z y, x); pretty(z yx)
2
20 sin(5 x + 2 y)
z yy = diff(z y, y); pretty(z yy)
(c) u = (x − at)6 + (x − at)6
(d) u = sin(x − at) + ln(x + at)
2
- 20 cos(5 x + 2 y)
2
8 sin(5 x + 2 y)
(a) u = sin(kx) sin(akt)
(b) u = t/ a 2 t 2 − x 2
2
Solution
- 8 cos(5 x + 2 y)
%
We see that all four functions are solutions.
echo off; diary off
4
Solution
Stewart 12.3 / Example A
1
−1
−1.6 .8
−1.4
−1.2
−1
−0.8
0
− .6
.4
0
−
−0.2
.6
−0
.4
−0
0.8
0
.2
−0
y
0.6
0.4
0
L =
0.4
0.2
0.2
0 .8
0
0.6
%
% Stewart 747/78
%
syms a k t x
A = sin(k*x) * sin(a*k*t);
B = t / (aˆ2*tˆ2 - xˆ2);
C = (x - a*t)ˆ6 + (x + a*t)ˆ6;
D = sin(x - a*t) + log(x + a*t);
%
G = [A B C D]; L = sym(zeros(1,4));
for k = 1:4
u = G(k);
L(k) = simple(diff(u,t,2) - aˆ2*diff(u,x,2));
echo off
end; echo on
L
0
0
0.2
0.4
0.6
0.8
1
x
[ 0, 0, 0, 0]
%
Solution
echo off; diary off
Use difference quotients to numerically estimate derivatives.
s748x85
• We have
0.6 − 0.4
0.2
f (0.9, 0.2) − f (0.8, 0.2)
≈
=
= 2.
f x (0.8, 0.2) ≈
0.9 − 0.8
0.1
0.1
The total resistance R produced by three conductors with
resistances R1 , R2 , and R3 connected in a parallel electrical
1
1
1
1
∂R
circuit is given by the formula =
+
+
. Find
.
R
R1
R2
R3
∂ R1
• Similarly,
f y (0.8, 0.2) ≈
= −1.5.
Solution
Using idiff, we see that ∂ R/∂ R1 = R 2 /R12 .
%
% Stewart 748/85
%
syms R R1 R2 R3
eq0 = 1/R - (1/R1 + 1/R2 + 1/R3); pretty(eq0)
1
1
1
1/R - ---- - ---- - ---R1
R2
R3
R R1 = idiff(eq0, R, R1); pretty(R R1)
2
R
--2
R1
%
echo off; diary off
Example A
A contour map is given for a function f . Use it to estimate the
partial derivatives f x (0.8, 0.2) and f y (0.8, 0.2).
5
0.1 − 0.4
−0.3
f (0.8, 0.4) − f (0.8, 0.2)
≈
=
0.4 − 0.2
0.2
0.2
Download