static double f(double x, double y)
return -Math.Sin(x) + 5 * y * Math.Cos(x);
double x0 = 2, y0 = -5.6, xf = 12, h = 0.001;
int n = (int)((xf - x0) / h);
double[] x = new double[n + 1];
double[] y = new double[n + 1];
for (int i = 0; i < n; i++)
double k1 = h * f(x[i], y[i]);
double k2 = h * f(x[i] + h / 2, y[i] + k1 / 2);
double k3 = h * f(x[i] + h / 2, y[i] + k2 / 2);
= h * f(x[i] + h, y[i] + k3);
+ (1.0 / 6.0) * (k1 + 2 * k2 + 2 * k3 + k4);
Console.WriteLine("Valor de f(x) en x=12: " + y[n]);