Explore BrainMass

Explicit Runge-Kutta Method

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Write a general purpose RK routine; here described in a matlab
context (but feel free to re-interpret into and program in any language environment)

[t_out,y_out,e_out] = rk ( ode_RHS, y_0, t_range, c, A, b1, b2 )

input parameters:
ode_RHS= function handle to right side f of the ODE y'=f(t,y)
y_0= initial value for ODE
t_range=the vector T_start:h:T_stop where h is the step size
c= the vector c in the butcher array that specifies the RK method
A= the matrix A in the butcher array that specifies the RK method
b1= vector in the butcher array that specifies primary RK method
b2= vector in the butcher array that specifies secondary RK method

output parameters:
t_out= the times where the solution was computed
y_out=the solution computed at the times t_out
e_out= the step-error estimated at the times t_out. Computed only when b2 is supplied.

Where is the step size h? You probably want to use something like
h_current_step=t_range(k) - t_range(k-1)
so that your code does not break if/when user passes in a non-uniform
e.g.t_range = [0 0.1 0.2 0.4 0.46 0.47 0.5 0.7 0.8 0.9 0.99 0.999 0.9999 1].

© BrainMass Inc. brainmass.com March 22, 2019, 1:15 am ad1c9bdddf

Solution Preview

Two scripts are uploaded:
GenRK.m is the general Runge-Kutta script ...

Solution Summary

The solution writes the general purpose of Runge-Kutta method. A description is provided in matlab.