Foundations to FrontierReferences and toolsBezhig

Companion workflow and compact engineering references

On this page
  1. The companion code and website
  2. Start without looking at the solution
  3. What to install
  4. Core equations and conditions
  5. A five-part debugging record
  6. Progress tracker and evidence levels

The companion code and website#

The companion website, bezhig.com/book, holds the code for every lab, the interactive explorers that accompany the frontier tracks, and any corrections to this edition. The code is grouped by part of the book: code/ for the labs and projects of the computing, applied-mathematics, and project chapters (the C, A, T, and J chapters), integration_code/ for the connecting workshops, graduate_code/ for the graduate core and its capstone projects, and frontier_code/ for the labs of F01 and F19. The frontier tracks name their own lab folders in their chapters. A lab path in the text, such as starters/search_lab.py, is relative to its folder, and each folder’s README gives its exact commands.

Start without looking at the solution#

Inside each code folder, starters/ holds the files you edit and tests/ the executable specification. The complete reference implementations that this book prints in its solution sections are in solutions/, and cpp/ holds the C++ references. The code/ folder also has fixtures/ with small input files, gpu/ with the optional CUDA source, and verification/ with the recorded test environment and benchmark results. Python starter functions preserve interfaces and docstrings but deliberately raise NotImplementedError. That failure is expected until you implement them. The reference suite’s passing status does not mean starter exercises are already solved.

Attempt each lab before you read its solution: write your version, run the tests against it, and only then compare it with the solution printed in the chapter. Note the first step where the two differ, not just whether the tests now pass.

Use a copy of the starter tree for independent work. Tests select Python implementations using the MANUAL_IMPL environment variable; the default is solutions. In a POSIX shell, MANUAL_IMPL=starters python -m unittest discover -s tests -v runs against the starter package. In PowerShell, set $env:MANUAL_IMPL="starters", run the tests, then remove that environment variable to restore the reference default. Running the full starter suite initially produces many failures; select the relevant test class while working on one lab, as documented in the README.

In code/, the C++ starter headers live under starters/cpp. Configure a separate build directory with the CMake option

-DMANUAL_CPP_DIR=starters/cpp

to use them in test targets. CMake’s compiler-specific configuration still matters. Do not overwrite the reference implementation and then lose the ability to compare against the original. The optional CUDA file is not required for the tested CPU route.

What to install#

The core labs need Python 3.13 and, for the C++ labs, a C++20 compiler with CMake. The Python labs use only the standard library. The labs in code/, integration_code/, and graduate_code/ were tested on Linux x86-64 with Python 3.13.5, SQLite 3.46.1 (through Python’s standard library), GCC 14.2.0, and CMake 3.31.6. The README in code/ records these versions and the build commands; they are not claimed to be the newest available releases.

On Windows, use an installed Python interpreter and a C++20-capable compiler with CMake, or use WSL as a Linux environment. The README includes PowerShell and multi-configuration generator notes; those Windows and macOS instructions were not part of the tested runs. Package installation and compiler setup can change; use official documentation for your chosen supported versions. No paid cloud service is needed. The frontier tracks need more, such as a GPU and PyTorch for the AI Lab and CAD and simulation software for the Engineering Lab; their route chapters list those tools and the dates their versions were checked.

Core equations and conditions#

ObjectMeaning and condition to remember
Lower boundSmallest index ii with ai≥ta_i\ge t, or nn; requires sorted input under the same ordering.
DijkstraNonnegative edge costs; tentative discovery is not final settlement; validate graph representation.
Amortized appendA linear total cost over a sequence can coexist with an individual linear-time resize.
Gradient stepw←w−α∇Jw\gets w-\alpha\nabla J; step size, conditioning, and objective assumptions matter.
Least squaresMinimize ∥Ax−b∥2\|Ax-b\|_2; QR avoids explicitly forming ATAA^TA and its squared condition number.
Conditional probabilityP(A∣B)=P(A∩B)/P(B)P(A\mid B)=P(A\cap B)/P(B) when P(B)>0P(B)>0; conditioning is not causation.
Numerical errorDistinguish model, discretization, and roundoff error; smaller steps do not fix a wrong model.
Retry identitySame logical key and payload, effect and result committed together, retention policy explicit.
Concurrent ownershipName every writer, every shared object’s lifetime, and the synchronization establishing visibility.
Benchmark claimState workload, environment, build, timing boundary, repetitions, validation, and limits.

A five-part debugging record#

Write the expected behavior and the smallest reproducing input. Record the first observed state that contradicts the contract. State one hypothesis and the observation that would refute it. Save the correction and a test that fails on the old version. Finally explain the root cause in terms of state, assumptions, or representation rather than saying only “the test now passes.”

For mathematics, use the same structure: original problem and domain; first incorrect algebraic or conceptual step; the rule that justifies a correction; substitution or differentiation check; interpretation of the answer. A sign error and a wrong method choice need different repairs even when they lead to the same wrong number.

Progress tracker and evidence levels#

Keep two small records while you study. A progress tracker is a spreadsheet or CSV file with one row for each instructional or project module and columns for the date, unaided attempts, hint level, first error, verification performed, explanation gap, next review date, and a fresh-transfer result. An error log has one row per mistake: the date, the exercise, its category (notation or syntax, concept, method choice, algebra, proof assumption, program state, test coverage, interpretation, or performance reasoning), the first incorrect step, the corrected rule, and the next review date. Both start empty; they record your own work, so fill them in from your attempts, never from the solutions.

Mark exposure when you can recognize a concept. Mark guided competence when you can complete a standard task with a limited prompt. Mark independent operational competence only after fresh unaided work, explanation, verification, and a changed-context task. Advanced specialization requires sustained depth on substantial work. Research-level contribution requires new knowledge or methods evaluated against the relevant literature and evidence standards. Do not promote a checkbox simply because the reference solution feels familiar.