runge_kutta_function

runge_kutta_function - { k1[i] = h*dydx[i]; yt[i] = yin[i]...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
void rk2(float xin, float yin[], float yout[], float h) { /* Second order Runge-Kutta scheme */ int i; float k1[N], k2[N], yt[N], dydx[N]; /* N is the number of ODEs */ /* Evaluate k1 */ derivs(xin, yin, dydx); for (i = 0; i < N; i++)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { k1[i] = h*dydx[i]; yt[i] = yin[i] + 0.5*k1[i]; } /* Evaluate k2, then update the dependent variable */ derivs(xin + 0.5*h, yt, dydx); for (i = 0; i &lt; N; i++) { k2[i] = h*dydx[i]; yout[i] = yin[i] + k2[i]; } return; }...
View Full Document

Ask a homework question - tutors are online