Class TaylorSeries

java.lang.Object
edu.cmu.tetrad.util.TaylorSeries

public class TaylorSeries extends Object
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 Type
    Method
    Description
    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.
    get(double[] derivatives, double a)
    Get the Taylor series with the given derivatives and center.
    double
    Retrieves the center point about which the Taylor series is expanded.
    double[]
    Retrieves a copy of the array containing the derivatives of the Taylor series.
    void
    Print the Taylor series.
    void
    setCenter(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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public static TaylorSeries get(double[] derivatives, double a)
      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

      public TaylorSeries withNewCenter(double newCenter)
      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

      public TaylorSeries withModifiedDerivatives(double[] newDerivatives)
      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.