-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainClass.java
34 lines (23 loc) · 971 Bytes
/
MainClass.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
package exercise1;
import java.util.Scanner;
import org.mariuszgromada.math.mxparser.Function;
public class MainClass {
static double b = 610.135;
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
System.out.print(" enter the value of a");
double vala = scan.nextDouble();
System.out.print(" enter frequency ");
double freq = scan.nextDouble();
Function function = new Function ("f(t)=" +vala + "*(t)+ sin(2*" + freq + "*pi*t)");
System.out.println(" the power function is" + function.getFunctionExpressionString());
IntegrationMethod integration = new IntegrationMethod(function);
double answer = integration.Method3(0, 20, function);
System.out.println(" integration is" + answer);
double result = answer- b;
//3.05
double result1 = result/b;
System.out.println( " absolute error is" + result);
System.out.println( " relative error is" + result1);
}
}