recommendScalingFactor

fun recommendScalingFactor(func: FunctionIfc, interval: Interval, initialPt: Double, delta: Double): Double(source)

Recommends a scaleFactor by fitting a linear approximation to func near initialPt over a +/-delta neighbourhood.

factor = min(1/|f(initialPt)|, 1/|slope|)

Clamped to 1.0, DEFAULT_SCALE_FACTOR. Floored to 1.0 if the computed value falls below DEFAULT_SCALE_FACTOR * DEFAULT_PRECISION.

This is a heuristic. Verify convergence and adjust manually if needed.

Return

Recommended scale factor in 1.0, DEFAULT_SCALE_FACTOR.

Parameters

func

Function being searched.

interval

Used to clamp the evaluation neighbourhood to the valid domain.

initialPt

Point around which the approximation is made. Must be in interval.

delta

Neighbourhood half-width. Must be > 0.