Class Solvers

java.lang.Object
org.jhotdraw8.geom.Solvers

public class Solvers extends Object
Provides algorithms for computing the inverse of a function.
  • Method Details

    • polynomialApprox3

      public static OrderedPair<ToDoubleFunction<Double>,Double> polynomialApprox3(Function3<ToDoubleFunction<Double>,Double,Double,Double> quadratureFunction, ToDoubleFunction<Double> fp, double xmin, double xmax)
      Returns a function y(x) that maps the parameter x [xmin,xmax] to the integral of fp. For a circle tmin and tmax would be 0 and 2PI respectively for example. It also returns the total length of the curve.

      Implemented using M. Walter, A. Fournier, Approximate Arc Length Parametrization, Anais do IX SIBGRAPHI, p. 143--150, 1996, see visgraf.impa.br.

      References:

      Canvas. Copyright (c) 2015 Taco de Wolff, MIT License.
      github.com
    • invPolynomialApprox3

      public static OrderedPair<ToDoubleFunction<Double>,Double> invPolynomialApprox3(Function3<ToDoubleFunction<Double>,Double,Double,Double> quadratureFunction, ToDoubleFunction<Double> fp, double xmin, double xmax)
      invPolynomialApprox does the opposite of polynomialApprox3(org.jhotdraw8.base.function.Function3<java.util.function.ToDoubleFunction<java.lang.Double>, java.lang.Double, java.lang.Double, java.lang.Double>, java.util.function.ToDoubleFunction<java.lang.Double>, double, double), it returns a function x(y) that maps the parameter y [f(xmin),f(xmax)] to x [xmin,xmax].

      References:

      Canvas. Copyright (c) 2015 Taco de Wolff, MIT License.
      github.com
    • bisectionMethod

      public static double bisectionMethod(ToDoubleFunction<Double> f, double y, double xmin, double xmax, double tolerance)
      Find value x for which f(x) = y in the interval x in [xmin, xmax] using the bisection method.

      References:

      Canvas. Copyright (c) 2015 Taco de Wolff, MIT License.
      github.com
      Parameters:
      f - a function that grows monotonically
      y - the desired y value
      xmin - the start of the interval
      xmax - the end of the interval
      tolerance -
      Returns:
      x the estimated x value
    • hybridNewtonBisectionMethod

      public static double hybridNewtonBisectionMethod(Function3<ToDoubleFunction<Double>,Double,Double,Double> quadratureFunction, ToDoubleFunction<Double> f, double y, double xmin, double xmax, double x0, double epsilon)
      Find value x for which ∫f(x) = y in the interval x in [xmin, xmax] using a hybrid of Newton's method and the bisection method.

      We perform iterations using the Newton’s method until the error of the solution becomes acceptable, or the number of iterations performed becomes unacceptably large.

      There is a potential problem when using only Newton’s method. If the function is said to be convex, the Newton iterations are guaranteed to converge to the root. However, if the function is non-convex, the Newton iterations may converge outside the domain x∈[xmin,xmax]. In such a case, we use the bisection method instead.

      References:

      Movement along the curve with constant speed. Copyright (c) 2021 Alexey Karamyshev.
      medium.com
      Parameters:
      quadratureFunction - the function for computing the integral of f
      f - a function
      y - the desired y value
      xmin - the start of the interval
      xmax - the end of the interval
      x0 - the initial approximation
      epsilon - the tolerance
      Returns:
      x the estimated x value
    • hybridNewtonBisectionMethod

      public static double hybridNewtonBisectionMethod(ToDoubleFunction<Double> f, ToDoubleFunction<Double> df, double y, double xmin, double xmax, double x0, double epsilon)
      Find value x for which f(x) = y in the interval x in [xmin, xmax] using a hybrid of Newton's method and the bisection method.

      We perform iterations using the Newton’s method until the error of the solution becomes acceptable, or the number of iterations performed becomes unacceptably large.

      There is a potential problem when using only Newton’s method. If the function is said to be convex, the Newton iterations are guaranteed to converge to the root. However, if the function is non-convex, the Newton iterations may converge outside the domain x∈[xmin,xmax]. In such a case, we use the bisection method instead.

      References:

      Movement along the curve with constant speed. Copyright (c) 2021 Alexey Karamyshev.
      medium.com
      Parameters:
      f - a function
      df - the derivative of the function
      y - the desired y value
      xmin - the start of the interval
      xmax - the end of the interval
      x0 - the initial approximation
      epsilon - the tolerance
      Returns:
      x the estimated x value
    • invPolynomialChebyshevApprox

      public static SimpleOrderedPair<ToDoubleFunction<Double>,Double> invPolynomialChebyshevApprox(int N, Function3<ToDoubleFunction<Double>,Double,Double,Double> quadratureFunction, ToDoubleFunction<Double> fp, double tmin, double tmax)
      Creates a function that computes time t given an arc length s.

      References:

      Canvas. Copyright (c) 2015 Taco de Wolff, MIT License.
      github.com
      Parameters:
      N -
      quadratureFunction -
      fp -
      tmin -
      tmax -
      Returns:
    • polynomialChebyshevApprox

      public static ToDoubleFunction<Double> polynomialChebyshevApprox(int N, ToDoubleFunction<Double> f, double xmin, double xmax, double ymin, double ymax)
      Creates an approximation of the provided function using a Chebyshev polynomial of degree N.

      References:

      Canvas. Copyright (c) 2015 Taco de Wolff, MIT License.
      github.com