Class BinarySolverUtil
Utility class providing binary solving methods for one-dimensional functions.
public static class BinarySolverUtil
- Inheritance
-
BinarySolverUtil
- Inherited Members
Methods
CenterSplitionSolve(Func<double, double>, Range<double>, Vec2d, double, double, Func<double, bool>, int)
Efficient center splitting solve that uses an initial point (x0, y0) within the boundary to save one function evaluation. The algorithm intelligently chooses the optimal boundary points based on the initial point position.
public static IEnumerable<BinarySolvingStatus> CenterSplitionSolve(Func<double, double> func, Range<double> xBoundary, Vec2d x0y0, double yTarget, double convergenceLimit, Func<double, bool> isYAcceptableFunc, int maxIteration = 12)
Parameters
funcFunc<double, double>The function to solve
xBoundaryRange<double>Boundary of the search interval. The order of Min and Max is not mattered, i.e. they can be reversed.
x0y0Vec2dInitial x,y value (x0,func(x0))
yTargetdoubleTarget y value to solve for
convergenceLimitdoubleConvergence limit (acceptable error)
isYAcceptableFuncFunc<double, bool>Function to determine if a y value is acceptable
maxIterationintMaximum number of iterations
Returns
- IEnumerable<BinarySolvingStatus>
A sequence of solving status objects showing the progress of the solution
CenterSplitionSolve(Func<double, double>, Range<double>, double, double, double, Func<double, bool>, int)
Solves for a target y-value using the center splitting method with a boundary range and initial x value.
public static IEnumerable<BinarySolvingStatus> CenterSplitionSolve(Func<double, double> func, Range<double> xBoundary, double x0, double yTarget, double convergenceLimit, Func<double, bool> isYAcceptableFunc, int maxIteration = 12)
Parameters
funcFunc<double, double>The function to solve
xBoundaryRange<double>Boundary of the search interval
x0doubleInitial x value (must be within the boundary)
yTargetdoubleTarget y value to solve for
convergenceLimitdoubleConvergence limit (acceptable error)
isYAcceptableFuncFunc<double, bool>Function to determine if a y value is acceptable
maxIterationintMaximum number of iterations
Returns
- IEnumerable<BinarySolvingStatus>
A sequence of solving status objects showing the progress of the solution
CenterSplitionSolve(Func<double, double>, Range<double>, double, double, Func<double, bool>, int)
Solves for a target y-value using the center splitting method with a boundary range.
public static IEnumerable<BinarySolvingStatus> CenterSplitionSolve(Func<double, double> func, Range<double> xBoundary, double yTarget, double convergenceLimit, Func<double, bool> isYAcceptableFunc, int maxIteration = 12)
Parameters
funcFunc<double, double>The function to solve
xBoundaryRange<double>Boundary of the search interval
yTargetdoubleTarget y value to solve for
convergenceLimitdoubleConvergence limit (acceptable error)
isYAcceptableFuncFunc<double, bool>Function to determine if a y value is acceptable
maxIterationintMaximum number of iterations
Returns
- IEnumerable<BinarySolvingStatus>
A sequence of solving status objects showing the progress of the solution
CenterSplitionSolve(Func<double, double>, double, double, double, double, double, Func<double, bool>, int)
Solves for a target y-value using the center splitting method.
public static IEnumerable<BinarySolvingStatus> CenterSplitionSolve(Func<double, double> func, double x0, double y0, double xBoundary, double yTarget, double convergenceLimit, Func<double, bool> isYAcceptableFunc, int maxIteration = 12)
Parameters
funcFunc<double, double>The function to solve
x0doubleInitial x value
y0doubleInitial y value (func(x0))
xBoundarydoubleextended side boundary
yTargetdoubleTarget y value to solve for
convergenceLimitdoubleConvergence limit (acceptable error)
isYAcceptableFuncFunc<double, bool>Function to determine if a y value is acceptable
maxIterationintMaximum number of iterations
Returns
- IEnumerable<BinarySolvingStatus>
A sequence of solving status objects showing the progress of the solution
CenterSplitionSolveWithY1(Func<double, double>, double, double, double, double, double, double, Func<double, bool>, int)
Solves for a target y-value using the center splitting method with a pre-calculated y1 value.
public static IEnumerable<BinarySolvingStatus> CenterSplitionSolveWithY1(Func<double, double> func, double x0, double y0, double x1, double y1, double yTarget, double convergenceLimit, Func<double, bool> isYAcceptableFunc, int maxIteration = 12)
Parameters
funcFunc<double, double>The function to solve
x0doubleInitial x value
y0doubleInitial y value (func(x0))
x1doubleSecond x value
y1doubleSecond y value (func(x1))
yTargetdoubleTarget y value to solve for
convergenceLimitdoubleConvergence limit (acceptable error)
isYAcceptableFuncFunc<double, bool>Function to determine if a y value is acceptable
maxIterationintMaximum number of iterations
Returns
- IEnumerable<BinarySolvingStatus>
A sequence of solving status objects showing the progress of the solution
SlopeSolve(Func<double, double>, double, double, double, double, double, int)
Solves for a target y-value using the slope method.
public static IEnumerable<BinarySolvingStatus> SlopeSolve(Func<double, double> func, double x0, double y0, double x1, double yTarget, double convergenceLimit, int maxIteration = 12)
Parameters
funcFunc<double, double>The function to solve
x0doubleInitial x value
y0doubleInitial y value (func(x0))
x1doubleSecond x value
yTargetdoubleTarget y value to solve for
convergenceLimitdoubleConvergence limit (acceptable error)
maxIterationintMaximum number of iterations
Returns
- IEnumerable<BinarySolvingStatus>
A sequence of solving status objects showing the progress of the solution
SlopeSolveWithY1(Func<double, double>, double, double, double, double, double, double, int)
Solves for a target y-value using the slope method with a pre-calculated y1 value.
public static IEnumerable<BinarySolvingStatus> SlopeSolveWithY1(Func<double, double> func, double x0, double y0, double x1, double y1, double yTarget, double convergenceLimit, int maxIteration = 12)
Parameters
funcFunc<double, double>The function to solve
x0doubleInitial x value
y0doubleInitial y value (func(x0))
x1doubleSecond x value
y1doubleSecond y value (func(x1))
yTargetdoubleTarget y value to solve for
convergenceLimitdoubleConvergence limit (acceptable error)
maxIterationintMaximum number of iterations
Returns
- IEnumerable<BinarySolvingStatus>
A sequence of solving status objects showing the progress of the solution