Download presentation
Presentation is loading. Please wait.
Published byAubrey Lee Modified over 9 years ago
1
public class Edo1 { private static double euler(double y, double h, double t, Derivada d) { return y + h * d.f(y, t); } public static void euler(double t[], double y[], double y0, double t1, double t2, int ni, Derivada d) { double h = Math.abs(t2 - t1) / ni; t[0] = t1; y[0] = y0; for(int i = 0; i < ni - 1; i++) { y[i + 1] = euler(y[i], h, t[i], d); t[i + 1] = t[i] + h; } } } Para 1 ecuación
2
class Derivada { private double k =.27; public double f(double y, double t) { return -k * y; } } class Prueba { public static void main(String s[]) { int ni = 10; double x[] = new double[ni]; double y[] = new double[ni]; Derivada der = new Derivada(); Edo1.euler(x, y, 10, 0., 20., ni, der); for(int i = 0; i < ni; i++) { System.out.println(x[i] + " " + y[i]); } } }
3
private static void euler(double y1[], double h, double t, Derivadas derivadas) { double dydt[] = new double[y1.length]; derivadas.f(y1, t, dydt); for(int i = 0; i < y1.length;i++) y1[i] = y1[i] + h * dydt[i]; } private static double euler(double y1, double h, double t, Derivada derivada) { return y1 + h * derivada.f(y1, t); } Para Ne Ecuaciones
4
class Derivadas { public void f(double y[], double t, double dydt[]) { dydt[0] = (5 * y[1] / (y[1] +.9) -.7) * y[0]; dydt[1] = -(5 * y[1] / (y[1] +.9)) * y[0]; } } Por ejemplo para dos ecuaciones
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.