Function to be analyzed. If f(ax) and f(bx) have opposite signs one root is returned, otherwise the implementation tries to find a local minimum and returns two roots. At least one of f(ax) and f(bx) should be greater or equal to zero.
Defines an early termination condition. Receives the current upper and lower bounds on the root. The delegate must return true when these bounds are acceptable. If this function always returns false or it is null, full machine precision will be achieved.
Left inner bound of initial range of f known to contain the roots.
Right inner bound of initial range of f known to contain the roots. Can be equal to ax.
Value of f(ax) (optional).
Value of f(bx) (optional).
Relative tolerance used by findLocalMin.
Absolute tolerance used by findLocalMin.
Appr. maximum allowed number of function calls for each findRoot call.
Smile
import mir.math.common: approxEqual; auto result = findSmileRoots!(x => x ^^ 2 - 1)(-10.0, 10.0); assert(result.roots.length == 2); assert(result.roots[0].approxEqual(-1)); assert(result.roots[1].approxEqual(+1)); assert(result.smileRoots.left.approxEqual(-1)); assert(result.smileRoots.right.approxEqual(+1)); assert(result.leftResult); assert(result.rightResult); assert(result.localMinResult); assert(result.localMinResult.get.x.approxEqual(0)); assert(result.localMinResult.get.y.approxEqual(-1));
Skew
import mir.math.common: approxEqual; auto result = findSmileRoots!(x => x ^^ 2 - 1)(0.5, 10.0); assert(result.roots.length == 1); assert(result.roots[0].approxEqual(+1)); assert(result.smileRoots.left.approxEqual(+1)); assert(result.smileRoots.right.approxEqual(+1)); assert(!result.leftResult); assert(result.rightResult);
Find one or two roots of a real function f(x) using combination of FindRoot and FindLocalMin.