# Thread:

1. ## Fourth-order Runge-Kutta for this equation.

Hi,

For my 3rd year project I'm meant to code different O.D.E solving algorithms and run them on GPU and compare the results to running them on CPU.

The first algorithm I am meant to code is the fourth order Runge-Kutta for a O.D.E in the form:
dx/dt = ax(t), x0 = 0 (I think that is how it is written)

It's solution is meant to be in the form of x = e^(at)x0 (again, I think)

Could someone show me how to set up the runge kutta algorithm? I am totally confused about the t and the x in the Runge-Kutta equation.

2. Originally Posted by kenny
Hi,

For my 3rd year project I'm meant to code different O.D.E solving algorithms and run them on GPU and compare the results to running them on CPU.

The first algorithm I am meant to code is the fourth order Runge-Kutta for a O.D.E in the form:
dx/dt = ax(t), x0 = 0 (I think that is how it is written)

It's solution is meant to be in the form of x = e^(at)x0 (again, I think)

Could someone show me how to set up the runge kutta algorithm? I am totally confused about the t and the x in the Runge-Kutta equation.
We have an ODE of the form:

$\frac{dx}{dt}=f(x)$

Because $t$ does not appear explicitly on the right-hand-side of the ODE the equations for the 4-order RK algorithm become:

$x_{n+1}=x_n+\frac{h}{6}(k_1+2k_2+2k_3+k_4)$

with:

$k_1=f(x_n)$
$k_2=f(x_n+hk_1/2)$
$k_3=f(x_n+hk_2/2)$
$k_4=f(x_n+hk_3)$

Where $x_n=x(nh)$, so we start from $x_0=x(0)=0$ and step forward from there.

The full equations for 4-order RK can be found on the Wikipedia page.

CB
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 9, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9391152262687683, "perplexity_flag": "middle"}