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