Package jahuwaldt.tools.math
Class AbstractEvaluatable1D
- java.lang.Object
-
- jahuwaldt.tools.math.AbstractEvaluatable1D
-
- All Implemented Interfaces:
Evaluatable1D
public abstract class AbstractEvaluatable1D extends java.lang.Object implements Evaluatable1D
A class that defines a 1D functiony = fn(x)
(named "function") that can be called by math tools such as root finders. Also defines the derivative of the function.dy/dx = dfn(x)/dx
(oddly enough, named "derivative"). An optional capability of setting an initial function value is also provided. This aides the calculating of some functions and is a common enough problem that I've included it in the basicEvaluatable1D
class definition.Modified by: Joseph A. Huwaldt
- Version:
- February 23, 2025
- Author:
- Joseph A. Huwaldt Date: October 7, 1998
-
-
Constructor Summary
Constructors Constructor Description AbstractEvaluatable1D()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
derivative(double x)
Calculates the derivative of the functiondy/dx = d fn(x)/dx
.double
getInitialValue()
Returns the initial function value set with "setInitialValue()".void
setInitialValue(double initialValue)
Used to set an initial function value (or any other initial value the user wants to use).-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jahuwaldt.tools.math.Evaluatable1D
function
-
-
-
-
Constructor Detail
-
AbstractEvaluatable1D
public AbstractEvaluatable1D()
-
-
Method Detail
-
derivative
public double derivative(double x) throws RootException
Calculates the derivative of the functiondy/dx = d fn(x)/dx
. Classes wanting to return the derivative of the function at x should override this function. If the method using this class doesn't require the derivative, do nothing and Double.NaN is returned.- Specified by:
derivative
in interfaceEvaluatable1D
- Parameters:
x
- Independent parameter to the function.- Returns:
- The function value at x or Double.NaN if the derivative is not defined.
- Throws:
RootException
- if there is any problem calculating the derivative.
-
setInitialValue
public void setInitialValue(double initialValue)
Used to set an initial function value (or any other initial value the user wants to use). This function is provided as an optional service. The programmer may use this to aide in solving problems where you want to find the point wheref(x) - f0 = 0
. Use this function to set f0 and use "getInitialValue()" to retrieve f0 and calculate f(x) - f0 in your "function()" definition.- Parameters:
initialValue
- Initial function value, f0.
-
getInitialValue
public final double getInitialValue()
Returns the initial function value set with "setInitialValue()".- Returns:
- The initial value set with "setInitialValue()".
-
-