17 lines
334 B
Plaintext
17 lines
334 B
Plaintext
import printer.formatter as pf;
|
|
|
|
euler(f, y, a, b, h) {
|
|
while (a < b) {
|
|
println(pf.rightAligned(2, a), " ", y);
|
|
a += h;
|
|
y += h * f(y);
|
|
}
|
|
}
|
|
|
|
main() {
|
|
for (i in [2.0, 5.0, 10.0]) {
|
|
println("\nFor delta = ", i, ":");
|
|
euler((temp) => -0.07 * (temp - 20), 100.0, 0.0, 100.0, i);
|
|
}
|
|
}
|