KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

19         public Tangent(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.tan(w*x+k);
26         }
27         public RealFunction differentiate() {
28         Cosine cos = new Cosine(1.0, w, k);
29         return RealFunction.constant(A*w).divide(cos.multiply(cos));
30         }
31 }
32
Popular Tags