PHYS2150 Chap.10 Scientific Computing and Numerical Methods
Scientific Computing and Numerical Methods
Computation belongs inside a validation loop
Scientific computing in this course connects plotting, curve fitting, root finding, minimisation and MATLAB programming with analytical physics. Begin with a model and a prediction about sign, scale, symmetry or limiting behaviour. Compute a result, visualize relevant structure, and return to an independent check.
A precise number is not evidence when the code represents the wrong equation or the output violates the model’s units. A useful numerical receipt records the method, inputs, starting value, tolerance, iteration limit, termination reason and residual.
These details allow another reader to reproduce the calculation and distinguish algorithmic accuracy from modelling validity.
Plots are arguments, not decoration
A scientific plot needs named axes, units, a domain and a sampling density suited to the behaviour being tested. Too few points can hide oscillation, curvature or a narrow feature; excessive sampling does not repair an unsuitable domain or model.
Distinguish raw observations from fitted curves with markers and lines, and avoid joining samples across a discontinuity. Polar, contour and surface plots require correctly constructed coordinate arrays and element-wise formulas. When contour and surface views represent the same function, their extrema and level locations should agree.
Captions should state what pattern is being checked rather than merely naming the command used.
Iterative roots need convergence evidence
Newton’s method starts from a guess and replaces a differentiable function locally by its tangent line, producing x_{n+1}=x_n-f(x_n)/f′(x_n). A nearby guess with nonzero derivative can converge rapidly, but a poor guess or small derivative may generate an unhelpful step.
The course’s cube-root program monitors relative change between successive estimates, accepts a user tolerance and enforces a maximum iteration count. Report which condition stopped the loop, the number of updates and the original-equation residual.
MATLAB’s fzero offers a built-in route from starting information, but its returned value should still be substituted into the function.
Fits must be judged through residuals
Least squares estimates coefficients within a chosen model family by minimizing squared vertical residuals.
The family should have a mathematical or physical rationale; a polynomial is an approximation over a stated interval, not automatically a mechanism. Plot signed residuals against the independent variable. Random scatter around zero is compatible with the family, whereas curvature, drift, widening spread or an isolated influential point reveals structure that the fit did not explain.
Higher degree always has more flexibility and may lower training error while producing unstable oscillation.
Centering or scaling variables can improve numerical conditioning, but the transformation must be recorded so coefficients and predictions remain interpretable.
Programs should make assumptions inspectable
Separate input, computation and output, use variable names that retain physical meaning, and place reusable calculations in functions with defined arguments and return values.
Build in small changes and test simple cases with known results. For a loop, inspect early iterations, state the stopping condition and include a maximum iteration count. For arrays, check dimensions and distinguish matrix operations from element-wise multiplication, division and powers. When debugging, reduce the failure to the smallest reproducible input and compare one intermediate value with a hand calculation.
Numerical error includes truncation and roundoff, while disagreement with experiment can also reflect data uncertainty or model error. Printing more digits cannot remove those limitations.
What this chapter covers
- 01
Plots with labelled physical axes
- 02
Curve fitting and residuals
- 03
Root finding and convergence tests
- 04
Numerical minimisation
- 05
Scripts, functions and debugging
Worked example · free
Iterate a nonlinear root
- 2Define the function, derivative and starting value.
- 3Apply and record the Newton updates.
- 2Report relative change and residual.
Key terms
- Newton’s Method
- An iterative root-finding method that uses a function and its derivative to replace the current estimate by the tangent-line intercept.
- Truncation Error
- Error introduced when an exact infinite or continuous mathematical process is replaced by a finite number of terms, steps or sampled points.
- Residual
- The difference between an observed or target value and the value predicted by a model, fit or numerical approximation, with a stated sign convention.
- Roundoff Error
- Error caused by representing real numbers with finite precision and propagating those approximations through arithmetic operations.
- Stopping Rule
- A declared condition that ends an iteration, usually paired with a maximum iteration count and a final relative-change or residual check.
Scientific Computing and Numerical Methods FAQ
What makes a scientific plot useful?
Axes need variable names and units, and the displayed domain must expose the behaviour being tested. Sampling should resolve expected curvature or oscillation without joining across discontinuities. Distinguish data from model curves, use a meaningful scale, and write a caption that explains which visible pattern supports or challenges the analytical expectation.
Why inspect residuals after fitting?
Residuals preserve information that a single fit statistic compresses. Curvature, drift or a widening band shows that the chosen family or variance assumption misses structure, even if overall error is small. Random-looking scatter around zero does not prove the model, but it removes one obvious warning and guides comparison with physically plausible alternatives.
What should accompany a numerical answer?
Report the algorithm, data or function, starting value or interval, tolerance, iteration cap, number of iterations, termination reason and final residual or error bound. Include units and an independent sign, scale, limiting or hand-calculated check. Also separate numerical precision from uncertainty in measurements and assumptions in the physical model.
Exam move
Use a prediction-computation-audit worksheet. Before opening MATLAB, write the expected sign, order of magnitude, symmetry and limiting behaviour. For plotting tasks, specify variables, units, domain and sampling needs. For roots or minima, record the starting value or interval, stopping rule and independent residual check.
For fits, graph both data with the fitted family and signed residuals, then state the defensible interpolation domain. Practise scripts through small testable changes, converting reusable calculations into functions with explicit inputs and outputs. When something fails, shrink the example, inspect dimensions and early loop iterations, and compare one intermediate result by hand.
Submit the numerical receipt with every final value rather than relying on software output alone.
Working through Scientific Computing and Numerical Methods in PHYS2150? Sia is AskSia’s AI Physics tutor — ask any PHYS2150 Scientific Computing and Numerical Methods question and get a clear, step-by-step explanation grounded in how PHYS2150 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.