Package tools.singlevariable
Class Solver
Object
Solver
public class Solver
extends Object
The
Solver class solves for zeros of GeneralFunctions using Newton's method or Halley's method of root finding.-
Method Summary
Modifier and Type Method Description static doublegetSolutionPointNewton(GeneralFunction expression, double initialPoint)Gives an approximate root of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)on the initialPoint for the amount of runs specified inSettings.defaultSolverIterationsstatic doublegetSolutionPointNewton(GeneralFunction expression, double initialPoint, int runs)Gives an approximate root of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)on the initialPoint for a specified amount of runsstatic List<Double>getSolutionsRange(GeneralFunction expression, double lower, double upper)Gives approximate roots of aGeneralFunctionin a range of values using the solver specified inSettings.defaultSolverTypestatic List<Double>getSolutionsRangeHalley(GeneralFunction expression, double lower, double upper)Gives approximate roots of aGeneralFunctionusing Halley's method in a range of values for the amount of runs specified inSettingsstatic List<Double>getSolutionsRangeNewton(GeneralFunction expression, double lower, double upper)Gives approximate roots of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)in a range of values for the amount of runs specified inSettingsstatic List<Double>getSolutionsRangeNewton(GeneralFunction expression, double lower, double upper, int runs)Gives approximate roots of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)in a range of values for a specified amount of runs
-
Method Details
-
getSolutionPointNewton
public static double getSolutionPointNewton(GeneralFunction expression, double initialPoint, int runs)Gives an approximate root of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)on the initialPoint for a specified amount of runs- Parameters:
expression- the function whose root is being foundinitialPoint- initial approximation of the rootruns- the amount of times thatnewtonsMethod(functions.GeneralFunction, double)is iterated- Returns:
- the approximate solution for a root of the function
-
getSolutionPointNewton
Gives an approximate root of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)on the initialPoint for the amount of runs specified inSettings.defaultSolverIterations- Parameters:
expression- the function whose root is being foundinitialPoint- initial approximation of the root- Returns:
- the approximate solution for a root of the function
-
getSolutionsRange
public static List<Double> getSolutionsRange(GeneralFunction expression, double lower, double upper)Gives approximate roots of aGeneralFunctionin a range of values using the solver specified inSettings.defaultSolverType- Parameters:
expression- the function whose roots are being foundlower- the lower bound of the values that will be searchedupper- the upper bound of the values that will be searched- Returns:
- a List of all the approximate roots found
-
getSolutionsRangeNewton
public static List<Double> getSolutionsRangeNewton(GeneralFunction expression, double lower, double upper, int runs)Gives approximate roots of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)in a range of values for a specified amount of runs- Parameters:
expression- the function whose roots are being foundlower- the lower bound of the values that will be searchedupper- the upper bound of the values that will be searchedruns- the amount of times thatnewtonsMethod(functions.GeneralFunction, double)is iterated- Returns:
- a List of all the approximate roots found
-
getSolutionsRangeHalley
public static List<Double> getSolutionsRangeHalley(GeneralFunction expression, double lower, double upper)Gives approximate roots of aGeneralFunctionusing Halley's method in a range of values for the amount of runs specified inSettings- Parameters:
expression- the function whose roots are being foundlower- the lower bound of the values that will be searchedupper- the upper bound of the values that will be searched- Returns:
- a List of all the approximate roots found
-
getSolutionsRangeNewton
public static List<Double> getSolutionsRangeNewton(GeneralFunction expression, double lower, double upper)Gives approximate roots of aGeneralFunctionusingnewtonsMethod(functions.GeneralFunction, double)in a range of values for the amount of runs specified inSettings- Parameters:
expression- the function whose roots are being foundlower- the lower bound of the values that will be searchedupper- the upper bound of the values that will be searched- Returns:
- a List of all the approximate roots found
-