Testing LaTeX Math Rendering

January 01, 2024

This post demonstrates the math rendering capabilities of the blog using KaTeX.

Inline Math

The famous mass-energy equivalence formula E=mc2E = mc^2 shows the relationship between energy and mass. We can also write inline expressions like 0ex2dx=π2\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}.

Display Math

The Cauchy-Schwarz inequality:

(k=1nakbk)2(k=1nak2)(k=1nbk2)\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)

Euler’s identity, often considered one of the most beautiful equations:

eiπ+1=0e^{i\pi} + 1 = 0

The definition of the Gaussian distribution:

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

Matrices and Vectors

A simple rotation matrix in 2D:

R(θ)=(cosθsinθsinθcosθ)R(\theta) = \begin{pmatrix} \cos\theta & -\sin\theta \ \sin\theta & \cos\theta \end{pmatrix}

Physics Equations

Newton’s second law of motion:

F=ma\mathbf{F} = m\mathbf{a}

The Schrodinger equation:

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

Code Example

Here’s a simple Python function:

def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

This demonstrates that code blocks work alongside math rendering.