Skip to main content
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} → ½ (proper fraction with numerator above denominator)
  • \frac{a+b}{c+d} → (a+b)/(c+d) with horizontal fraction bar
  • \frac{1}{1 + \frac{1}{2}} → Nested fraction with proper sizing

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} → Binomial coefficient with n above k in parentheses
  • \frac{n!}{k!(n-k)!} → Factorial formula as a proper fraction

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 (square root with radical sign)
  • \sqrt[n]{x} → ⁿ√x (nth root with index)
  • \sqrt{a^2 + b^2} → √(a² + b²) (radical extends over entire expression)

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 → Σ with i=1 below and n above (summation notation)
  • \sum_{n=0}^{\infty} x^n → Σ with limits from 0 to ∞ (infinite series)

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 (indefinite integral)
  • \int_a^b f(x) \, dx → ∫ with limits a to b (definite integral)
  • \oint_C F \cdot dr → ∮ contour integral around path 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 with x→0 subscript, equals 1
  • \lim_{n \to \infty} (1 + 1/n)^n → lim with n→∞ subscript, equals 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) with prime notation for first derivative
  • \frac{df}{dx} → df/dx in Leibniz notation (fraction form)
  • \frac{\partial f}{\partial x} → ∂f/∂x for partial derivatives

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