Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Writing an entry

This page records the conventions used throughout the book, for contributors and for future chapters.

Outline

Every entry uses the outline described in How to read an entry:

# Algorithm name

<div class="entry-summary">

| | |
|---|---|
| **Problem** | ... |
| **Devised by** | Who, when |
| **Accuracy** | Convergence rate or error bound |
| **Cost** | Operations, evaluations, memory |
| **Read first** | Links to the entries or background sections this one builds on (at most three) |
| **API** | Links into ../../api/... |

</div>

## Overview
## Where it is used
## History
## The idea
## Algorithm
## Implementation
## In practice
## Exercises
## Further reading

Writing for students

The reader is an advanced undergraduate meeting the algorithm for the first time. Accuracy is not enough: the entry must be something they can learn from. The conventions below came out of feedback from early readers, who found compressed derivations hard to follow.

  • Figures and tables are numbered automatically. After adding one, run python3 book/tools/captions.py from book/src: figures get “Figure C.k” below them (the image’s alt text is the caption, so make it a descriptive phrase) and generated tables get “Table C.k” above them with a placeholder listing the columns, which you should replace by a short title saying what the table shows. Refer to them by number, and say what to look for rather than only “the figure above”.
  • Keep the library’s history out of the text. Do not write “an earlier version did…”, “this chapter fixed…”. Put the record of a fixed defect in CHANGELOG.md. If the mistake is one that anyone coding the method could make, state it as a pitfall in the present tense (“a partition that sends equal keys to one side takes quadratic time”) and, where it fits, make it an exercise.
  • Say where it is used. Every entry has a “Where it is used” section after the Overview: a one-sentence framing and three to five bullets, each naming a concrete application (a device, a standard, a field, a kind of analysis) and what the method does there. Name only uses that are well established, and link to the other entries of the book that the application involves. Do not write a list of buzzwords: an undergraduate should be able to picture the problem.
  • Motivate before defining. Open each part of “The idea” with the question it answers or the difficulty it removes, in a sentence or two, before any formula.
  • Define every term at first use, in bold, in the entry where it is used. If the full treatment is elsewhere, give a one-clause definition and a link. Do not rely on the reader having read another entry.
  • Show the intermediate steps. Do not write “it follows that” across a gap that takes more than one line of algebra. Say what is being substituted into what, and what cancels. Label the stages of a longer argument (Step 1, Why it works, The catch).
  • Say what a formula means in words after stating it: what each term does, and what happens in the limiting cases.
  • Give one small worked example with actual numbers for each central idea (a system, three data points, a four-symbol alphabet). Check the numbers by running them.
  • One idea per sentence. Prefer two short sentences to one joined by a semicolon or a colon. Use a list when a paragraph enumerates cases or properties, and numbered steps for a procedure.
  • Explain numerical hazards by their mechanism (which digits cancel, which error is amplified), not only by their name.
  • Connect to what the reader already knows: link to the earlier entry that uses the same idea, and say that it is the same idea.

Mathematics

Write LaTeX between $...$ for inline maths and $$...$$ for displayed equations. It is rendered at build time by KaTeX, so no escaping is needed. State theorems as block quotes, and end proofs with .

Code excerpts

Never paste library code into the book: include it from the source, so the book cannot drift from the code. Mark the region in the Rust source:

// ANCHOR: my_region
...
// ANCHOR_END: my_region

and include it with {{#include path/to/file.rs:my_region}}. Complete programs live in the crate’s examples/ directory, where cargo build --examples compiles them, and are included whole.

Figures and tables

Figures and tables are generated by running the library, so every number in the book is one the code computes. The generator is the workspace crate book/generator; add a function for the new chapter and run

cargo run --release -p lib_jsl_book_generator

from the repository root. It writes SVG figures and Markdown tables to book/src/generated/, which pages include with ![caption](../generated/chapter/name.svg) and {{#include ../generated/chapter/name.md}}.

The book is published at /lib_jsl/book/ and the API reference at /lib_jsl/api/ on the same site, so pages link to API items with relative paths such as ../../api/lib_jsl_integration/romberg/struct.RombergEngine.html. The crate documentation links back to the corresponding book chapter.

Building the site locally

book/build-site.sh          # generator, book and API reference into target/site/
python3 -m http.server -d target/site 8000

then open http://localhost:8000/.