MorphIQ Labs

MorphIQ Labs ·

The Boundary Is Part of the Algorithm

A numerical method needs a justified domain. The threshold that selects it deserves the same scrutiny as the formula itself.

Numerical software often uses several methods to evaluate the same quantity. A series expansion works well in one region. Another formulation handles the tails. A third avoids cancellation near a limiting case.

The formulas receive considerable attention. The constants that choose between them can receive much less.

Yet a threshold makes a mathematical claim: this method remains suitable on this side of the boundary. That claim depends on approximation error, floating-point behavior, and the accuracy required by the caller.

At MorphIQ Labs, we treat those boundaries as part of the numerical method.

A case from implied volatility

During a review of MorphIQ Risk’s implied-volatility calculation, we examined a constant that selected between evaluation paths. Comparison against an independent high-precision reference showed that the selected series expansion was being used beyond the region where it delivered the required accuracy.

The existing test corpus had not exposed the problem. Targeted comparisons around the transition did.

That distinction matters. Coverage established that the code ran. The missing evidence concerned whether the selected method was appropriate for those inputs.

The investigation therefore needed to evaluate both candidate paths against the reference, including inputs on either side of the switch.

Establish the reference first

A high-precision calculation is useful only if its formulation is suitable for the region being tested.

For example, evaluating a very small normal-tail probability by subtracting nearly equal quantities can lose significant digits. Increasing precision may help, but it does not remove the need to examine cancellation and numerical conditioning. A formulation based on the complementary error function can avoid that subtraction.

The reference itself needs checks: agreement as precision increases, comparison with another formulation where practical, and deliberate examination of extreme inputs.

Independence also requires more than choosing another programming language. Reimplementing the same approximation can reproduce the same error.

Measure the transition

Once the reference is credible, compare the candidate methods across the region where the implementation changes behavior.

The useful questions are specific:

  • Where does each method satisfy the required error budget?
  • What happens immediately before and after the switching point?
  • How sensitive is the result to nearby inputs?
  • What computational cost accompanies each valid choice?

This produces a defensible basis for selecting the threshold. Accuracy requirements determine which methods are acceptable; performance measurements help choose among them.

A measured sweep establishes behavior for the cases examined. A mathematical bound can establish a broader domain. The evidence should state which kind of conclusion it supports.

Make the result reproducible

The investigation should leave more than a revised constant.

A threshold needs a recorded criterion, a reference calculation, and regression cases that exercise the transition. Those cases should distinguish the corrected behavior from the original behavior.

The evidence also needs its context: the implementation revision, input domain, precision, error metric, and commands required to reproduce the comparison.

This gives future maintainers something concrete to evaluate when an approximation changes, a vectorized path is introduced, or a performance optimization moves a boundary. They can revisit the numerical decision against its original requirements—and update the evidence alongside the code.