Created
April 1, 2016 14:05
-
-
Save quirinpa/701d6b3c85913ceebaa3b99bbf431bd0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef RK4_H | |
#define RK4_H | |
double rk4(double xi, double yi, double h, double df()) { | |
double k[4]; | |
k[0] = df(xi, yi); | |
k[1] = df(xi + h/2, yi + h*k[0])/2; | |
k[2] = df(xi + h/2, yi + h*k[1])/2; | |
k[3] = df(xi + h, yi + h*k[2]); | |
return yi + h(k[0]+2*(k[1]+k[2]) + k[3])/6; | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment