Package org.opensourcephysics.numerics
Class ParsedFunction
java.lang.Object
org.opensourcephysics.numerics.ParsedFunction
- All Implemented Interfaces:
Function
ParsedFunction defines a function of a single varianble using a String.
This function is immutable. That is, once an instance is created with a particular
function string, the function cannot be changed. Because immutable
objects cannot change, they are thread safe and can be freely shared in a Java
program.
- Author:
- Wolfgang Christian
-
Constructor Summary
ConstructorsConstructorDescriptionParsedFunction
(String fStr) Constructs a function x with from the given string.ParsedFunction
(String _fStr, String var) Constructs a ParsedFunction from the given string and independent variable. -
Method Summary
-
Constructor Details
-
ParsedFunction
Constructs a function x with from the given string.- Parameters:
fStr
- the function- Throws:
ParserException
-
ParsedFunction
Constructs a ParsedFunction from the given string and independent variable.- Parameters:
_fStr
- the functionvar
- the independent variable- Throws:
ParserException
-
-
Method Details
-
evaluate
public double evaluate(double x) Evaluates the function, f. -
toString
Represents the function as a string.
-