> ## Documentation Index
> Fetch the complete documentation index at: https://resources.latex-cloud-studio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mathematical Expressions

> Master writing mathematical expressions in LaTeX. Learn fractions, roots, integrals, limits, and complex mathematical notation.

Learn how to write beautiful mathematical expressions in LaTeX, from basic arithmetic to complex formulas.

## Basic Mathematical Expressions

### Inline vs Display Math

<CodeGroup>
  ```latex math-modes theme={null}
  % 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}
  ```
</CodeGroup>

### Basic Operations

| Expression     | LaTeX                       | Result         |
| :------------- | :-------------------------- | :------------- |
| Addition       | `a + b`                     | a + b          |
| Subtraction    | `a - b`                     | a - b          |
| Multiplication | `a \times b` or `a \cdot b` | a × b or a · b |
| Division       | `a \div b` or `a / b`       | a ÷ b or a / b |
| Powers         | `a^2` or `a^{10}`           | a² or a¹⁰      |
| Subscripts     | `a_1` or `a_{ij}`           | a₁ or aᵢⱼ      |

## Fractions and Binomials

### Fractions

<Tabs>
  <Tab title="Code">
    <CodeGroup>
      ```latex fractions theme={null}
      % 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}}}
      ```
    </CodeGroup>
  </Tab>

  <Tab title="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
  </Tab>
</Tabs>

### Binomial Coefficients

<Tabs>
  <Tab title="Code">
    <CodeGroup>
      ```latex binomial theme={null}
      % Binomial coefficient
      \binom{n}{k} = \frac{n!}{k!(n-k)!}

      % Different styles
      \dbinom{n}{k}  % Display style
      \tbinom{n}{k}  % Text style
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Rendered output">
    * `\binom{n}{k}` → Binomial coefficient with n above k in parentheses
    * `\frac{n!}{k!(n-k)!}` → Factorial formula as a proper fraction
  </Tab>
</Tabs>

## Roots and Radicals

<Tabs>
  <Tab title="Code">
    <CodeGroup>
      ```latex roots theme={null}
      % 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}}
      ```
    </CodeGroup>
  </Tab>

  <Tab title="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)
  </Tab>
</Tabs>

## Sums, Products, and Integrals

### Summation

<Tabs>
  <Tab title="Code">
    <CodeGroup>
      ```latex summation theme={null}
      % 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
      ```
    </CodeGroup>
  </Tab>

  <Tab title="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)
  </Tab>
</Tabs>

### Products

<CodeGroup>
  ```latex products theme={null}
  % 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
  ```
</CodeGroup>

### Integration

<Tabs>
  <Tab title="Code">
    <CodeGroup>
      ```latex integrals theme={null}
      % 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}
      ```
    </CodeGroup>
  </Tab>

  <Tab title="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
  </Tab>
</Tabs>

## Limits and Derivatives

### Limits

<Tabs>
  <Tab title="Code">
    <CodeGroup>
      ```latex limits theme={null}
      % 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)
      ```
    </CodeGroup>
  </Tab>

  <Tab title="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
  </Tab>
</Tabs>

### Derivatives

<Tabs>
  <Tab title="Code">
    <CodeGroup>
      ```latex derivatives theme={null}
      % 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}
      ```
    </CodeGroup>
  </Tab>

  <Tab title="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
  </Tab>
</Tabs>

## Brackets and Delimiters

### Automatic Sizing

<CodeGroup>
  ```latex brackets theme={null}
  % 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
  ```
</CodeGroup>

### Special Cases

<CodeGroup>
  ```latex special-brackets theme={null}
  % 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}
  ```
</CodeGroup>

## Functions and Operators

### Standard Functions

<CodeGroup>
  ```latex functions theme={null}
  % 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)
  ```
</CodeGroup>

### Custom Operators

<CodeGroup>
  ```latex custom-operators theme={null}
  % 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)
  ```
</CodeGroup>

## Advanced Techniques

### Aligning Equations

<CodeGroup>
  ```latex align theme={null}
  \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*}
  ```
</CodeGroup>

### Text in Math Mode

<CodeGroup>
  ```latex text-in-math theme={null}
  % 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$.
  ```
</CodeGroup>

## Common Mistakes to Avoid

<Warning>
  **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
</Warning>

## Best Practices

<CardGroup cols={2}>
  <Card title="Use Proper Spacing" icon="ruler">
    Add thin spaces with `\,` in integrals: `\int f(x) \, dx`
  </Card>

  <Card title="Choose Right Size" icon="text-height">
    Use `\dfrac` for display fractions in inline math
  </Card>

  <Card title="Be Consistent" icon="check">
    Use the same notation style throughout your document
  </Card>

  <Card title="Number Wisely" icon="hashtag">
    Only number equations you reference
  </Card>
</CardGroup>

## Further Reading

<CardGroup cols={2}>
  <Card title="Symbol Reference" icon="book" href="/learn/reference/symbols">
    Complete list of mathematical symbols
  </Card>

  <Card title="Advanced Mathematics" icon="function" href="/learn/latex/mathematics/advanced-math">
    Complex mathematical typesetting
  </Card>

  <Card title="Equations Guide" icon="equals" href="/learn/latex/mathematics/equations">
    Multi-line equations and systems
  </Card>

  <Card title="Physics Notation" icon="atom" href="/learn/latex/specialized-notation/physics">
    Physics-specific expressions
  </Card>
</CardGroup>
