Learn how to write beautiful mathematical expressions in LaTeX, from basic arithmetic to complex formulas.

Basic Mathematical Expressions

Inline vs Display Math

% Inline math - flows with text
The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.

% Display math - centered on its own line
The quadratic formula is:
\[x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\]

% Or using equation environment (numbered)
\begin{equation}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\end{equation}

Basic Operations

ExpressionLaTeXResult
Additiona + ba + b
Subtractiona - ba - b
Multiplicationa \times b or a \cdot ba × b or a · b
Divisiona \div b or a / ba ÷ b or a / b
Powersa^2 or a^{10}a² or a¹⁰
Subscriptsa_1 or a_{ij}a₁ or aᵢⱼ

Fractions and Binomials

Fractions

% Basic fraction
\frac{1}{2}

% Nested fractions
\frac{1}{1 + \frac{1}{2}}

% Display style in inline math
$\displaystyle\frac{1}{2}$

% Text style in display math
\[\textstyle\frac{1}{2}\]

% Continued fractions
\cfrac{1}{2 + \cfrac{1}{3 + \cfrac{1}{4}}}
Rendered output:
\frac{1}{2}1/2
\frac{a+b}{c+d}(a+b)/(c+d)
\frac{1}{1 + \frac{1}{2}}1/(1 + 1/2)

Binomial Coefficients

% Binomial coefficient
\binom{n}{k} = \frac{n!}{k!(n-k)!}

% Different styles
\dbinom{n}{k}  % Display style
\tbinom{n}{k}  % Text style
Rendered output:
\binom{n}{k}(n k)
\frac{n!}{k!(n-k)!}n! / k!(n-k)!

Roots and Radicals

% Square root
\sqrt{x}

% nth root
\sqrt[n]{x}

% Complex expressions
\sqrt{a^2 + b^2}

% Nested roots
\sqrt{\sqrt{x} + 1}

% Large expressions
\sqrt{\frac{x^2 + y^2}{2}}
Rendered output:
\sqrt{x}√x
\sqrt[n]{x}ⁿ√x
\sqrt{a^2 + b^2}√(a² + b²)

Sums, Products, and Integrals

Summation

% Basic sum
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}

% Display style
\displaystyle\sum_{i=1}^{n} i

% Multiple indices
\sum_{\substack{i=1 \\ j=1}}^{n} a_{ij}

% Infinite series
\sum_{n=0}^{\infty} \frac{x^n}{n!} = e^x
Rendered output:
\sum_{i=1}^{n} iΣ(i=1 to n) i
\sum_{n=0}^{\infty} x^nΣ(n=0 to ∞) x^n

Products

% Basic product
\prod_{i=1}^{n} i = n!

% Infinite product
\prod_{n=1}^{\infty} \left(1 - \frac{1}{n^2}\right)

% Co-product
\coprod_{i \in I} X_i

Integration

% Indefinite integral
\int f(x) \, dx

% Definite integral
\int_a^b f(x) \, dx

% Multiple integrals
\iint_D f(x,y) \, dx \, dy
\iiint_V f(x,y,z) \, dx \, dy \, dz

% Contour integrals
\oint_C F \cdot dr

% With limits
\int\limits_0^1 x^2 \, dx = \frac{1}{3}
Rendered output:
\int f(x) \, dx∫ f(x) dx
\int_a^b f(x) \, dx∫(from a to b) f(x) dx
\oint_C F \cdot dr∮ F · dr around C

Limits and Derivatives

Limits

% Basic limit
\lim_{x \to 0} \frac{\sin x}{x} = 1

% Limits with approach direction
\lim_{x \to 0^+} f(x)
\lim_{x \to 0^-} f(x)

% Limits to infinity
\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e

% Supremum and infimum
\sup_{x \in A} f(x)
\inf_{x \in A} f(x)
Rendered output:
\lim_{x \to 0} \frac{\sin x}{x}lim(x→0) sin(x)/x = 1
\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^nlim(n→∞) (1 + 1/n)^n = e

Derivatives

% First derivative
f'(x) \text{ or } \frac{df}{dx}

% Higher derivatives
f''(x) \text{ or } \frac{d^2f}{dx^2}

% Partial derivatives
\frac{\partial f}{\partial x}
\frac{\partial^2 f}{\partial x \partial y}

% With evaluation
\left.\frac{df}{dx}\right|_{x=0}
Rendered output:
f’(x)f’(x) (first derivative)
\frac{df}{dx}df/dx (derivative notation)
\frac{\partial f}{\partial x}∂f/∂x (partial derivative)

Brackets and Delimiters

Automatic Sizing

% Manual sizing
( \big( \Big( \bigg( \Bigg(

% Automatic sizing
\left( \frac{1}{2} \right)
\left[ \sum_{i=1}^n i \right]
\left\{ x : x > 0 \right\}

% Mixed delimiters
\left< \frac{a}{b} \right|
\left\lfloor x \right\rfloor
\left\lceil x \right\rceil

Special Cases

% Cases
f(x) = \begin{cases}
  x^2 & \text{if } x \geq 0 \\
  -x^2 & \text{if } x < 0
\end{cases}

% Matrices with brackets
\begin{pmatrix}
  a & b \\
  c & d
\end{pmatrix}

% Norms and absolute values
\|x\| = \sqrt{x_1^2 + x_2^2}
|x| = \begin{cases}
  x & \text{if } x \geq 0 \\
  -x & \text{if } x < 0
\end{cases}

Functions and Operators

Standard Functions

% Trigonometric
\sin x, \cos x, \tan x
\arcsin x, \arccos x, \arctan x

% Exponential and logarithmic
\exp(x), e^x
\log x, \ln x, \log_2 x

% Hyperbolic
\sinh x, \cosh x, \tanh x

% Other functions
\max(a,b), \min(a,b)
\gcd(a,b), \det(A)

Custom Operators

% Define new operators
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator*{\argmax}{arg\,max}

% Usage
\sgn(x) = \begin{cases}
  1 & x > 0 \\
  0 & x = 0 \\
  -1 & x < 0
\end{cases}

\argmax_{x \in \mathbb{R}} f(x)

Advanced Techniques

Aligning Equations

\begin{align}
  (a + b)^2 &= (a + b)(a + b) \\
            &= a^2 + ab + ba + b^2 \\
            &= a^2 + 2ab + b^2
\end{align}

% Without numbering
\begin{align*}
  e^{i\pi} + 1 &= 0 \\
  e^{i\pi} &= -1
\end{align*}

Text in Math Mode

% Using \text
f(x) = x^2 \text{ for all } x \in \mathbb{R}

% Using \intertext in align
\begin{align}
  a &= b + c \\
  \intertext{and therefore}
  a - b &= c
\end{align}

% Math in text
The value of $\pi$ is approximately $3.14159$.

Common Mistakes to Avoid

Common errors:
  • Forgetting braces for multi-character superscripts: Use x^{10} not x^10
  • Missing \ before functions: Use \sin x not sin x
  • Wrong math mode: Use $...$ for inline, \[...\] for display
  • Inconsistent notation: Stick to one style throughout your document

Best Practices

Use Proper Spacing

Add thin spaces with \, in integrals: \int f(x) \, dx

Choose Right Size

Use \dfrac for display fractions in inline math

Be Consistent

Use the same notation style throughout your document

Number Wisely

Only number equations you reference

Further Reading