Module math

Class Newton

java.lang.Object
de.grogra.math.Newton

public class Newton extends Object
This class contains some numeric algorithms based on the Newton algorithm.
Author:
Ole Kniemeyer
  • Constructor Details

    • Newton

      public Newton()
  • Method Details

    • findRoot

      public static void findRoot(ObjectToObject<double[],double[]> function, double[] x, double[] prec, int maxSteps, double[] eps, double relax)
      Finds a root of function. Starting at x, the derivative of function is approximated by difference quotients (using eps as delta) to compute a new x according to Newton's method, using relax as factor which reduces the x-movement computed by Newton's method. If the movement is less than prec in all dimensions, this method returns normally. Otherwise, after maxSteps an ArithmeticException is thrown.

      All arrays have to be of the same length.

      Parameters:
      function - the function
      x - the start value and (after method invocation completes normally) the final value
      prec - the precision to achieve
      maxSteps - maximal number of iterations
      eps - the delta to approximate differential quotients
      relax - relaxation factor for step
    • findExtremum

      public static void findExtremum(ObjectToDouble<double[]> function, double[] x, double[] prec, int maxSteps, double[] eps, double relax)
      Finds a local extremum by looking for a root of an approximation of the derivative of function. The approximation is obtained by difference quotients, the delta being given by eps.
      Parameters:
      function - the function
      x - the start value and (after method invocation completes normally) the final value
      prec - the precision to achieve
      maxSteps - maximal number of iterations
      eps - the delta to approximate differential quotients
      relax - relaxation factor for step
      See Also:
    • fit

      public static void fit(ObjectToDouble<double[][]> function, DataTable data, double[] params, double[] prec, int maxSteps, double[] eps, double relax)
      Fits function to data. function gets an array as input whose first component contains the x-vector and whose second component contains the parameter vector. data contains for each row a data set consisting of the x-vector and (as last entry) the function value.
      Parameters:
      function - the function
      data - the data table
      params - the start value for the parameter vector and (after method invocation completes normally) the final value
      prec - the precision to achieve
      maxSteps - maximal number of iterations
      eps - the delta to approximate differential quotients
      relax - relaxation factor for step
      See Also:
    • fit

      public static void fit(ObjectToDouble<double[][]> function, DataTable data, double[] params, double[] prec)
    • fitParameters

      public static void fitParameters(ObjectToDouble<double[]> function, DataTable data, double[] params, double[] prec, int maxSteps, double[] eps, double relax)
    • fitParameters

      public static void fitParameters(ObjectToDouble<double[]> function, DataTable data, double[] params, double[] prec)
    • toDataTable

      public static DataTable toDataTable(Dataset set)