forked from cstrahan/aduni
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuncTest.java
More file actions
54 lines (41 loc) · 1.23 KB
/
FuncTest.java
File metadata and controls
54 lines (41 loc) · 1.23 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class FuncTest{
static class SinFunc extends RFunc{
public double evaluate(double x){
return(Math.sin(x));
}
}
static class ExpFunc extends RFunc{
public double evaluate(double x){
return(Math.exp(x) - 2.0);
}
}
static class LogFunc extends RFunc{
public double evaluate(double x){
return(Math.log(x) - 1);
}
}
public static void main(String[] args){
RFunc sin = new SinFunc();
RFunc exp = new ExpFunc();
RFunc log = new LogFunc();
double x;
x = sin.bracketRoot(1.0,4.0,0.0000000001);
System.out.println((float)x);
System.out.println((float)Math.PI);
x = exp.bracketRoot(0.0,4.0,0.0000000001);
System.out.println((float)x);
System.out.println((float)Math.log(2));
x = log.bracketRoot(1.0,4.0,0.0000000001);
System.out.println((float)x);
System.out.println((float)Math.E);
x = sin.defIntegral(0.0,Math.PI/2,1024*1024);
System.out.println((float)x);
System.out.println((float)1.0);
x = exp.defIntegral(0.0,2.0,1024*1024);
System.out.println((float)x);
System.out.println((float)(Math.exp(2) - 5));
x = log.defIntegral(1.0,2.0,1024*1024);
System.out.println((float)x);
System.out.println((float)(2*Math.log(2) - 2));
}
}