Math Equations with KaTeX

Learn how to write beautiful mathematical equations using LaTeX syntax


Math Equations with KaTeX

This CMS supports beautiful mathematical equations using KaTeX, a fast math typesetting library that uses LaTeX syntax.

Inline Math

Use single dollar signs $...$ for inline math equations:

The famous equation $E = mc^2$ shows the relationship between energy and mass.

The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.

Euler's identity: $e^{i\pi} + 1 = 0$ is considered one of the most beautiful equations in mathematics.

More Inline Examples

  • The Pythagorean theorem: $a^2 + b^2 = c^2$
  • Circle area: $A = \pi r^2$
  • Derivative notation: $\frac{dy}{dx}$
  • Summation: $\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$

Block Math

Use double dollar signs $$...$$ for display equations (centered on their own line):

$$ E = mc^2 $$
$$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$
$$ \int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2} $$

Mathematical Formulas

Fractions and Binomials

$$ \frac{n!}{k!(n-k)!} = \binom{n}{k} $$

Matrices

$$ \begin{pmatrix} a & b \\ c & d \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} ax + by \\ cx + dy \end{pmatrix} $$

Summations and Products

$$ \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} $$
$$ \prod_{i=1}^{n} i = n! $$

Integrals

The fundamental theorem of calculus:

$$ \int_a^b f(x) \, dx = F(b) - F(a) $$

Double integral:

$$ \iint_D f(x,y) \, dA = \int_a^b \int_c^d f(x,y) \, dy \, dx $$

Limits

$$ \lim_{x \to \infty} \frac{1}{x} = 0 $$
$$ \lim_{h \to 0} \frac{f(x+h) - f(x)}{h} = f'(x) $$

Greek Letters

Inline: $\alpha$, $\beta$, $\gamma$, $\delta$, $\epsilon$, $\theta$, $\lambda$, $\mu$, $\pi$, $\sigma$, $\phi$, $\omega$

$$ \Alpha, \Beta, \Gamma, \Delta, \Theta, \Lambda, \Pi, \Sigma, \Phi, \Omega $$

Common Mathematical Notation

Set Theory

$$ A \cup B \quad A \cap B \quad A \subseteq B \quad x \in A \quad \emptyset $$

Logic

$$ \land \quad \lor \quad \neg \quad \implies \quad \iff \quad \forall \quad \exists $$

Calculus

Derivatives: $f'(x)$, $\frac{df}{dx}$, $\frac{\partial f}{\partial x}$

Integrals: $\int f(x) dx$, $\oint f(x) dx$

Linear Algebra

Vectors: $\vec{v}$, $\mathbf{v}$

Dot product: $\vec{a} \cdot \vec{b}$

Cross product: $\vec{a} \times \vec{b}$

Advanced Examples

Taylor Series

$$ f(x) = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \frac{f'''(a)}{3!}(x-a)^3 + \cdots $$

Fourier Transform

$$ \hat{f}(\xi) = \int_{-\infty}^{\infty} f(x) e^{-2\pi i x \xi} \, dx $$

Differential Equations

The wave equation:

$$ \frac{\partial^2 u}{\partial t^2} = c^2 \frac{\partial^2 u}{\partial x^2} $$

Probability

Normal distribution:

$$ f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2} $$

Bayes' theorem:

$$ P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)} $$

Computer Science Applications

Big O Notation

The time complexity of binary search: $O(\log n)$

The space complexity of merge sort: $O(n)$

Algorithm Analysis

$$ T(n) = 2T\left(\frac{n}{2}\right) + O(n) $$

Information Theory

Shannon entropy:

$$ H(X) = -\sum_{i=1}^{n} P(x_i) \log_2 P(x_i) $$

Combining Math with Asides

Physics Examples

Classical Mechanics

Newton's second law: $F = ma$

Kinetic energy:

$$ KE = \frac{1}{2}mv^2 $$

Electromagnetism

Maxwell's equations in vacuum:

$$ \nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0} $$
$$ \nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t} $$

Quantum Mechanics

Schrödinger equation:

$$ i\hbar\frac{\partial}{\partial t}\Psi(\mathbf{r},t) = \hat{H}\Psi(\mathbf{r},t) $$

Step-by-Step Example

steps

  1. Write the equation in LaTeX

    For the quadratic formula, write: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

  2. Preview the rendering

    It appears as: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

  3. Use display mode for emphasis

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

    Renders as:

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

Quick Reference

Description LaTeX Rendered
Fraction \frac{a}{b} $\frac{a}{b}$
Square root \sqrt{x} $\sqrt{x}$
Nth root \sqrt[n]{x} $\sqrt[n]{x}$
Exponent x^2 $x^2$
Subscript x_i $x_i$
Sum \sum_{i=1}^{n} $\sum_{i=1}^{n}$
Product \prod_{i=1}^{n} $\prod_{i=1}^{n}$
Integral \int_a^b $\int_a^b$
Infinity \infty $\infty$
Pi \pi $\pi$

Best Practices

Use inline math for equations within text ✅ Use block math for important standalone equations ✅ Keep it readable - Don't overcomplicate simple expressions ✅ Add context - Explain what variables represent ✅ Test rendering - Make sure complex equations display correctly