-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cos.java
39 lines (32 loc) · 1019 Bytes
/
Cos.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class Cos {
private double coefficient;
private double period;
private double exponent;
public Cos(double coefficient, double period, double exponent){
this.coefficient = coefficient;
this.period = period;
this.exponent = exponent;
}
public double calculateCos(double x) {
final double cos = this.coefficient * Math.pow(Math.cos(this.period * x), this.exponent);
return cos;
}
public Sin cosDerivative() {
final Sin sin;
if(this.exponent > 1) {
sin = new Sin(-1 * this.coefficient * this.exponent * this.period, this.period, this.exponent - 1);
} else {
sin = new Sin(-1 * this.coefficient * this.period, this.period, this.exponent);
}
return sin;
}
public double getCoefficient() {
return this.coefficient;
}
public double getPeriod() {
return this.period;
}
public double getExponent() {
return this.exponent;
}
}