Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Equations and Formulas

Objective: Experiment with mathematical notation in LaTeX.

Getting Started: Basic Equations

Inline vs Display Style

To add math to your documents, you first have to enter math mode. Math can be displayed inline or in math blocks (called display style). To render equations in inline style, enclose them in a pair of dollar signs $...$.

Inline: Using $x + y = z$ will display the equation x+y=zx + y = z in the line.

To render equations in display style, LaTeX offers several options. We suggest using \[...\] to start.

Display: Using \[ x + y = z \] will display the equation centered on its own line as below.

x+y=zx + y = z

Simple Operators, Subscripts, Superscripts & More

To render simple equations, you also need to know syntax and commands for operators, relations, subscripts, superscripts, and fractions.

Operators & Relations:
+, -, =, >, < work as expected. Here are some other commands:

CommandDisplayCommandDisplay
\times×\times\cdot\cdot
\div÷\div\pm±
\geq\geq\leq\leq
\neq\neq\approx\approx

Subscript: use the underscore (_) / Superscript: use the carret (^)

Example: $x^n+1$ gives xn+1x^n+1 but $x^{n+1}$ gives xn+1x^{n+1}

Fractions:
To display a fraction, use the command \frac followed by the numerator and denominator in curly brackets.

Example: \frac{1}{x} gives 1x\frac{1}{x}

Exercise 1

Open a blank document in Overleaf and recreate this text in your document using LaTeX commands:


A quadratic equation is an equation of the form ax2+bx+c=0ax^2 + bx + c = 0 and such equations can be solved using the quadratic formula:

x=b±b24ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Commands needed: \frac{}{}, \pm, \sqrt{}

Challenge Exercise

Recreate these equations in your document:


a12+a22=a32a^2_1 + a^2_2 = a^2_3
v(x,t)=xx2+ea2tv(x,t) = x - \sqrt{x^2 + e^{a-2t}}

Next Steps: Greek Letters, Integrals & More

Greek Letters

Many equations and formulas use Greek letters. The command is simple - just the backslash and the name of the letter. Capitalize the command to get the capital letter. Here are some examples:

CommandDisplayCommandDisplay
\alphaα\alpha\muμ\mu
\betaβ\beta\piπ\pi
\GammaΓ\Gamma\rhoρ\rho
\deltaδ\delta\sigmaσ\sigma
\DeltaΔ\Delta\PhiΦ\Phi
\lambdaλ\lambda\omegaω\omega
\LambdaΛ\Lambda\OmegaΩ\Omega

Limits, Integrals, Products & Sums

There are also commands for common operations that take upper and lower bounds:

Limits:

\[ 
lim_{x \to \infty} f(x) 
\]

results in

limxf(x)lim_{x \to \infty} f(x)

Integrals

\[ 
\int_{a}^{b} x^2 dx 
\]

results in

abx2dx\int_{a}^{b} x^2 dx

Products

\[ 
\prod_{i=a}^{b} f(i) 
\]

results in

i=abf(i)\prod_{i=a}^{b} f(i)

Sums

What about summation (\sum)?

Exercise 2

Recreate these equations in your Overleaf document:


eiπ=1e^{i\pi} = -1
f(x)=i=0f(i)(0)i!xif(x) = \sum_{i=0}^{\infty} \frac{f^{(i)}(0)}{i!} x^i

Commands needed: \pi, \infty, \frac{}{}, \sum_{}^{}

Challenge Exercise

Recreate this text in your document:


Suppose that the measurable sets A1,A2,...A_1,A_2,... are “almost disjoint” in the sense that μ(AiAj)=0\mu(A_i \cap A_j) = 0 if iji \neq j. Prove that

μ(k=1Ak)=k1μ(Ak)\mu(\cup_{k=1}^{\infty} A_k) = \sum_{k \geq 1} \mu(A_k)

Commands needed: \mu, \cap, \neq, \cup, \infty, \sum_{}, \geq

More Advanced: Math Packages

amsmath & amssymb Packages

LaTeX has many packages that you can use to extend its capabilities. The amsmath and amssymb packages provide you with additional symbols and commands for structuring equations.

To include them, add these commands to the preamble of your LaTeX document:
\usepackage{amsmath}
\usepackage{amssymb}

amsmath: Equations Environment

Use the \begin{equation}...\end{equation} command to include a numbered equation in display mode.

\begin{equation}
(I - A \otimes A) vec(X) = vec(Q)
\end{equation}

results in

(IAA)vec(X)=vec(Q)(1)(I - A \otimes A) vec(X) = vec(Q) \tag{1}

amsmath: Align Environment

The command \begin{align}...\end{align} will allow you to align a series of equations around a common element, which you can identify with the ampersand (&).

\begin{align}
\frac{d}{dx} \sin x &= \cos x \\
\frac{d}{dx} \cos x &= -\sin x \\
\frac{d}{dx} \tan x &= \sec^2 x
\end{align}

results in

ddxsinx=cosxddxcosx=sinxddxtanx=sec2x\begin{align} \frac{d}{dx} \sin x &= \cos x \tag{2} \\ \frac{d}{dx} \cos x &= -\sin x \tag{3} \\ \frac{d}{dx} \tan x &= \sec^2 x \tag{4} \end{align}

amsmath: Cases Environment

The amsmath package also offers the \begin{cases}...\end{cases} command, which enables you to display an equation with multiple cases.

\begin{equation*}
f(n) = \begin{cases}
0 & n=0 \\
1 & n=1 \\
f(n-1) + f(n-2) & \text{otherwise}
\end{cases}
\end{equation*}

results in

f(n)={0n=01n=1f(n1)+f(n2)otherwisef(n) = \begin{cases} 0 & n=0 \\ 1 & n=1 \\ f(n-1) + f(n-2) & \text{otherwise} \end{cases}

amssymb

The amssymb package provides access to more options for mathematical symbols including additional fonts such as Blackboard-Bold.

More fonts:
\mathbb{R} gives R\mathbb{R} for the set of real numbers.

More symbols:
\approxeq \Rightarrow \approxeq
\nleq \Rightarrow \nleq

Alternate versions of symbols:
in plain LaTeX: \emptyset \Rightarrow \emptyset
with amssymb: \varnothing \Rightarrow \varnothing

Matrices

To create a matrix in your document, you can use the the {array} environment in plain LaTeX or the simpler {matrix} environment in the amsmath package.

\[
\begin{matrix}
a & b & c \\
d & e & f \\
\end{matrix}
\]

results in a matrix with no brackets:

abcdef\begin{matrix} a & b & c \\ d & e & f \\ \end{matrix}

{pmatrix}

(abcdef)\begin{pmatrix} a & b & c \\ d & e & f \\ \end{pmatrix}

{bmatrix}

[abcdef]\begin{bmatrix} a & b & c \\ d & e & f \\ \end{bmatrix}

{vmatrix}

abcdef\begin{vmatrix} a & b & c \\ d & e & f \\ \end{vmatrix}

Exercise 3

Part A

Recreate these matrices in your Overleaf document:


A=[abcpqruvw],B=(αβγλμνρστ)A = \begin{bmatrix} a & b & c \\ p & q & r \\ u & v & w \end{bmatrix}, B = \begin{pmatrix} \alpha & \beta & \gamma \\ \lambda & \mu & \nu \\ \rho & \sigma & \tau \end{pmatrix}

Commands needed: \begin{bmatrix}...\end{bmatrix}, \begin{pmatrix}...\end{pmatrix}, \alpha, \beta, \gamma, \lambda, \mu, \nu, \rho, \sigma, \tau

Part B

Recreate this equation in your document:


Σ(i=13fiρxi)dSx=0 for any ρC(R3)\int_{\Sigma} \left( \sum_{i=1}^{3} f_i \frac{\partial \rho}{\partial x_i} \right) dS_x = 0 \text{ for any } \rho \in C^{\infty} (\mathbb{R}^3)

Commands needed: \begin{equation*}...\end{equation*}, \int_{}, \Sigma, \sum_{}^{}, \frac{}{}, \partial, \rho, \text{}, \in, \infty, \mathbb{}