Runge-Kutta method: Difference between revisions

m
Improve formatting of problem (\delta t not dt, \times not *)
m (moved Runge-Kutta to Runge-Kutta method: Page names should be clearer)
m (Improve formatting of problem (\delta t not dt, \times not *))
Line 1:
{{draft task}}
Given the example Differential equation:
:<math>y' = t *\times \sqrt y</math>
With initial condition:
:<math>t_0 = 0</math> and <math>y_0 = y(t_0) = y(0) = 1</math>
This equation has an exact solution:
:<math>y = \tfrac{1}{16}(t^2 +4)^2</math>
''';Task'''
:Demonstrate the commonly used explicit fourth-order Runge–Kutta method as defined in the [[wp:Runge–Kutta_methods#Common_fourth-order_Runge.E2.80.93Kutta_method|Wikipedia article]] to solve the above differential equation.
:* Solve the given differential equation over the range <math>t = 0 ..\ldots 10</math> with a step value of h=dt<math>\delta t=0.1</math> (101 total points, the first being given)
:* Print the calculated values of <math>y</math> at whole numbered <math>t</math>'s (<math>0.0, 1.0, ...\ldots 10.0</math>) along with error as compared to the exact solution.
''';Method Summary'''summary
:Starting with a given <math>y_n</math> and <math>t_n</math> calculate:
:<math>dy_1\delta y_1 = dt*\delta t\times y'(t_n, y_n)\quad</math>
:<math>dy_2\delta y_2 = dt*\delta t\times y'(t_n + \tfrac{1}{2}dt\delta t , y_n + \tfrac{1}{2}dy_1\delta y_1)</math>
:<math>dy_3\delta y_3 = dt*\delta t\times y'(t_n + \tfrac{1}{2}dt\delta t , y_n + \tfrac{1}{2}dy_2\delta y_2)</math>
:<math>dy_4\delta y_4 = dt*\delta t\times y'(t_n + dt\delta t , y_n + dy_3\delta y_3)\quad</math>
:then:
:<math>y_{n+1} = y_n + \tfrac{1}{6} (dy_1\delta y_1 + 2dy_22\delta y_2 + 2dy_32\delta y_3 + dy_4\delta y_4)</math>
:<math>t_{n+1} = t_n + dt\delta t\quad</math>
* The reference implementation is provided in Ada.
 
=={{header|Ada}}==
Anonymous user