-
Method Summary
Modifier and TypeMethodDescriptionstatic doublebisectionMethod(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.static doublehybridNewtonBisectionMethod(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.static doublehybridNewtonBisectionMethod(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.static OrderedPair<ToDoubleFunction<Double>, Double> invPolynomialApprox3(Function3<ToDoubleFunction<Double>, Double, Double, Double> quadratureFunction, ToDoubleFunction<Double> fp, double xmin, double xmax) invPolynomialApprox does the opposite ofpolynomialApprox3(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].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.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.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.
-
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 ofpolynomialApprox3(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 monotonicallyy- the desired y valuexmin- the start of the intervalxmax- the end of the intervaltolerance-- 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 ff- a functiony- the desired y valuexmin- the start of the intervalxmax- the end of the intervalx0- the initial approximationepsilon- 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 functiondf- the derivative of the functiony- the desired y valuexmin- the start of the intervalxmax- the end of the intervalx0- the initial approximationepsilon- 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
-