Writing Partial Derivatives in LaTeX Made Easy
Writing Partial Derivatives in LaTeX: The Practical Guide
Partial derivatives show up everywhere — thermodynamics, machine learning, economics, physics. If you're writing technical documents, you need to know how to typeset them properly. LaTeX makes this straightforward once you know the commands.
This guide cuts through the noise. You'll learn the exact syntax, common pitfalls, and how to handle everything from basic first-order derivatives to messy higher-order cases.
Basic Partial Derivative Syntax
The \partial command gives you the ∂ symbol. Combine it with fractions and you've got your basic partial derivative:
\frac{\partial f}{\partial x}
This produces ∂f/∂x. That's it. The \frac command handles the fraction, \partial gives you the symbol.
For inline math (same line as text), the fraction looks cramped. Use \tfrac or \partial f / \partial x instead:
\frac{\partial f}{\partial x} \quad \text{vs} \quad \partial f / \partial x
Common Notations You'll Actually Use
First-Order Partial Derivative
\frac{\partial f}{\partial x} — the standard notation. Most textbooks use this.
Partial with Respect to Multiple Variables
Need ∂²f/(∂x∂y)? Use nested fractions:
\frac{\partial^2 f}{\partial x \partial y}
The ^2 goes on the \partial, not the function.
Subscript Notation
Physics and engineering often use subscript notation:
f_x = \frac{\partial f}{\partial x}
Or mixed: f_{xy} = \frac{\partial^2 f}{\partial x \partial y}
Evaluated Partial Derivatives
When you need to show evaluation at a point, use the vertical bar with subscript:
\left. \frac{\partial f}{\partial x} \right|_{x=0}
The \left. and \right| commands make the bar scale to match the fraction height.
Higher-Order Partial Derivatives
Second-order and beyond get messy fast. Here's the breakdown:
- ∂²f/∂x²:
\frac{\partial^2 f}{\partial x^2} - ∂²f/(∂x∂y):
\frac{\partial^2 f}{\partial x \partial y} - ∂³f/(∂x²∂y):
\frac{\partial^3 f}{\partial x^2 \partial y}
The exponent placement matters. Put it directly after \partial for the derivative symbol, or at the end for the variable.
When to Use Packages
Plain LaTeX handles most cases. But if you're writing heavy math, these packages help:
- amsmath — included in most distributions, adds alignment environments for multi-line equations
- physics — provides
\pdv{f}{x}shorthand that saves typing - mathtools — fixes some amsmath quirks, adds more precise spacing controls
The physics package syntax:
\pdv{f}{x} % first derivative
\pdv[2]{f}{x} % second derivative
\pdv{f}{x}{y} % mixed partial
\pdv{f}{x}{y}{z} % triple mixed
It's cleaner but adds a dependency. Plain \frac{\partial}{\partial} works without any packages — and works everywhere.
Comparison: Common Partial Derivative Notations
| Notation Type | LaTeX Code | Best For |
|---|---|---|
| Fraction notation | \frac{\partial f}{\partial x} | Standard math, textbooks |
| Inline fraction | \partial f / \partial x | Running text, tight spaces |
| Subscript notation | f_x or f_{xy} | Physics, continuum mechanics |
| Evaluated at point | \left. \frac{\partial f}{\partial x} \right|_{x=a} | Thermodynamics, optimization |
| Short-hand (physics pkg) | \pdv{f}{x} | Rapid typing, long documents |
Getting Started: Your First Partial Derivative
Step 1: Open a math environment with $ ... $ for inline or \[ ... \] for display.
Step 2: Type \partial for the symbol.
Step 3: Build your fraction with \frac{numerator}{denominator}.
Example — find ∂f/∂x where f(x,y) = x²y + sin(x):
\[ \frac{\partial}{\partial x}(x^2y + \sin x) = 2xy + \cos x \]
Example — mixed partial ∂²f/(∂x∂y) where f(x,y) = e^(xy):
\[ \frac{\partial^2 f}{\partial y \partial x} = e^{xy} + xy e^{xy} \]
Example — evaluated partial at a point:
\[ \left. \frac{\partial f}{\partial x} \right|_{(1,0)} = 2 \]
Common Mistakes to Avoid
- Forgetting the caret on the second derivative: it's
\partial^2, not\partial2 - Wrong order in mixed partials: ∂²f/(∂x∂y) ≠ ∂²f/(∂y∂x) unless Clairaut's theorem applies
- Scaling issues with vertical bars: always use
\left.and\right|together, or the bar won't match fraction height - Over-complicating: if plain fractions work, don't add packages just for shorthand
Quick Reference Cheat Sheet
Bookmark this. You'll come back to it.
- Basic partial:
\frac{\partial f}{\partial x} - Second partial:
\frac{\partial^2 f}{\partial x^2} - Mixed partial:
\frac{\partial^2 f}{\partial x \partial y} - Evaluated:
\left. \frac{\partial f}{\partial x} \right|_{x=a} - With physics package:
\pdv{f}{x}
That's everything you need for 95% of partial derivative notation. The syntax is consistent — once you understand the pattern, you can extend it to any order or variable combination.