taylor
Class TSEModel

java.lang.Object
  extended by taylor.TSEModel

public class TSEModel
extends java.lang.Object

Model for a function and its Taylor series expansion.


Constructor Summary
TSEModel()
          Create a new model with default values.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Add a ChangeListener.
 double evaluateFunction(double x)
           
 double evaluateSeries(double x)
           
 void fireStateChanged(javax.swing.event.ChangeEvent e)
          Notify all ChangeListeners.
 java.lang.String getError()
           
 java.lang.String getFunction()
           
 taylor.Change getLastChange()
           
 int getNumberOfTerms()
           
 double getPoint()
           
 double getSeriesCoeff(int n)
           
 boolean isLoading()
           
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Remove a ChangeListener.
 boolean setFunction(java.lang.String function)
          Set the function to use.
 boolean setNumberOfTerms(int terms)
          Set the number of terms in the Taylor series.
 void setPoint(double point)
          Set the point to use for Taylor series expansion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSEModel

public TSEModel()
Create a new model with default values. The default function is sin(x), the default point is x = 0 and the number of terms is 2.

Method Detail

getFunction

public java.lang.String getFunction()
Returns:
the function in use.

setFunction

public boolean setFunction(java.lang.String function)
Set the function to use.

Returns:
true if the function was accepted, false if the function cannot be used or the requested number of terms was too high for this function.

getPoint

public double getPoint()
Returns:
the point used for Taylor series expansion.

setPoint

public void setPoint(double point)
Set the point to use for Taylor series expansion.


getNumberOfTerms

public int getNumberOfTerms()
Returns:
the number of terms in the Taylor series.

setNumberOfTerms

public boolean setNumberOfTerms(int terms)
Set the number of terms in the Taylor series.

Returns:
whether the program can handle this many terms for the current function.

getSeriesCoeff

public double getSeriesCoeff(int n)
Returns:
the coefficient of xn in the taylor series expansion.

getLastChange

public taylor.Change getLastChange()
Returns:
the last change in the model.

isLoading

public boolean isLoading()
Returns:
whether the model is between states. If true, trying to get the state of the model will cause delays.

getError

public java.lang.String getError()
Returns:
the last error that occurred.

evaluateFunction

public double evaluateFunction(double x)
Returns:
the function evaluated in the given point x.

evaluateSeries

public double evaluateSeries(double x)
Returns:
the Taylor series evaluated in the given point x.

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Add a ChangeListener.


removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Remove a ChangeListener.


fireStateChanged

public void fireStateChanged(javax.swing.event.ChangeEvent e)
Notify all ChangeListeners.