0
|
6920 Views
|
|
0 Total Likes
View groups...
Share
GROUPS:

# What is the difference between Explicit RungeKutta Method and RK4 Equation?

Posted 9 years ago
 Hello guys, I've been trying some built-in package in Mathematica and I have few questions. At first, I would like to solve my equation by using Runge-Kutta 4th order method. As I was looking into the tutorial, there's few types of equations such as Euler Equation and others as well. So for my equation, I've been using Method -> "ExplicitRungeKutta", "StartingStepSize" -> 1/1000] Then as I search online, I found some other ways, to use Runge-Kutta Equations, for example ClassicalRungeKuttaCoefficients[4, prec_] := With[{amat = {{1/2}, {0, 1/2}, {0, 0, 1}}, bvec = {1/6, 1/3, 1/3, 1/6}, cvec = {1/2, 1/2, 1}}, N[{amat, bvec, cvec}, prec]] Followed by, Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4, "Coefficients" -> ClassicalRungeKuttaCoefficients}, "StartingStepSize" -> 1/1000] And finally, I also found some manual input of Runge-Kutta 4th Order Equation from http://www.cfm.brown.edu/ Well I tried to use this manual input equation instead but, there is something I don't understand at all RK4s[f_, {x0_, xn_}, y0_, steps_] := Block[{xold = x0, yold = y0, sollist = {{x0, y0}}, x, y, n, h}, h = N[(xn - x0)/steps]; Do[xnew = xold + h; xhalf = xold + h/2; k1 = f /. {x -> xold, y -> yold}; k2 = f /. {x -> xhalf, y -> yold + k1*h/2}; k3 = f /. {x -> xhalf, y -> yold + k2*h/2}; k4 = f /. {x -> xnew, y -> yold + k3*h}; ynew = yold + (h/6)*(k1 + 2*k2 + 2*k3 + k4); sollist = Append[sollist, {xnew, ynew}]; xold = xnew; yold = ynew, {steps}]; Return[sollist[[steps + 1]]]]  I'm new in Mathematica and I need your guidance. Thank you very much.