Package edu.cmu.tetrad.util
Class TaylorSeries
java.lang.Object
edu.cmu.tetrad.util.TaylorSeries
Represents a Taylor series expansion for a mathematical function. A Taylor series approximates a function as a sum of
terms calculated from the derivatives at a specific center. This class is thread-safe and immutable.
- Author:
- josephramsey
-
Method Summary
Modifier and TypeMethodDescriptiondoubleevaluate(double x) Evaluates the Taylor series at a given point x by summing the terms up to the length of the derivative array.static TaylorSeriesget(double[] derivatives, double a) Get the Taylor series with the given derivatives and center.doubleRetrieves the center point about which the Taylor series is expanded.double[]Retrieves a copy of the array containing the derivatives of the Taylor series.voidPrint the Taylor series.voidsetCenter(double center) Sets the center point of the Taylor series.withModifiedDerivatives(double[] newDerivatives) Creates a new TaylorSeries instance with modified derivatives while maintaining the same center.withNewCenter(double newCenter) Creates a new TaylorSeries object with the same derivatives but a specified new center.
-
Method Details
-
get
Get the Taylor series with the given derivatives and center. The length of the derivative array determines the degree of the Taylor series.- Parameters:
derivatives- Derivatives for the Taylor series.a- Center of the Taylor series.- Returns:
- Taylor series with the given derivatives and center.
-
withNewCenter
Creates a new TaylorSeries object with the same derivatives but a specified new center.- Parameters:
newCenter- The new center point of the Taylor series.- Returns:
- A new TaylorSeries object with the updated center.
-
withModifiedDerivatives
Creates a new TaylorSeries instance with modified derivatives while maintaining the same center.- Parameters:
newDerivatives- An array of new derivatives to be used in the TaylorSeries.- Returns:
- A new TaylorSeries object with the updated derivatives and the existing center.
-
getDerivatives
public double[] getDerivatives()Retrieves a copy of the array containing the derivatives of the Taylor series. The derivatives represent the coefficients of the Taylor series expansion about its center.- Returns:
- A copy of the array containing the derivatives of the Taylor series.
-
getCenter
public double getCenter()Retrieves the center point about which the Taylor series is expanded.- Returns:
- The center point of the Taylor series.
-
setCenter
public void setCenter(double center) Sets the center point of the Taylor series. This does not change the derivatives of the series, only the point about which the series is expanded.- Parameters:
center- The new center point of the Taylor series.
-
evaluate
public double evaluate(double x) Evaluates the Taylor series at a given point x by summing the terms up to the length of the derivative array.- Parameters:
x- The value at which to evaluate the Taylor series.- Returns:
- The computed value of the series at the specified point x.
-
printSeries
public void printSeries()Print the Taylor series.
-