Course · Scientific computingPhase 10 · Study guide

Are you fitting the physical model or the solver’s error?

Domain Specialization · Local CPULaptop CPU4 lessons (~6.8h)

Revision v0.18.1 ·

A simulation has at least three layers of meaning: a model of the physical process, a numerical discretization of that model, and an inference procedure that fits unknown parameters. An exact derivative of the numerical program can still describe an inaccurate approximation to the continuous process. Use a solvable system to separate those layers. Predict one integration step, refine the grid at a fixed horizon and inspect convergence before fitting a parameter. Then compare predictions at held-out times and ask whether a shifted estimate comes from observation noise, weak identifiability or solver error.

Preparation: Math & optimization

Runtime: CPU; target accelerator execution requires separate evidence

Check your starting point

A solver’s output is differentiable. Does that establish that its gradient matches the continuous differential equation?

Compare your reasoning

No. Autodiff follows the implemented discrete steps. Compare a discrete reference and refine the step size toward an analytic or higher-accuracy continuous reference.

If this is unfamiliar, work through Differentiate through a solver before attempting the project.

Build in stages

1. Validate dynamics and axes

Compare one integration step independently, refine the grid and separate independent trajectory axes from dependent time steps.

2. Fit an identifiable inverse problem

Check objective derivatives, choose observations that constrain the unknown parameter and evaluate predictions at held-out times. Separate noise sensitivity from discretization bias.

Try a changed condition

Make a prediction before opening the reasoning. Keep your answer and the evidence you would collect.

Forward Euler solves y′=−yy\prime=-y from 1 to time 1. Compare step sizes 0.5 and 0.25 with the exact exponential.

Compare an approach

Euler gives 0.25 for two half-steps and 0.31640625 for four quarter-steps. The exact value is about 0.36787944. The finer grid reduces this forward error; a correct derivative of either discrete program still need not equal the continuous derivative. Repeat at a fixed horizon and inspect convergence, rather than tuning the fitted parameter to hide solver error.

Diagnose a likely failure

Symptom: The fitted rate changes as the time step is refined.

Check next: Compare solver error and parameter estimates across resolutions before attributing the shift to physical variation.

Decide what is ready

Use scientific-inverse. Keep discrete and continuous references, a refinement study, derivative checks, recovered parameters and a held-out/noise sensitivity report.

Where to put your project code

Write your code in: projects/scientific-inverse/my_model.py (copy projects/scientific-inverse/starter/model.py first: cp projects/scientific-inverse/starter/model.py projects/scientific-inverse/my_model.py).

Verify your implementation: python3 projects/scientific-inverse/tests/check.py --stage all --impl projects/scientific-inverse/my_model.py

Run the staged project checks on your implementation in projects/scientific-inverse/my_model.py and record your transfer experiment results in your portfolio.

Open A differentiable inverse problem

What still needs further work

Adaptive solvers, event handling, stiff systems, PDEs and domain-specific physical validation remain outside the scalar ODE lab.