5.3 KiB
@slide(layout=chapter-slide)
@number 8
@title Typesetting mathematics
@slide(layout=content-and-preview)
@title Formula environments 🧮
@content
$2 \sqrt{\frac{\pi^2}{3} \cdot c_2}$
Mathematical formulas are only accepted in the so-called math mode.
In-line formulas must therefor be guarded by two dollar signs.
We can also use the equation block environment:
\begin{equation}
2 \sqrt{\frac{\pi^2}{3} \cdot c_2}
\end{equation}
Packages: amsmath, amsthm, amssymb, mathtools
@slide(layout=content-only)
@title Examples
@content
| source code | result |
|---|---|
| `\sum_{i=1}^{n}x^2` | $\sum_{i=1}^{n} x^2$ |
| `12 \leq 4 x^2 + 13` | $12 \leq 4 x^2 + 13$ |
| `{n \choose k}` | ${n \choose k}$ |
@slide(layout=content-and-preview)
@title Aligning a group of equations
@content
The align environment permits us to align equations at certain positions like the ‘ = ’ character.
\begin{align}
13 \cdot (4a - 3)^2 &= 13 … \\
&= 208a^2 - 312a + 117
\end{align}
- ++ The equations will be aligned with respect to the ampersands (‘
&’). - ++ We can mark a new line using ‘
\\’. - ++
alignandequationwill not be numbered if we add an asterisk after their names (e. g.\begin{align*}and\end{align*}).
@slide(layout=task-without-number)
@task-number 8a
@title Typesetting mathematics
@content
Code up the following formulas in the file exercises/maths/math-formulas.tex.
| Meaning | Result |
|---|---|
| Gravitational acceleration | 9,81\,\frac{m}{s^2} |
| Formula to solve quadratic equations | x_{1,2} = - \frac{p}{2} \pm \sqrt{\left(\frac{p}{2}\right)^2 - q} |
| Another formula to solve quadratic equations | x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} |
| Catalan numbers | C_n = \frac{1}{n+1} {2n \choose n} = \frac{(2n)!}{(n+1)!n!} |
@slide(layout=task-without-number)
@task-number 8b
@title Typesetting mathematics
@content
Code up the following formulas in the file exercises/maths/math-formulas.tex.
| Meaning | Result |
|---|---|
| Definition of factorial | n! = \prod_{i=1}^{n} i |
| Set of all odd natural numbers | \{ x \mid x \in \mathbb{N}, \text{odd}(x) \} |
Elimination \neg\exists x |
\neg\exists x . p(x) \Leftrightarrow \forall x . \neg p(x) |
@slide(layout=extra-content-only)
@title More examples
@content
| source code | result |
|---|---|
| `(x)`, `[x]`, `\lbrace x \rbrace`, `\lvert x \rvert` | $(x), [x], \lbrace x\rbrace, \lvert x\rvert$ |
| `\exists`, `\forall`, `\in`, `\notin`, `\infty` |
$\exists,\forall,\in,\notin,\infty$ |
| `\alpha`, `\beta`, `\Gamma`, `\Delta`, `\varepsilon`, `\pi` |
$\alpha, \beta, \Gamma, \Delta, \varepsilon, \pi$ |
| `\rightarrow`, `\leftarrow`, `\Rightarrow`, `\Leftarrow`, `\Leftrightarrow` | $\rightarrow, \leftarrow, \Rightarrow, \Leftarrow, \Leftrightarrow$ |
| `(A \cup B) \cap C` | $(A \cup B) \cap C$ |
| `(A \lor B) \land C` | $(A \lor B) \land C$ |
| `(A \cdot B) \times C` | $(A \cdot B) \times C$ |
@slide(layout=extra-content-only)
@title Height-adapting braces
@content
| source code | result |
|---|---|
| `\left( \frac{1}{2} \right)` | $\left( \frac{1}{2} \right)$ |
| `\left[ \frac{1}{2} \right]` | $\left[ \frac{1}{2} \right]$ |
| `\left\lbrace \frac{1}{2} \right\rbrace` | $\left\lbrace \frac{1}{2} \right\rbrace$ |
$4 \cdot \left( \frac{1}{2} % …
$4 \cdot \left(\frac{1}{2} +\frac{3}{ 12 \cdot \left( 2 + \frac{1}{86 \cdot \left(\frac{1}{2} + 24 \right)} \right)} \right)$
@slide(layout=extra-content-and-preview)
@title Depicting boundaries
@content
The bounds of an integral can be enforced to appear above and below the integral symbol using the \limits command.
This is the standard behaviour for sums, products and limits.
\sum_{i=1}^{n^2}(x+2)
\prod_{j=1}^{100}(3 \cdot x)
\lim_{x \rightarrow \infty}(14x^3 - 12)
\int\limits_{-12}^{4}(14x^3 - 12)
Don't use `\limits` inline.
@slide(layout=extra-content-only)
@title Set-builder notation
@content In certain situations, it is more adequate to use textual predicates or long function names within the set builder notation.
This is where \text{} comes into play.
$\left\lbrace x \mid frequency(x) \geq 20\right\rbrace$
$\left\lbrace x \mid \text{frequency}(x) \geq 20\right\rbrace$
$\left\lbrace x \mid \text{frequency} …