Class FieldSqrt
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.UnaryFunction
com.singularsys.extensions.field.functions.FieldSqrt
- All Implemented Interfaces:
PostfixMathCommandI,Serializable
Calculate the square root of a number using any field.
Uses the Babylonian method with the iterative formula
x_{n+1} = (x_n + S / x_n) / 2
where S is the input number scaled to lie between 1/16 and 16.
Algorithm will stop until convergence or the maximum number of iterations is reached.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.singularsys.jep.functions.UnaryFunction
UnaryFunction.FunctionWithException<T> -
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEvaluate the functionintvoidsetNum_itts(int num_itts) toString()Return a string representation of the function.Methods inherited from class com.singularsys.jep.functions.UnaryFunction
instanceOf, instanceOf, instanceOf, instanceOf, runMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString
-
Constructor Details
-
FieldSqrt
Constructor- Parameters:
f- the field for all computationsnum_itts- maximum number of iterations
-
-
Method Details
-
eval
Description copied from class:UnaryFunctionEvaluate the function- Specified by:
evalin classUnaryFunction- Parameters:
arg- the single argument passed in- Returns:
- the result of the function
- Throws:
EvaluationException- on error
-
getNum_itts
public int getNum_itts() -
setNum_itts
public void setNum_itts(int num_itts) -
toString
Description copied from class:PostfixMathCommandReturn a string representation of the function. If the name is not null, return the name, otherwise return the class name.- Overrides:
toStringin classPostfixMathCommand
-