Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Part I Recap — Trustworthy Scientific Programming

Scientific Computing with Python

Your code is a scientific instrument

Scientific code mediates between a model, data, and a conclusion. A calculation that runs is therefore not enough: another reader must be able to identify its environment, numerical assumptions, algorithmic decisions, and interpretation. Part I supplies the first tools for that work.

A return route, not another chapter

Use this page after a first pass through Chapters 1–6, or return when a result is difficult to trust. It does not introduce a second set of techniques to memorize. Instead, it helps you identify the first assumption worth inspecting: the environment, the numerical representation, the control logic, the data representation, the function contract, or the boundary around shared state.

Six chapters, one architecture

ChapterWhat it helps you establish
1. Environmentswhich code and dependencies actually ran
2. Numerical realitywhich numerical comparisons and representations are defensible
3. Control flowwhat decisions and termination conditions define the algorithm
4. Data structureshow data is organized and accessed
5. Functions and moduleswhat a reusable calculation promises
6. Small scientific objectswhen state and behavior should be protected together

Diagnostic and transfer guide

SymptomLikely causeNext checkRelevant chapter
The same code behaves differently elsewheredifferent interpreter, package, path, or hidden staterecord sys.executable, versions, and a clean rerun1
Two nearly identical values compare unequalfinite floating-point representationchoose a claim-appropriate absolute and relative tolerance2
A calculation never finishesmissing progress condition or unbounded loopstate the invariant, tolerance, and maximum iteration count3
A once-small task becomes slowdata structure does not match the access patterncount operations and inspect lookup/mutation behavior4
A result cannot explain its assumptionsan unclear or oversized function contractname inputs, units, output, validity range, and failures5
Related values drift out of agreementno explicit invariant around shared stateconsider a small validated object—or a simpler function/data pair6

Transfer prompt

Choose one computation from your own discipline. Before changing its algorithm, write a short instrument record: interpreter and package versions, input units, one limiting case, the stopping rule if it iterates, and the observable that would count as evidence against its result. This record should make sense to a reader outside the original domain.

Recap and next connection

Part I is not a checklist to finish once. Return when a computation is hard to trust, then use the relevant chapter as a diagnostic reference. Next, continue to Part II: Arrays, Visualization, and Reliable Computing, where these habits become tools for inspecting arrays, figures, numerical behavior, and small scientific types. Part II assumes these foundations; it does not replace the environment, numerical, or contract checks established here.