A scalar MATLAB solver accepts a candidate only when both its absolute displacement step and its absolute force residual meet their tolerances. At iteration 4 of a maximum of 20 iterations, its variables are:
x = 0.24985; % m, previous estimate xNew = 0.25000; % m, candidate estimate rOld = 0.040; % N, residual at x rNew = -0.080; % N, residual at xNew step = abs(xNew - x); tolX = 0.00020; % m tolF = 0.050; % N
Which expression correctly sets the logical variable converged according to this requirement?
converged = step <= tolX && abs(rNew) <= tolF;
converged = step <= tolX || abs(rNew) <= tolF;
converged = step <= tolX && abs(rOld) <= tolF;
converged = step <= tolX && rNew <= tolF;
Unlock full course notes by signing up
Tracing a Bisection Calibration
An engineering calibration requires the positive, dimensionless gain ggg satisfying
A MATLAB implementation uses bisection, which repeatedly halves an interval while retaining endpoints with opposite function signs. Its initial bracket is [1,2][1,2][1,2].
When a Small Residual Hides a Large Error
A displacement calibration calculation for a very soft spring uses the exact linear residual model
where xxx is in metres. A numerical solver returns an estimate x^\hat{x}x^ with signed residual f(x^)=+0.000100 Nf(\hat{x})=+0.000100\ \text{N}f(x^)=+0.000100 N. This passes its residual tolerance of 0.000150 N0.000150\ \text{N}0.000150 N.
Repairing a Length-Unit Mismatch
A nonlinear spring calculation solves
A programmer stores extension as u in millimetres, with x=u/1000x=u/1000x=u/1000 when numerical values are used. The residual calculation below correctly returns newtons, but the update mixes length units:
Using Step Refinement to Control Integration Error
A MATLAB program integrates a smooth power signal over a fixed time interval to estimate transferred energy. The program uses the composite trapezoidal rule with uniform time step hhh.
Two runs give E(0.4 s)=12.8 JE(0.4\ \text{s})=12.8\ \text{J}E(0.4 s)=12.8 J and E(0.2 s)=12.2 JE(0.2\ \text{s})=12.2\ \text{J}E(0.2 s)=12.2 J. For this calculation, assume the following error model is exact over the step sizes considered: