1 package JSci.maths.analysis; 2 3 9 public class Power extends RealFunction { 10 private final double A, n, k; 11 14 public Power() { 15 this(1.0, 0.0, 1.0); 16 } 17 20 public Power(double A, double n) { 21 this(A, 0.0, n); 22 } 23 26 public Power(double A, double k, double n) { 27 this.A = A; 28 this.k = k; 29 this.n = n; 30 } 31 public double map(double x) { 32 x += k; 33 if(n == 1.0) 34 x = x; 35 else if(n == 2.0) 36 x *= x; 37 else 38 x = Math.pow(x, n); 39 return A*x; 40 } 41 public RealFunction differentiate() { 42 return new Power(A*n, k, n-1); 43 } 44 } 45 | Popular Tags |