package com.imsl.test.example.math; import com.imsl.math.*; /** *
* ZeroFunction Example 1: Finds the zeros of univariate function.
* In this example \(3\) zeros of the \(\sin\) function are found. * * @see Code * @see Output * * @deprecatedZeroFunction
class has been deprecated.
*/
public class ZeroFunctionEx1 {
public static void main(String args[]) {
ZeroFunction.Function fcn = new ZeroFunction.Function() {
@Override
public double f(double x) {
return Math.sin(x);
}
};
ZeroFunction zf = new ZeroFunction();
double guess[] = {5, 18, -6};
double zeros[] = zf.computeZeros(fcn, guess);
for (int k = 0; k < zeros.length; k++) {
System.out.println(zeros[k] + " = " + (zeros[k] / Math.PI) + " pi");
}
}
}