1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.math.analysis;
17
18 import org.apache.commons.math.FunctionEvaluationException;
19
20 /**
21 * Auxillary class for testing solvers.
22 *
23 * The function is extraordinarily well behaved around zero roots: it
24 * has an inflection point there (second order derivative is zero),
25 * which means linear approximation (Regula Falsi) will converge
26 * quadratically.
27 *
28 * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
29 */
30 public class SinFunction implements DifferentiableUnivariateRealFunction {
31
32
33
34
35 public double value(double x) throws FunctionEvaluationException {
36 return Math.sin(x);
37 }
38
39
40
41 public UnivariateRealFunction derivative() {
42 return new UnivariateRealFunction() {
43 public double value(double x) throws FunctionEvaluationException {
44 return Math.cos(x);
45 }
46 };
47 }
48
49 }