WebCab Functions for COM v2.0

EquationSolver Class

The Equation Solver class offers a range of procedures for finding the solutions of (continuous) equations on one real variable.

For a list of all members of this type, see EquationSolver Members.

System.Object
   EquationSolver

public class EquationSolver

Remarks

Formally, we find the value of the real variable x, such that ƒ(x) = 0, to a given level of precision.

Overview of the class

Below we describe two important factors which will effects algorithm you choose to use will most likely be effected by the following two factors:

  1. Finding the Bracketing Interval: Each of the algorithms offered (namely Bisection, Secant, Ridders, Brent, Regula-Falsi, Newton-Raphson, and Fail-Safe Newton-Raphson) are offered in two forms. One where the initial bracketing interval must be given and another where the initial bracketing interval is not given by the user. For example algorithm if the bracketing is handled internally then only the desired precision will be required to be passed, whereas in the alternative version the bracketing interval end-points and the maximum number of iterations will also need to be passed. In cases where the bracketing interval cannot be found either by inspection or by the internal algorithms then the Newton-Raphson approach should be applied since it only requires an initial starting point from which a solution will be sort.
  2. Expense the Differentiate: Two algorithms namely Newton-Raphson, and Fail-Safe Newton-Raphson internally differentiate the function being considered. The evaluation of the derivative can be expensive and hence the viability or these two approaches over the others with be determined primarily by this factor.

The function is defined in the Function interface located in the same package. The way to define a function is by implementing the Function interface and defining the GetValueAt method, which should return the value at any point x on the real line.

Detailed Description of the Functionality Provided

The functionality provided within this class uses two basic techniques:

  1. Bracketing the solution: The solution is first bracketed and then this interval in iteratively shrunk (by a variety of procedures) until a solution is found. The algorithms which use this basic technique include: Bisection, Secant, Brent's, Regula-Falsi, Ridders' and Fail-Safe Newton Raphson.
  2. Linear Approximation: Here we find the local linear approximation of the equation and solve the linear case in order to provide a better estimate of the solution. The algorithms which use the technique include: Newton-Raphson and the Fail-Safe Newton-Raphson.

Below we list all the algorithms which are offered within this class:

  1. Bisection Method
    1. Implementations Available
      1. No need to provide a Bracketing Interval: Bisection
      2. Must provide an initial Bracketing interval: Bisection(double, ...)
    2. Summary: The Bisection approach is very stable in terms of the convergence and the speed at which the convergence takes place. However, the Bisection method is often slower than the other algorithms provided.
  2. Secant Method
    1. Implementations Available
      1. No need to provide a Bracketing Interval: Secant
      2. Must provide an initial Bracketing interval: Secant(double, ...)
    2. Summary: When the equation being considered is linear in nature then the Secant method is a very efficient and robust approach to use.
  3. Brent's Method
    1. Implementations Available
      1. No need to provide a Bracketing Interval: Brent
      2. Must provide an initial Bracketing interval: Brent(double, ...)
    2. Summary: A variant of the Secant method which is less efficient but more stable.
  4. Regula-Falsi Method
    1. Implementations Available
      1. No need to provide a Bracketing Interval: RegulaFalsi
      2. Must provide an initial Bracketing interval: RegulaFalsi(double, ...)
    2. Summary: A variant of the Secant method which is less efficient but more stable than the Secant method.
  5. Ridders' Method
    1. Implementations Available
      1. No need to provide an initial Bracketing Interval: Ridders
      2. Must provide an initial Bracketing interval: Ridders(double, ...)
    2. Summary: A powerful variant of the Secant method which in most cases is to be preferred over the Secant approach.
  6. Newton-Raphson Approach
    1. Implementations Available
      1. Starts the search at the origin and uses a maximum of 1,000 iterations: NewtonRaphson
      2. User sets the starting point and the maximum number of iterations: NewtonRaphson(double, ...)
    2. Summary: If the derivative is not particularly expensive to evaluate then the Newton-Raphson approach is generally a very efficient approach. Moreover, it only requires that an initial starting point is provided and hence does not depend on our ability to bracket a solution.
  7. Fail Safe Newton-Raphson Approach
    1. Implementations Available
      1. No need to provide an initial bracketing interval: NewtonRaphsonFailSafe
      2. Must provide an initial Bracketing interval: NewtonRaphsonFailSafe(double, ...)
    2. Summary: If the derivative is not particularly expensive to evaluate then this approach is ideal for those who want almost the speed of the Newton-Raphson approach with the security of convergence of the Bisection approach.

Using this class

By following the below steps you will be able to set the equation ƒ(x), which you wish to solve and then select the algorithm which will return a solution:

  1. Setting the Equation to be solved by calling SetFunction
  2. Calling one of the equation solve algorithms to find a solution of the set equation.

For further details on exact how the equation is set we refer the reader to the documentation of SetFunction. In the following discussion we consider the differences between the different algorithms which are offer and provide advice to the user for the select for an appropriate algorithm.

Requirements

Namespace: WebCab.COM.Math.EquationSolver

Assembly: WebCab.COM.Functions (in WebCab.COM.Functions.dll)

See Also

EquationSolver Members | WebCab.COM.Math.EquationSolver Namespace