Maths notes
Theorems, proofs and real formulas from LaTeX-style commands you define yourself.
What it shows
Write maths notes with LaTeX's commands, defined here as ordinary rules, and real TeX formulas.
What you learn
TeX maths in a line and on its own, a LaTeX block, a TikZ picture, line and inline rules that read backslash commands, environments as block rules, a theorem's name from its [optional argument].
Try this
- Change
theoremin the palette to #c92a2a, and every theorem box turns red. - Change \section{Comparison tests} to \subsection{Comparison tests}, and the heading drops a level.
This week ends with Euler's theorem. To get there, we first need to know when a sum of infinitely many terms has a value at all, and how to tell without working the value out.
Geometric series
A series \sum a_k converges when its partial sums S_n = a_1 + \dots + a_n approach a limit. The limit is the sum of the series.
For a real number r, the partial sums S_n = 1 + r + r^2 + \dots + r^{n} satisfy S_n - rS_n = 1 - r^{n+1}. When |r| < 1 the last power shrinks to nothing, so the sums approach a limit. With r = \tfrac12 you can see it: each term fills half of what is left of a square.
If |r| < 1, then \displaystyle\sum_{k=0}^{\infty} r^k = \frac{1}{1-r}.
From S_n = \dfrac{1 - r^{n+1}}{1 - r} and r^{n+1} \to 0 for |r| < 1, the partial sums converge to \dfrac{1}{1-r}.
Comparison tests
A series \sum a_k converges absolutely when \sum |a_k| converges. Absolute convergence implies convergence, and any rearrangement then has the same sum.
If 0 \le a_k \le b_k for every k and \sum b_k converges, then \sum a_k converges too.
The comparison test bounds Euler's series long before we know its value. Each term from the second on is less than a term of a series that telescopes:
The harmonic series
The harmonic series \sum 1/k diverges, although its terms shrink to zero.
Group the terms in blocks that each add up to at least one half:
The Basel problem
Euler treated \sin \pi x as a polynomial with a root at every whole number, and wrote it as a product (Euler 1740). On the desktop app with a TeX installation, the block below is typeset by LaTeX itself; elsewhere its maths falls back to KaTeX.
Comparing the coefficients of x^2 in the two expansions gives \sum 1/n^2 = \pi^2/6, the theorem at the top of these notes. The bound of 2 from the comparison test was not far off: \pi^2/6 \approx 1.6449.
References
- Euler, L. (1740). De summis serierum reciprocarum. Commentarii academiae scientiarum Petropolitanae, 7, 123-134.
How it's made
- Every command is a rule. No LaTeX is installed for this page to read. A line
\section{…}is a heading,\subsection{…}one level down, and\emph{…}and\textbf{…}style words in a sentence. - Boxes. Each
\begin{theorem}…\end{theorem}pair is a block rule that draws a box. The words in square brackets after it,[Euler, 1734], are a slot that becomesdata-name, and the classnamedputs them in the label. A proof starts with Proof. and ends with ∎ by itself, from the classproof. - Formulas between dollar signs are TeX, drawn by KaTeX. The square of halves is a
tikzblock, and the product formula alatexblock. - Citations.
\cite{euler1740}is a rule too. It finds the record with that key in the hidden data block under References and reads (Euler 1740).\bibliography{refs}lists the works the notes cite, and only those. - The look is
set style numbered, which numbers the sections, and Spectral for the text and headings.
Try it yourself
- In the palette, change
theoremto #c92a2a. Every theorem box turns red, and the definition keeps its teal. - Change
\section{Comparison tests}to\subsection{Comparison tests}. The heading drops a level, and the numbers follow. - Change
\begin{theorem}[comparison test]to\begin{theorem}. The box keeps its colour, and the label says only Theorem. - In the theorem at the top, change
= \frac{\pi^2}{6}to\approx 1.6449. KaTeX redraws the formula as you type. - At the end of the Basel problem, add
Dunham tells the story well \cite{dunham1999}.Dunham's book joins the references.
Next: Research paper numbers its equations and cites its sources; Lab report is a report with data and a chart.
~~~ selfscribe
# Lesson: Write maths notes with LaTeX's commands, defined here as ordinary rules, and real TeX formulas.
# You learn: TeX maths in a line and on its own, a LaTeX block, a TikZ picture, line and inline rules that read backslash commands, environments as block rules, a theorem's name from its [optional argument].
# Try this: change `theorem` in the palette to #c92a2a, and every theorem box turns red.
# Try this: change \section{Comparison tests} to \subsection{Comparison tests}, and the heading drops a level.
# summary: Theorems, proofs and real formulas from LaTeX-style commands you define yourself.
# category: study
# tags: document, advanced, school
# uses: maths, diagram
use markdown
set title Maths notes
# Numbered sections and a bookish face, as LaTeX would set them.
set style numbered
set font Spectral
set heading-font Spectral
# ---- TeX maths: "$x$" in a line and "$$ ... $$" on its own, drawn by KaTeX -------------
inline $_$ -> math verbatim
block $$ ... $$ -> math verbatim
# ---- ```latex and ```tikz blocks: typeset by TeX on the desktop app, or KaTeX elsewhere ---
block ``` latex ... ``` -> latex verbatim
block ``` tikz ... ``` -> tikz verbatim
# ---- Colours, each with its shade for dark pages -------------------------------
palette
theorem #6741d9 dark #b197fc
definition #0c7c7b dark #3cc7c6
# ---- "\title{…}", "\section{…}", "\emph{…}": LaTeX's commands, defined as ordinary rules ----
# A backslash in a pattern is written twice.
line \\title{_} -> header.title { font-family: var(--doc-font-heading); font-size: 2.3em; font-weight: 600; line-height: 1.1; text-align: center; letter-spacing: -0.01em; margin: 0.2em 0 0.25em } as ms-title
line \\author{_} -> div.author { text-align: center; font-variant: small-caps; letter-spacing: 0.08em; opacity: 0.7; margin-bottom: 2.2em } as ms-author
line \\section{_} -> h2 fold 2
line \\subsection{_} -> h3 fold 3
inline \\emph{_} -> em
inline \\textbf{_} -> strong
# ---- "\cite{key}" cites a work, and "\bibliography{refs}" lists the works cited -----------
# The works are records in a hidden data block. The engine writes "(Euler 1740)" and the list.
inline \\cite{_} -> citation
line \\bibliography{_} -> bibliography
block ```data\ _ ... ``` -> data info=_1 verbatim
# ---- "\begin{theorem}[name]" ... "\end{theorem}": environments as block rules ----------------
# Every box shares the class `box`. Each rule sets its colour (--tone) and its word (data-kind);
# the words in square brackets, when there are some, become data-name and join the label.
class box { margin: 1.5em 0; padding: 0.9em 1.3em 0.2em; border-radius: 6px; border-left: 3px solid var(--tone); background: color-mix(in srgb, var(--tone) 8%, transparent) }
class box::before { content: attr(data-kind); display: block; margin-bottom: 0.35em; font: 700 0.72em/1.3 var(--doc-font-ui); letter-spacing: 0.12em; text-transform: uppercase; color: var(--tone) }
class named::before { content: attr(data-kind) " · " attr(data-name) }
block \\begin{theorem}[_] ... \\end{theorem} -> div.box.named data-kind=Theorem data-name=_1 { --tone: var(--theorem) } as ms-theorem-named
block \\begin{theorem} ... \\end{theorem} -> div.box data-kind=Theorem { --tone: var(--theorem) } as ms-theorem
block \\begin{definition}[_] ... \\end{definition} -> div.box.named data-kind=Definition data-name=_1 { --tone: var(--definition) } as ms-definition-named
block \\begin{definition} ... \\end{definition} -> div.box data-kind=Definition { --tone: var(--definition) } as ms-definition
# A proof starts with "Proof." and ends with a square at the right, as LaTeX's does.
block \\begin{proof} ... \\end{proof} -> div.proof { margin: 0.4em 0 1.6em; padding-left: 1.3em; border-left: 1px dashed color-mix(in srgb, currentColor 30%, transparent) } as ms-proof
class proof::before { content: "Proof."; font-style: italic; font-weight: 600 }
class proof::after { content: "∎"; display: block; text-align: right; line-height: 1; opacity: 0.7 }
block \\begin{remark} ... \\end{remark} -> aside.remark { margin: 1.2em 0; font-size: 0.92em; opacity: 0.85 } as ms-remark
class remark::before { content: "Remark. "; font-style: italic; font-weight: 600 }
~~~
\title{Infinite series}
\author{Analysis I · Week 6 · 9 November 2026}
\begin{theorem}[Euler, 1734]
$$
\sum_{k=1}^{\infty} \frac{1}{k^2} \;=\; 1 + \frac{1}{4} + \frac{1}{9} + \frac{1}{16} + \cdots \;=\; \frac{\pi^2}{6}
$$
\end{theorem}
This week ends with Euler's theorem. To get there, we first need to know when a sum of infinitely many terms has a value at all, and how to tell without working the value out.
\section{Geometric series}
\begin{definition}
A series $\sum a_k$ \emph{converges} when its partial sums $S_n = a_1 + \dots + a_n$ approach a limit. The limit is the sum of the series.
\end{definition}
For a real number $r$, the partial sums $S_n = 1 + r + r^2 + \dots + r^{n}$ satisfy $S_n - rS_n = 1 - r^{n+1}$. When $|r| < 1$ the last power shrinks to nothing, so the sums approach a limit. With $r = \tfrac12$ you can see it: each term fills half of what is left of a square.
```tikz
\begin{tikzpicture}[scale=3]
\filldraw[fill=violet!30, draw=violet!70!black] (0,0) rectangle (0.5,1);
\filldraw[fill=violet!22, draw=violet!70!black] (0.5,0.5) rectangle (1,1);
\filldraw[fill=violet!15, draw=violet!70!black] (0.5,0) rectangle (0.75,0.5);
\filldraw[fill=violet!9, draw=violet!70!black] (0.75,0) rectangle (1,0.25);
\draw[violet!70!black] (0,0) rectangle (1,1);
\node at (0.25,0.5) {$\frac12$};
\node at (0.75,0.75) {$\frac14$};
\node at (0.625,0.25) {$\frac18$};
\node[font=\scriptsize] at (0.875,0.125) {$\frac1{16}$};
\end{tikzpicture}
```
\begin{theorem}[geometric series]
If $|r| < 1$, then $\displaystyle\sum_{k=0}^{\infty} r^k = \frac{1}{1-r}$.
\end{theorem}
\begin{proof}
From $S_n = \dfrac{1 - r^{n+1}}{1 - r}$ and $r^{n+1} \to 0$ for $|r| < 1$, the partial sums converge to $\dfrac{1}{1-r}$.
\end{proof}
\section{Comparison tests}
\begin{definition}[absolute convergence]
A series $\sum a_k$ \emph{converges absolutely} when $\sum |a_k|$ converges. Absolute convergence implies convergence, and any rearrangement then has the same sum.
\end{definition}
\begin{theorem}[comparison test]
If $0 \le a_k \le b_k$ for every $k$ and $\sum b_k$ converges, then $\sum a_k$ converges too.
\end{theorem}
The \textbf{comparison test} bounds Euler's series long before we know its value. Each term from the second on is less than a term of a series that telescopes:
$$
\sum_{k=1}^{\infty} \frac{1}{k^2} \;\le\; 1 + \sum_{k=2}^{\infty} \frac{1}{k(k-1)} \;=\; 1 + \sum_{k=2}^{\infty} \left( \frac{1}{k-1} - \frac{1}{k} \right) \;=\; 2
$$
\subsection{The harmonic series}
\begin{theorem}
The harmonic series $\sum 1/k$ diverges, although its terms shrink to zero.
\end{theorem}
\begin{proof}
Group the terms in blocks that each add up to at least one half:
$$
1 + \tfrac12 + \underbrace{\tfrac13 + \tfrac14}_{\ge 1/2} + \underbrace{\tfrac15 + \dots + \tfrac18}_{\ge 1/2} + \dots = \infty
$$
\end{proof}
\begin{remark}
The same grouping shows that the partial sums $H_n$ grow like $\ln n$. More precisely, $H_n - \ln n \to \gamma \approx 0.5772$.
\end{remark}
\section{The Basel problem}
Euler treated $\sin \pi x$ as a polynomial with a root at every whole number, and wrote it as a product \cite{euler1740}. On the desktop app with a TeX installation, the block below is typeset by LaTeX itself; elsewhere its maths falls back to KaTeX.
```latex
\begin{align*}
\frac{\sin \pi x}{\pi x} &= \prod_{n=1}^{\infty} \left(1 - \frac{x^2}{n^2}\right) \\
&= 1 - \left(\sum_{n=1}^{\infty} \frac{1}{n^2}\right) x^2 + O(x^4) \\
\frac{\sin \pi x}{\pi x} &= 1 - \frac{\pi^2}{6} x^2 + O(x^4)
\end{align*}
```
Comparing the coefficients of $x^2$ in the two expansions gives $\sum 1/n^2 = \pi^2/6$, the theorem at the top of these notes. The bound of 2 from the comparison test was not far off: $\pi^2/6 \approx 1.6449$.
\section{References}
```data refs records as hidden
key: euler1740
author: Euler, Leonhard
title: De summis serierum reciprocarum
journal: Commentarii academiae scientiarum Petropolitanae
volume: 7
pages: 123-134
year: 1740
key: dunham1999
author: Dunham, William
title: Euler: The Master of Us All
publisher: Mathematical Association of America
year: 1999
```
\bibliography{refs}
---
\section{How it's made}
- **Every command is a rule.** No LaTeX is installed for this page to read. A line `\section{…}` is a heading, `\subsection{…}` one level down, and `\emph{…}` and `\textbf{…}` style words in a sentence.
- **Boxes.** Each `\begin{theorem}` … `\end{theorem}` pair is a block rule that draws a box. The words in square brackets after it, `[Euler, 1734]`, are a slot that becomes `data-name`, and the class `named` puts them in the label. A proof starts with *Proof.* and ends with ∎ by itself, from the class `proof`.
- **Formulas** between dollar signs are TeX, drawn by KaTeX. The square of halves is a `tikz` block, and the product formula a `latex` block.
- **Citations.** `\cite{euler1740}` is a rule too. It finds the record with that key in the hidden data block under References and reads (Euler 1740). `\bibliography{refs}` lists the works the notes cite, and only those.
- **The look** is `set style numbered`, which numbers the sections, and Spectral for the text and headings.
\section{Try it yourself}
1. In the palette, change `theorem` to #c92a2a. Every theorem box turns red, and the definition keeps its teal.
2. Change `\section{Comparison tests}` to `\subsection{Comparison tests}`. The heading drops a level, and the numbers follow.
3. Change `\begin{theorem}[comparison test]` to `\begin{theorem}`. The box keeps its colour, and the label says only Theorem.
4. In the theorem at the top, change `= \frac{\pi^2}{6}` to `\approx 1.6449`. KaTeX redraws the formula as you type.
5. At the end of the Basel problem, add `Dunham tells the story well \cite{dunham1999}.` Dunham's book joins the references.
Next: *Research paper* numbers its equations and cites its sources; *Lab report* is a report with data and a chart.