|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.webcompmath.data.SimpleFunction
public class SimpleFunction
An object belonging to this class is a function of one or more variables. It is defined by an expression, e, and a list of variables, which presumably can occur in e. The value of the function at arguments x1,x2,... is obtained by assigning the x's as the values of the variables and then evaluating the expression e.
Note: When the function is evaluated, the values of the variables that act as its parameters are saved and the variables are set to the values of the actual parameters provided for the function. After the evaluation, the saved values are restored. Usually, this is OK, but if setting the value of the variable has a side effect (such as changing the position of a VariableSlider), it could be a problem. So, don't use the variables associated with VariableSliders or VariableInputs in SimpleFunctions.
Note: A SimpleFunction is not a MathObject and does not have a name. It cannot be added to a Parser. If you want to do somethign like that, use an ExpressionFunction (defined in package edu.hws.jcm.functions).
Constructor Summary | |
---|---|
SimpleFunction(Expression e,
Variable v)
Create the function of one variable such that the value of the function at x is obtained by temporarily assigning x as the value of the variable v and then evaluating e. |
|
SimpleFunction(Expression e,
Variable[] v)
Create a function. |
Method Summary | |
---|---|
boolean |
dependsOn(Variable x)
Return true if the definition of this function depends in some way on the variable x. |
Function |
derivative(int wrt)
Return the derivative of the function with repect to argument number wrt, where arguments are numbered starting from 1. |
Function |
derivative(Variable x)
Return the derivative of the function with respect to the variable x. |
int |
getArity()
Return the number of arguments of this function. |
double |
getVal(double[] arguments)
Find the value of the function at the argument values argument[0], argument[1].... |
double |
getValueWithCases(double[] arguments,
Cases cases)
Find the value of the function at the argument values argument[0], argument[1].... |
java.lang.String |
toString()
Returns the text representation of the expression |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SimpleFunction(Expression e, Variable v)
e
- expression to evaluatev
- variable to use in evaluationpublic SimpleFunction(Expression e, Variable[] v)
e
- expression to evaluatev
- array of variables to useMethod Detail |
---|
public int getArity()
getArity
in interface Function
public double getVal(double[] arguments)
getVal
in interface Function
arguments
- array of arg. values
public double getValueWithCases(double[] arguments, Cases cases)
getValueWithCases
in interface Function
arguments
- array of arg. valuescases
- cases to use
public Function derivative(int wrt)
derivative
in interface Function
wrt
- arg. number with respect to
public Function derivative(Variable x)
derivative
in interface Function
x
- variable with respect to
public boolean dependsOn(Variable x)
dependsOn
in interface Function
x
- variable to check
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |