From this site

One project, every trade

Each calculator adds its lines to a single estimate — consolidated BOM, schedule and cash-flow included.

Open My Project

Methodology

Numerical Goal Seek by Bisection

How the site inverts any calculator — and why bisection rather than Newton–Raphson is the correct choice here.

Inverting a function you cannot invert algebraically

Every calculator here is a pure function from inputs to a result. Goal seek asks the reverse question: what input produces this result? For most of these functions there is no closed-form inverse, so the answer is found numerically.

Bisection is the method used. Bracket the answer between a low and a high value known to straddle the target, evaluate the midpoint, discard whichever half cannot contain the answer, and repeat. Each iteration halves the interval, so the answer converges at a predictable rate regardless of how badly behaved the function is.

xm=xlo+xhi2,|xhixlo||xhixlo|2k
Each step takes the midpoint, and after k steps the bracket has shrunk by a factor of two to the k.

Why not Newton–Raphson

Newton's method converges far faster — quadratically rather than linearly — and it is the obvious choice for a smooth function. These functions are not smooth.

Almost every material calculator here contains a ceiling function, because you cannot buy part of a box. That makes the output piecewise constant: it steps rather than slopes. Newton's method needs a derivative, and the derivative of a step function is zero almost everywhere and undefined at the steps. It would divide by zero or shoot off to infinity.

Bisection needs no derivative. It needs only that the function moves in a consistent direction across the bracket, which these do. Slower convergence is a price worth paying for a method that cannot fail on the functions it is actually applied to.

Tolerance must be relative

The registry spans results from 0.02 cubic metres to 400,000 kilograms. An absolute tolerance that is sensible for one is meaningless for the other — four decimal places is absurd precision on a mass in tonnes and insufficient on a volume in cubic metres.

The solver therefore converges on relative tolerance, and so do the tests that check it. This was found the hard way: a test asserting an absolute tolerance failed at 17,657.998 against a target of 17,658, where the solver was entirely correct and the assertion was wrong.

Basis

  • Bisection method; guaranteed convergence for any continuous function with a sign change across the bracket.