Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16764

Runge-Kutta 2

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!backlog3.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From amzoti <amzoti@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Runge-Kutta 2
Date Thu, 10 Apr 2014 07:09:33 +0000 (UTC)
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <li5g3d$3lc$1@smc.vnet.net> (permalink)
Lines 27
Organization Time-Warner Telecom
NNTP-Posting-Date 10 Apr 2014 07:15:32 GMT
NNTP-Posting-Host faf1d749.news.twtelecom.net
X-Trace DXC=@O<OmT>jNg?9g9ZDEYmh=8C_A=>8kQj6=;[h;PUXBgb4Pm3bW^Q9cm6EFiONJ7[Go6cMmm[WNG2W;
X-Complaints-To abuse@twtelecom.net
X-Original-Bytes 2047
X-Received-Bytes 2151
X-Received-Body-CRC 3058068128
Xref csiph.com comp.soft-sys.math.mathematica:16764

Show key headers only | View raw


After spending some time using the Mathematica documentation I implemented the Runge-Kutta-2 routines below.

I am hoping someone can validate what I did and tell me that it is correct (especially the Butcher Tableau I used) and the step size h=0.1.

  ClassicalRungeKuttaCoefficients[4, prec_] :=
   With[{amat = {{1/2}}, bvec = {0, 1}, cvec = {1/2}},
    N[{amat, bvec, cvec}, prec]]

  {xf, yf} = {x, y} /.
    First@NDSolve[{x'[t] == -y[t], y'[t] == x[t], x[0] == 1,
     y[0] == 0}, {x, y}, {t, 0, 6},
     Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4,
    "Coefficients" -> ClassicalRungeKuttaCoefficients},
     StartingStepSize -> 1/10];

  xl = MapThread[Append, {xf["Grid"], xf["ValuesOnGrid"]}]

  yl = MapThread[Append, {yf["Grid"], yf["ValuesOnGrid"]}]

We can find a closed form solution to this problem as:

  s = DSolve[{x'[t] == -y[t], y'[t] == x[t], x[0] == 1, y[0] == 0}, {x, y}, t]

Is there an automated way to update and step through each variant of RK-2, RK-3, RK-4, ... without having to manually enter the Butcher values (in other words, I want to step through each variant of RK-n and compare the errors (a table of that would be great))? There is a hint of this at: http://reference.wolfram.com/mathematica/tutorial/NDSolveExplicitRungeKutta.html

Lastly, is there a better approach?

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar


Thread

Runge-Kutta 2 amzoti <amzoti@gmail.com> - 2014-04-10 07:09 +0000

csiph-web