Multivariable Functions & Partial Derivatives

1379 words
7 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Multivariable Functions & Partial Derivatives ## ๐ŸŽฏ Learning Objectives After this topic you will be able to: - Visualise functions $f: \mathbb{R}^n \to \mathbb{R}$ as surfaces, contour maps, and colour plots - Compute partial derivatives of any order - Interpret partial derivatives as slopes in coordinate directi...

Multivariable Functions & Partial Derivatives

๐ŸŽฏ Learning Objectives

After this topic you will be able to:
  • Visualise functions f:Rnโ†’Rf: \mathbb{R}^n \to \mathbb{R} as surfaces, contour maps, and colour plots
  • Compute partial derivatives of any order
  • Interpret partial derivatives as slopes in coordinate directions
  • Use the chain rule for multivariable functions
  • Compute partial derivatives of implicit functions

๐Ÿ“‹ Prerequisites

  • Single-variable calculus (BSMA1001) โ€” derivatives, chain rule
  • The transition from 1D to nnD is the key leap in this course

1. Intuition: From Curves to Surfaces

A single-variable function f(x)f(x) gives a curve in R2\mathbb{R}^2. A multivariable function f(x,y)f(x,y) gives a surface in R3\mathbb{R}^3. (Diagram)

1.1 Ways to Visualise f(x,y)f(x,y)

MethodDescriptionExample f(x,y)=x2+y2f(x,y) = x^2 + y^2
3D surface plotPlot z=f(x,y)z = f(x,y) as a surfaceParaboloid
Contour plotLevel curves f(x,y)=cf(x,y) = cConcentric circles
Colour mapColour pixels by function valueHeat map

2. Partial Derivatives

2.1 Definition

Definition (Partial Derivative). The partial derivative of f(x1,โ€ฆ,xn)f(x_1, \dots, x_n) with respect to xix_i is:
>โˆ‚fโˆ‚xi=limโกhโ†’0f(x1,โ€ฆ,xi+h,โ€ฆ,xn)โˆ’f(x1,โ€ฆ,xn)h>> \frac{\partial f}{\partial x_i} = \lim_{h \to 0} \frac{f(x_1, \dots, x_i + h, \dots, x_n) - f(x_1, \dots, x_n)}{h} >
To compute: treat all variables except xix_i as constants, then differentiate normally.
Example 1: Partial derivatives of f(x,y)=x2y+y3f(x,y) = x^2y + y^3
โˆ‚fโˆ‚x=2xy\frac{\partial f}{\partial x} = 2xy (treat yy as constant) โˆ‚fโˆ‚y=x2+3y2\frac{\partial f}{\partial y} = x^2 + 3y^2 (treat xx as constant) Example 2: Partial derivatives of f(x,y,z)=exysinโก(z)f(x,y,z) = e^{xy}\sin(z)
โˆ‚fโˆ‚x=yexysinโก(z)\frac{\partial f}{\partial x} = ye^{xy}\sin(z) โˆ‚fโˆ‚y=xexysinโก(z)\frac{\partial f}{\partial y} = xe^{xy}\sin(z) โˆ‚fโˆ‚z=exycosโก(z)\frac{\partial f}{\partial z} = e^{xy}\cos(z)

2.2 Geometric Interpretation

โˆ‚fโˆ‚x(a,b)\frac{\partial f}{\partial x}(a,b) is the slope of the surface z=f(x,y)z = f(x,y) at (a,b)(a,b) in the xx-direction (holding yy fixed at bb). (Diagram)

3. Higher-Order Partial Derivatives

Definition (Second partial derivatives).
>fxx=โˆ‚2fโˆ‚x2=โˆ‚โˆ‚x(โˆ‚fโˆ‚x)>> f_{xx} = \frac{\partial^2 f}{\partial x^2} = \frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}\right) >
>fxy=โˆ‚2fโˆ‚yโˆ‚x=โˆ‚โˆ‚y(โˆ‚fโˆ‚x)>> f_{xy} = \frac{\partial^2 f}{\partial y \partial x} = \frac{\partial}{\partial y}\left(\frac{\partial f}{\partial x}\right) >
Similarly fyxf_{yx} and fyyf_{yy}.

3.1 Clairaut's Theorem (Equality of Mixed Partials)

Theorem (Clairaut). If fxyf_{xy} and fyxf_{yx} are continuous at a point, then:
>fxy=fyx>> f_{xy} = f_{yx} >
Order of mixed partials doesn't matter for "nice" functions (most functions you'll encounter).
Example 3: Higher-order partials
f(x,y)=x3y2+x2yf(x,y) = x^3y^2 + x^2y
fx=3x2y2+2xyf_x = 3x^2y^2 + 2xy fy=2x3y+x2f_y = 2x^3y + x^2
fxx=6xy2+2yf_{xx} = 6xy^2 + 2y fyy=2x3f_{yy} = 2x^3 fxy=6x2y+2xf_{xy} = 6x^2y + 2x fyx=6x2y+2xf_{yx} = 6x^2y + 2x (same as fxyf_{xy} โœ“)

4. The Chain Rule

4.1 One Independent Variable

If z=f(x,y)z = f(x,y) and x=x(t)x = x(t), y=y(t)y = y(t), then:
dzdt=โˆ‚fโˆ‚xdxdt+โˆ‚fโˆ‚ydydt\frac{dz}{dt} = \frac{\partial f}{\partial x}\frac{dx}{dt} + \frac{\partial f}{\partial y}\frac{dy}{dt}

4.2 Multiple Independent Variables

If z=f(x,y)z = f(x,y) and x=x(s,t)x = x(s,t), y=y(s,t)y = y(s,t), then:
โˆ‚zโˆ‚s=โˆ‚fโˆ‚xโˆ‚xโˆ‚s+โˆ‚fโˆ‚yโˆ‚yโˆ‚s\frac{\partial z}{\partial s} = \frac{\partial f}{\partial x}\frac{\partial x}{\partial s} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial s} โˆ‚zโˆ‚t=โˆ‚fโˆ‚xโˆ‚xโˆ‚t+โˆ‚fโˆ‚yโˆ‚yโˆ‚t\frac{\partial z}{\partial t} = \frac{\partial f}{\partial x}\frac{\partial x}{\partial t} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial t}
Example 4: Chain rule
f(x,y)=x2+y2f(x,y) = x^2 + y^2, x=t2x = t^2, y=ety = e^t.
dfdt=โˆ‚fโˆ‚xdxdt+โˆ‚fโˆ‚ydydt=2xโ‹…2t+2yโ‹…et=4xt+2yet\frac{df}{dt} = \frac{\partial f}{\partial x}\frac{dx}{dt} + \frac{\partial f}{\partial y}\frac{dy}{dt} = 2x \cdot 2t + 2y \cdot e^t = 4xt + 2ye^t.
Substitute: x=t2x = t^2, y=ety = e^t: dfdt=4t3+2e2t\frac{df}{dt} = 4t^3 + 2e^{2t}.
Direct check: f(t)=t4+e2tf(t) = t^4 + e^{2t}, dfdt=4t3+2e2t\frac{df}{dt} = 4t^3 + 2e^{2t} โœ“

5. Edge Cases & Gotchas

SituationWhat Happens
** ff not continuous at a point**Partial derivatives may not exist
** fxyโ‰ fyxf_{xy} \neq f_{yx} **Possible for pathological functions; Clairaut's theorem requires continuity
**Point where fx=fy=0f_x = f_y = 0 **Critical point (potential local min, max, or saddle)

6. Common Pitfalls

โŒ Pitfall 1: Forgetting which variable is held constant

โˆ‚โˆ‚x(x2+xy+y2)=2x+y\frac{\partial}{\partial x}(x^2 + xy + y^2) = 2x + y โ€” the yy in y2y^2 is constant, so derivative is 0. The yy in xyxy is constant, so derivative is yy.

โŒ Pitfall 2: Confusing fxyf_{xy} with โˆ‚2fโˆ‚xโˆ‚y\frac{\partial^2 f}{\partial x \partial y}

fxy=โˆ‚โˆ‚y(โˆ‚fโˆ‚x)f_{xy} = \frac{\partial}{\partial y}(\frac{\partial f}{\partial x}), so it's differentiate with respect to xx first, then yy. But by Clairaut, order often doesn't matter.

โŒ Pitfall 3: Applying chain rule with wrong dependency tree

Draw a dependency tree: if ff depends on x,yx,y, which depend on s,ts,t, the chain rule has two terms.

7. Formula Summary Table

ConceptFormula
Partial derivativeโˆ‚fโˆ‚xi=limโกhโ†’0f(x+hei)โˆ’f(x)h\frac{\partial f}{\partial x_i} = \lim_{h\to0} \frac{f(x+he_i)-f(x)}{h}
Mixed partial (Clairaut)fxy=fyxf_{xy} = f_{yx} (if continuous)
Chain rule (1 dep)dzdt=โˆ‚fโˆ‚xdxdt+โˆ‚fโˆ‚ydydt\frac{dz}{dt} = \frac{\partial f}{\partial x}\frac{dx}{dt} + \frac{\partial f}{\partial y}\frac{dy}{dt}
Chain rule (multi)โˆ‚zโˆ‚s=โˆ‚fโˆ‚xโˆ‚xโˆ‚s+โˆ‚fโˆ‚yโˆ‚yโˆ‚s\frac{\partial z}{\partial s} = \frac{\partial f}{\partial x}\frac{\partial x}{\partial s} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial s}

8. ๐Ÿ“ Practice Questions

Q1: Compute partial derivatives
f(x,y)=sinโก(xy)+xeyf(x,y) = \sin(xy) + xe^y. Find fxf_x and fyf_y.
Solution: fx=ycosโก(xy)+eyf_x = y\cos(xy) + e^y (treat yy constant) fy=xcosโก(xy)+xeyf_y = x\cos(xy) + xe^y (treat xx constant) Q2: Second partials
f(x,y)=lnโก(x2+y2)f(x,y) = \ln(x^2 + y^2). Find fxxf_{xx}, fxyf_{xy}, fyxf_{yx}, fyyf_{yy}.
Solution: fx=2xx2+y2f_x = \frac{2x}{x^2+y^2}, fy=2yx2+y2f_y = \frac{2y}{x^2+y^2}. fxx=2(x2+y2)โˆ’2x(2x)(x2+y2)2=2(y2โˆ’x2)(x2+y2)2f_{xx} = \frac{2(x^2+y^2) - 2x(2x)}{(x^2+y^2)^2} = \frac{2(y^2 - x^2)}{(x^2+y^2)^2}. fxy=โˆ’2x(2y)(x2+y2)2=โˆ’4xy(x2+y2)2f_{xy} = \frac{-2x(2y)}{(x^2+y^2)^2} = \frac{-4xy}{(x^2+y^2)^2}. fyx=โˆ’2y(2x)(x2+y2)2=โˆ’4xy(x2+y2)2f_{yx} = \frac{-2y(2x)}{(x^2+y^2)^2} = \frac{-4xy}{(x^2+y^2)^2} (same โœ“). fyy=2(x2+y2)โˆ’2y(2y)(x2+y2)2=2(x2โˆ’y2)(x2+y2)2f_{yy} = \frac{2(x^2+y^2) - 2y(2y)}{(x^2+y^2)^2} = \frac{2(x^2 - y^2)}{(x^2+y^2)^2}. Q3: Chain rule
z=exyz = e^{xy}, x=cosโกtx = \cos t, y=sinโกty = \sin t. Find dzdt\frac{dz}{dt}.
Solution: dzdt=โˆ‚zโˆ‚xdxdt+โˆ‚zโˆ‚ydydt=yexy(โˆ’sinโกt)+xexy(cosโกt)\frac{dz}{dt} = \frac{\partial z}{\partial x}\frac{dx}{dt} + \frac{\partial z}{\partial y}\frac{dy}{dt} = ye^{xy}(-\sin t) + xe^{xy}(\cos t). =exy(โˆ’ysinโกt+xcosโกt)=ecosโกtsinโกt(โˆ’sinโก2t+cosโก2t)=ecosโกtsinโกtcosโก(2t)= e^{xy}(-y\sin t + x\cos t) = e^{\cos t\sin t}(-\sin^2 t + \cos^2 t) = e^{\cos t\sin t}\cos(2t). Q4: Verification of Clairaut
Verify fxy=fyxf_{xy} = f_{yx} for f(x,y)=tanโกโˆ’1(y/x)f(x,y) = \tan^{-1}(y/x).
Solution: fx=โˆ’yx2+y2f_x = \frac{-y}{x^2+y^2}, fy=xx2+y2f_y = \frac{x}{x^2+y^2}. fxy=โˆ’(x2+y2)+y(2y)(x2+y2)2=โˆ’x2โˆ’y2+2y2(x2+y2)2=y2โˆ’x2(x2+y2)2f_{xy} = \frac{-(x^2+y^2) + y(2y)}{(x^2+y^2)^2} = \frac{-x^2 - y^2 + 2y^2}{(x^2+y^2)^2} = \frac{y^2 - x^2}{(x^2+y^2)^2}. fyx=(x2+y2)โˆ’x(2x)(x2+y2)2=x2+y2โˆ’2x2(x2+y2)2=y2โˆ’x2(x2+y2)2f_{yx} = \frac{(x^2+y^2) - x(2x)}{(x^2+y^2)^2} = \frac{x^2 + y^2 - 2x^2}{(x^2+y^2)^2} = \frac{y^2 - x^2}{(x^2+y^2)^2}. Equal โœ“. Q5: Implicit differentiation
If x2+y2+z2=1x^2 + y^2 + z^2 = 1, find โˆ‚zโˆ‚x\frac{\partial z}{\partial x}.
Solution: Differentiate both sides w.r.t. xx, treating zz as function of x,yx,y: 2x+0+2zโˆ‚zโˆ‚x=0โ‡’โˆ‚zโˆ‚x=โˆ’xz2x + 0 + 2z \frac{\partial z}{\partial x} = 0 \Rightarrow \frac{\partial z}{\partial x} = -\frac{x}{z} (for zโ‰ 0z \neq 0). Q6: Tangent plane equation
Find the tangent plane to z=x2+y2z = x^2 + y^2 at (1,2,5)(1,2,5).
Solution: z0=5z_0 = 5, fx(1,2)=2f_x(1,2) = 2, fy(1,2)=4f_y(1,2) = 4. Tangent plane: zโˆ’5=2(xโˆ’1)+4(yโˆ’2)z - 5 = 2(x-1) + 4(y-2), or z=2x+4yโˆ’5z = 2x + 4y - 5. Q7: Linear approximation
Approximate f(1.1,1.9)f(1.1, 1.9) for f(x,y)=x2yf(x,y) = x^2y using linearisation at (1,2)(1,2).
Solution: f(1,2)=2f(1,2) = 2, fx=2xyf_x = 2xy, fx(1,2)=4f_x(1,2) = 4, fy=x2f_y = x^2, fy(1,2)=1f_y(1,2) = 1. L(x,y)=2+4(xโˆ’1)+1(yโˆ’2)=4x+yโˆ’4L(x,y) = 2 + 4(x-1) + 1(y-2) = 4x + y - 4. L(1.1,1.9)=4(1.1)+1.9โˆ’4=4.4+1.9โˆ’4=2.3L(1.1, 1.9) = 4(1.1) + 1.9 - 4 = 4.4 + 1.9 - 4 = 2.3. Actual: f(1.1,1.9)=(1.1)2(1.9)=1.21ร—1.9=2.299f(1.1, 1.9) = (1.1)^2(1.9) = 1.21 \times 1.9 = 2.299. Close! Q8: 3-variable function partials
f(x,y,z)=xyz+xyf(x,y,z) = xyz + \frac{x}{y}. Find fxf_x, fyf_y, fzf_z.
Solution: fx=yz+1yf_x = yz + \frac{1}{y} fy=xzโˆ’xy2f_y = xz - \frac{x}{y^2} fz=xyf_z = xy Q9: Partial differential equation
Show f(x,y)=eโˆ’xsinโกyf(x,y) = e^{-x}\sin y satisfies Laplace's equation fxx+fyy=0f_{xx} + f_{yy} = 0.
Solution: fx=โˆ’eโˆ’xsinโกyf_x = -e^{-x}\sin y, fxx=eโˆ’xsinโกyf_{xx} = e^{-x}\sin y. fy=eโˆ’xcosโกyf_y = e^{-x}\cos y, fyy=โˆ’eโˆ’xsinโกyf_{yy} = -e^{-x}\sin y. fxx+fyy=eโˆ’xsinโกyโˆ’eโˆ’xsinโกy=0f_{xx} + f_{yy} = e^{-x}\sin y - e^{-x}\sin y = 0 โœ“. Q10: Wave equation
Show u(x,t)=sinโก(xโˆ’at)u(x,t) = \sin(x-at) satisfies the wave equation utt=a2uxxu_{tt} = a^2 u_{xx}.
Solution: ux=cosโก(xโˆ’at)u_x = \cos(x-at), uxx=โˆ’sinโก(xโˆ’at)u_{xx} = -\sin(x-at). ut=โˆ’acosโก(xโˆ’at)u_t = -a\cos(x-at), utt=โˆ’a2sinโก(xโˆ’at)=a2(โˆ’sinโก(xโˆ’at))=a2uxxu_{tt} = -a^2\sin(x-at) = a^2(-\sin(x-at)) = a^2 u_{xx} โœ“.

๐Ÿ”— Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.