Jacobian Matrix Tutorial: A Step-by-Step Guide for Students
The Jacobian matrix is a central tool in multivariable calculus, used extensively in optimization, machine learning, robotics, and physics. While symbolic computation tools like SymPy automate its calculation, understanding how to compute a Jacobian by hand is essential for mastering the theory. This article provides a student-friendly, step-by-step guide to computing the Jacobian matrix manually, supported by geometric intuition and worked-out examples.
What Is the Jacobian Matrix?
Given a vector-valued function \[ \mathbf{F}(x_1, x_2, ..., x_n) = \begin{bmatrix} f_1(x_1, ..., x_n) \\ f_2(x_1, ..., x_n) \\ \vdots \\ f_m(x_1, ..., x_n) \end{bmatrix}, \] the Jacobian matrix is the matrix of all first-order partial derivatives: \[ J(\mathbf{x}) = \left[ \frac{\partial f_i}{\partial x_j} \right]_{m \times n}. \] This matrix tells us how sensitive each output \( f_i \) is to each input \( x_j \), serving as a multi-dimensional generalization of the derivative.
Step-by-Step Jacobian Calculation
Step 1: Define the Function
Let us consider a function from \( \mathbb{R}^2 \to \mathbb{R}^2 \): \[ \mathbf{F}(x, y) = \begin{bmatrix} f_1(x, y) \\ f_2(x, y) \end{bmatrix} = \begin{bmatrix} x^2 + y \\ \sin(xy) \end{bmatrix}. \]
Step 2: Compute Partial Derivatives
We compute the partial derivatives for each output function with respect to each input:
- \( \frac{\partial f_1}{\partial x} = 2x \)
- \( \frac{\partial f_1}{\partial y} = 1 \)
- \( \frac{\partial f_2}{\partial x} = y \cos(xy) \) (using chain rule)
- \( \frac{\partial f_2}{\partial y} = x \cos(xy) \)
Step 3: Assemble the Jacobian Matrix
\[ J(x, y) = \begin{bmatrix} 2x & 1 \\ y \cos(xy) & x \cos(xy) \end{bmatrix} \]
This matrix shows how small changes in \( x \) and \( y \) affect the outputs \( f_1 \) and \( f_2 \).
Worked Example 2: More Inputs than Outputs
Consider the function \( \mathbf{F}(x, y, z) = \begin{bmatrix} x + yz \\ x^2 + y^2 + z^2 \end{bmatrix} \).
Partial derivatives:
- \( \frac{\partial f_1}{\partial x} = 1 \), \( \frac{\partial f_1}{\partial y} = z \), \( \frac{\partial f_1}{\partial z} = y \)
- \( \frac{\partial f_2}{\partial x} = 2x \), \( \frac{\partial f_2}{\partial y} = 2y \), \( \frac{\partial f_2}{\partial z} = 2z \)
Jacobian: \[ J(x, y, z) = \begin{bmatrix} 1 & z & y \\ 2x & 2y & 2z \end{bmatrix} \]
Geometric Interpretation
The Jacobian matrix represents the best linear approximation to a function at a point. When the number of inputs equals the number of outputs, the Jacobian determinant tells us how volume (or area) is scaled under the transformation:
\[ \text{Volume}_{\text{new}} \approx |\det(J(\mathbf{x}))| \cdot \text{Volume}_{\text{original}}. \]For example, in transforming coordinates from Cartesian to polar: \[ x = r \cos \theta,\quad y = r \sin \theta, \] the Jacobian determinant is: \[ \left| \frac{\partial(x, y)}{\partial(r, \theta)} \right| = r. \] This factor appears when integrating over circular regions.
Practice Problems
- Compute the Jacobian of: \[ \mathbf{F}(x, y) = \begin{bmatrix} x \cdot y \\ \ln(x^2 + y^2) \end{bmatrix}. \]
- For the coordinate transformation \( \mathbf{F}(r, \theta) = (r \cos \theta, r \sin \theta) \), compute the Jacobian and its determinant.
Python Verification (Optional)
import sympy as sp
x, y = sp.symbols('x y')
f1 = x**2 + y
f2 = sp.sin(x * y)
F = sp.Matrix([f1, f2])
vars = sp.Matrix([x, y])
J = F.jacobian(vars)
J
1 Use sympy.Matrix.jacobian() for symbolic Jacobian computation in Python. Install with pip install sympy.
Summary Table
| Concept | Description |
|---|---|
| Jacobian Matrix | Matrix of first-order partial derivatives |
| Rows | Number of output functions |
| Columns | Number of input variables |
| Determinant | Measures volume change under transformation |
| Applications | Optimization, robotics, neural networks, integration |
Further Reading
- Calculus: Early Transcendentals by James Stewart
- 3Blue1Brown – Visual explanations of multivariable calculus
- SymPy Documentation for symbolic math in Python
No comments:
Post a Comment