Derivatives in LaTeX
A derivative measures a rate of change; in LaTeX it is written as a fraction with \frac{dy}{dx}, with primes for , or with \partial for partial derivatives.
LaTeX command
\frac{dy}{dx}Not the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
Leibniz notation uses \frac: \frac{dy}{dx} for a first derivative and \frac{d^2y}{dx^2} for a second. Note the exponent goes on the d in the numerator and on the variable in the denominator, not on the whole thing. Lagrange notation is shorter: uses an apostrophe that renders as a prime, and stacks two.
For functions of several variables, swap the straight d for \partial: \frac{\partial f}{\partial x} is a partial derivative. Mixed partials read \frac{\partial^2 f}{\partial x\, \partial y}, where the thin space \, keeps the two differentials from touching. The \partial symbol is a curly d, slanted like an italic letter.
Newton's dot notation, common in mechanics, marks a time derivative with \dot{x} and a second one with \ddot{x}. Some conventions typeset the differential operator upright as \mathrm{d}, giving \frac{\mathrm{d}y}{\mathrm{d}x}; the \mathrm command needs no special package and is supported by KaTeX.
Other forms
\frac{\partial f}{\partial x}partial derivativef'(x)prime notation\dot{x}Newton's dot notationExamples
$\frac{d}{dx}\left(x^2\right) = 2x$an ordinary derivative as an operator
$\frac{d^2y}{dx^2}$a second derivative in Leibniz form
$f'(x) \quad f''(x)$first and second derivatives with primes
$\frac{\partial^2 f}{\partial x\, \partial y}$a mixed second partial derivative
$\dot{x} = \frac{dx}{dt}$Newton's dot notation for velocity
Tips and common mistakes
- For a second derivative write
\frac{d^2y}{dx^2}: the square goes on the d up top and on the x below. - Use
\partial(not a plain d) for partial derivatives; it renders the correct curly symbol. - A prime is just an apostrophe: and work directly, with no need for
\primein ordinary use. \dot{x}and\ddot{x}give first and second time derivatives in Newton's notation.- For an upright differential operator, use
\mathrm{d}, as in\frac{\mathrm{d}y}{\mathrm{d}x}.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.
See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).
Convert your maths to LaTeX →FAQ
How do I write dy/dx in LaTeX?
Use \frac{dy}{dx}. The \frac command stacks dy over dx with a horizontal bar, which is the standard Leibniz form.
How do I write a second derivative?
In Leibniz notation use \frac{d^2y}{dx^2}. In Lagrange notation use with two apostrophes, which render as a double prime.
How do I write a partial derivative?
Use \partial in place of d: \frac{\partial f}{\partial x}. For higher orders, \frac{\partial^2 f}{\partial x^2}, and for mixed partials \frac{\partial^2 f}{\partial x\, \partial y}.