freegraph
Class EquationSolver

java.lang.Object
  |
  +--freegraph.EquationSolver

public class EquationSolver
extends java.lang.Object

class with static functions to find solutions to equations using either Newton's Method or Bisection techniques.


Constructor Summary
EquationSolver()
           
 
Method Summary
static double bisection(ExpressionEvaluator expr1, ExpressionEvaluator expr2, double low, double high, double tolerance, char solveFor)
          attempts to solve the equation expr1=exrp2 using bisection looking between low and high
static void main(java.lang.String[] args)
           
static double newton(ExpressionEvaluator expr1, ExpressionEvaluator expr2, double value, double tolerance, double slopeLimit, char solveFor)
          attempts to zero in on a solution using Newtons equation solving technique.
static double repeatBisection(ExpressionEvaluator expr1, ExpressionEvaluator expr2, double low, double high, double tolerance, char solveFor)
          attempts to solve the equation expr1=exrp2 using bisection repeatedly by moving trying various starting points.
static double repeatNewton(ExpressionEvaluator expr1, ExpressionEvaluator expr2, double value, double tolerance, double slopeLimit, char solveFor)
          attempts to solve the equation expr1=exrp2 using Newton's method and repeatedly moving to different starting points looking for an answer.
static double xintercept(ExpressionEvaluator expr1, ExpressionEvaluator expr2, double value, double tolerance, double slopeLimit, char solveFor)
          returns the X-Intercept of the tangent to the equation expr1=expr2 at value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EquationSolver

public EquationSolver()
Method Detail

repeatNewton

public static double repeatNewton(ExpressionEvaluator expr1,
                                  ExpressionEvaluator expr2,
                                  double value,
                                  double tolerance,
                                  double slopeLimit,
                                  char solveFor)
                           throws NoSolutionException
attempts to solve the equation expr1=exrp2 using Newton's method and repeatedly moving to different starting points looking for an answer.

Parameters:
expr1 - the left side of the equation.
expr2 - the rigth side of the equation.
value - the x value.
tolerance - the tolerance of the solution (how close to the actual answer must the result be)
slopeLimit - the difference in x values used in estimating the slope of the line
Returns:
a solution to the equation expr1=expr2.
Throws:
NoSolutionException - if no solution can be found

newton

public static double newton(ExpressionEvaluator expr1,
                            ExpressionEvaluator expr2,
                            double value,
                            double tolerance,
                            double slopeLimit,
                            char solveFor)
                     throws NoSolutionException
attempts to zero in on a solution using Newtons equation solving technique.

Parameters:
expr1 - the left side of the equation.
expr2 - the rigth side of the equation.
value - the x value.
tolerance - the tolerance of the solution (how close to the actual answer must the result be)
slopeLimit - the difference in x values used in estimating the slope of the line
Returns:
a solution to the equation expr1=expr2.
Throws:
NoSolutionException - if no solution can be found

repeatBisection

public static double repeatBisection(ExpressionEvaluator expr1,
                                     ExpressionEvaluator expr2,
                                     double low,
                                     double high,
                                     double tolerance,
                                     char solveFor)
                              throws NoSolutionException
attempts to solve the equation expr1=exrp2 using bisection repeatedly by moving trying various starting points.

Parameters:
expr1 - the left side of the equation.
expr2 - the rigth side of the equation.
low - the low value to start in the bisection
high - the high value to start in the bisection
tolerance - the tolerance of the solution (how close to the actual answer must the result be)
Returns:
a solution to the equation expr1=expr2.
Throws:
NoSolutionException - if no solution can be found

bisection

public static double bisection(ExpressionEvaluator expr1,
                               ExpressionEvaluator expr2,
                               double low,
                               double high,
                               double tolerance,
                               char solveFor)
                        throws NoSolutionException
attempts to solve the equation expr1=exrp2 using bisection looking between low and high

Parameters:
expr1 - the left side of the equation.
expr2 - the rigth side of the equation.
low - the low value to start in the bisection
high - the high value to start in the bisection
tolerance - the tolerance of the solution (how close to the actual answer must the result be)
Returns:
a solution to the equation expr1=expr2.
Throws:
NoSolutionException - if no solution can be found

xintercept

public static double xintercept(ExpressionEvaluator expr1,
                                ExpressionEvaluator expr2,
                                double value,
                                double tolerance,
                                double slopeLimit,
                                char solveFor)
                         throws freegraph.EquationSolver.SolutionFound
returns the X-Intercept of the tangent to the equation expr1=expr2 at value. (This method is used by the Newtonian solving methods)

Parameters:
expr1 - the left side of the equation.
expr2 - the rigth side of the equation.
tolerance - the tolerance of the solution (how close to the actual answer must the result be)
slopeLimit - the difference in x values used in estimating the slope of the line
Returns:
the xintercept
Throws:
SolutionFound - is the xintercept is a solution to the equation expr1=expr2 within tolerance.
freegraph.EquationSolver.SolutionFound

main

public static void main(java.lang.String[] args)