-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaylor.java
More file actions
63 lines (40 loc) · 1.44 KB
/
Taylor.java
File metadata and controls
63 lines (40 loc) · 1.44 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
55
56
57
58
59
60
61
62
63
public class Taylor{
/*
* Classe per l'astrazione dei metodi di Eulero
*/
//--------------- Attributi: variabili membro------------//
public double coeff_y_i_uno;
public double coeff_y_i_due;
public int i_iniziale;
public int o_grande;
//--------------- Metodo membro-------------------------//
public double[] buildArray(double a, double b, int c, int d){
coeff_y_i_uno = a;
coeff_y_i_due = b;
i_iniziale = c;
o_grande = d;
// 1 ) istanza per usare la lunghezza di X
Vettore x_vett = new Vettore();
// 2 ) istanza per le condizioni iniziali su y
CondIniz ci = new CondIniz();
double y_istante_gen [];
y_istante_gen = new double [x_vett.n];
y_istante_gen [0] = ci.y_iniziale;
if (o_grande==2){
y_istante_gen [1] = (1-ci.lambda*ci.delta_x)*y_istante_gen[0];
for ( int i=i_iniziale; i< (x_vett.n); i++){
y_istante_gen[i] = (coeff_y_i_uno*y_istante_gen[i-1]) + coeff_y_i_due*y_istante_gen[i-2];
System.out.println(y_istante_gen [i]);
} // for
} // if
else {
for (int i=i_iniziale; i<x_vett.n; i++){
y_istante_gen [i] = (coeff_y_i_uno*y_istante_gen [i-1]);
System.out.println(y_istante_gen [i]);
} // for
} // else
// System.out.println("da buildarray di taylor: coeff y_(i-1)\t:" + coeff_y_i_uno);
// System.out.println(y_istante_gen.length);
return y_istante_gen;
} // buildArray
} // class