Using Mathematical Equations

This page demonstrates how to use mathematical notation in your research wiki.

Inline Math

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

For example, the variance formula $\sigma^2 = \frac{1}{n}\sum_{i=1}^{n}(x_i - \mu)^2$ appears within this sentence.

The Sharpe ratio is calculated as $SR = \frac{\mu - r_f}{\sigma}$ where $\mu$ is the expected return, $r_f$ is the risk-free rate, and $\sigma$ is the standard deviation.

Display Math (Centered)

Use double dollar signs $$...$$ for centered display equations:

\[E[R_p] = \sum_{i=1}^{n} w_i \cdot E[R_i]\]

Portfolio Variance

\[\sigma_p^2 = \mathbf{w}^T \mathbf{\Sigma} \mathbf{w}\]

where $\mathbf{w}$ is the vector of portfolio weights and $\mathbf{\Sigma}$ is the covariance matrix.

Maximum Sharpe Ratio

\[\mathbf{w}^* = \frac{\mathbf{\Sigma}^{-1}(\mathbf{\mu} - r_f \mathbf{1})}{\mathbf{1}^T \mathbf{\Sigma}^{-1}(\mathbf{\mu} - r_f \mathbf{1})}\]

Common Financial Formulas

Black-Scholes Formula

\[C(S,t) = S_t N(d_1) - Ke^{-r(T-t)}N(d_2)\]

where:

\[d_1 = \frac{\ln(\frac{S_t}{K}) + (r + \frac{\sigma^2}{2})(T-t)}{\sigma\sqrt{T-t}}\] \[d_2 = d_1 - \sigma\sqrt{T-t}\]

GARCH(1,1) Model

\[\sigma_t^2 = \omega + \alpha \epsilon_{t-1}^2 + \beta \sigma_{t-1}^2\]

Kelly Criterion

\[f^* = \frac{p(b+1)-1}{b}\]

where $p$ is the probability of winning, $b$ is the odds, and $f^*$ is the optimal fraction to bet.

Greek Letters

Common Greek letters used in finance:

Matrices and Vectors

Return vector:

\[\mathbf{r} = \begin{bmatrix} r_1 \\ r_2 \\ \vdots \\ r_n \end{bmatrix}\]

Covariance matrix:

\[\mathbf{\Sigma} = \begin{bmatrix} \sigma_1^2 & \sigma_{12} & \cdots & \sigma_{1n} \\ \sigma_{21} & \sigma_2^2 & \cdots & \sigma_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ \sigma_{n1} & \sigma_{n2} & \cdots & \sigma_n^2 \end{bmatrix}\]

Sum and Product Notation

Portfolio return:

\[R_p = \sum_{i=1}^{n} w_i R_i\]

Compound return:

\[R_{total} = \prod_{t=1}^{T} (1 + R_t) - 1\]

Fractions and Limits

Continuous compounding:

\[\lim_{n \to \infty} \left(1 + \frac{r}{n}\right)^n = e^r\]

Tips for Writing Math

  1. Inline math: Use $...$ for equations within text
  2. Display math: Use $$...$$ for centered, standalone equations
  3. Escape special characters: Use backslash: \{, \}, \_
  4. Spaces: LaTeX ignores spaces in math mode; use \quad or \; for spacing
  5. Line breaks: Use \\ for line breaks in aligned equations

Common LaTeX Commands

\frac{numerator}{denominator}   # Fraction
\sqrt{x}                         # Square root
\sum_{i=1}^{n}                  # Summation
\int_{a}^{b}                    # Integral
\lim_{x \to \infty}             # Limit
\mathbf{x}                      # Bold (for vectors)
\hat{x}                         # Hat (estimator)
\bar{x}                         # Bar (mean)
\alpha, \beta, \sigma           # Greek letters

More Complex Example

The Kalman filter update equations:

Prediction: \(\begin{align} \hat{x}_{t|t-1} &= F_t \hat{x}_{t-1|t-1} + B_t u_t \\ P_{t|t-1} &= F_t P_{t-1|t-1} F_t^T + Q_t \end{align}\)

Update: \(\begin{align} \tilde{y}_t &= z_t - H_t \hat{x}_{t|t-1} \\ K_t &= P_{t|t-1} H_t^T (H_t P_{t|t-1} H_t^T + R_t)^{-1} \\ \hat{x}_{t|t} &= \hat{x}_{t|t-1} + K_t \tilde{y}_t \\ P_{t|t} &= (I - K_t H_t) P_{t|t-1} \end{align}\)