KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > analysis > Sine


1 package JSci.maths.analysis;
2
3 /**
4 * The sine function.
5 * @version 1.1
6 * @author Mark Hale
7 */

8 public class Sine extends RealFunction {
9         private final double A, w, k;
10         /**
11         * Constructs a sine function of the form <code>sin(x)</code>.
12         */

13         public Sine() {
14         this(1.0, 1.0, 0.0);
15         }
16         /**
17         * Constructs a sine function of the form <code>A sin(wx+k)</code>.
18         */

19         public Sine(double A, double w, double k) {
20         this.A = A;
21         this.w = w;
22         this.k = k;
23         }
24         public double map(double x) {
25                 return A*Math.sin(w*x+k);
26         }
27         public RealFunction differentiate() {
28         return new Cosine(A*w, w, k);
29         }
30 }
31
Popular Tags