Created by Roman on 10 04 14 public class Lab_7 private static final d

 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
/**
* Created by Roman on 10.04.14.
*/
public class Lab_7 {
private static final double A = 0.01;
private static final double FROM = 0;
private static final double TO = 3;
private static final double H = 0.1;
private static final double Y_20 = 0.5;
public static void main(String... args) {
int iteration = (int) ((TO - FROM) / H + 1);
double[] x = new double[iteration];
x[0] = FROM;
double[] y1 = new double[iteration];
y1[0] = 0;
double[] y2 = new double[iteration];
y2[0] = Y_20;
for (int index = 1; index < iteration; index++) {
y2[index] = y2[index - 1] + H * (-A * x[index - 1] * y2[index - 1] - y1[index - 1]);
y1[index] = y2[index - 1];
x[index] = x[index - 1] + H;
}
for (int index = 0; index < iteration; index++) {
System.out.println("X[" + index + "] = " + x[index]);
}
System.out.println("--------------");
for (int index = 0; index < iteration; index++) {
System.out.println("Y1[" + index + "] = " + y1[index]);
}
System.out.println("--------------");
for (int index = 0; index < iteration; index++) {
System.out.println("Y2[" + index + "] = " + y2[index]);
}
}
}