I have to create a java program that integrates equations into the 4th order Run
ID: 3640280 • Letter: I
Question
I have to create a java program that integrates equations into the 4th order Runge-Kutta Method but I have absolutely no idea how to incorporate the equations.
The code for the Runge-Kutta method is the following.
/* call this function in a loop from starting point to stopping point */
public double rk(double x, double y, double step){
double h = step;
double k0 = h * f(x, y);
double k1 = h * f(x + 0.5 * h, y + 0.5 * k0);
double k2 = h * f(x + 0.5 * h, y + 0.5 * k1);
double k3 = h * f(x + h, y + k2);
return y + 1.0/6.0 * (k0 + 2 * k1 + 2 * k2 + k3);
For example, if my equation was 5 - 1/x + 4 * x * x from 0.001 to 20, how would I integrate this?