Re: NDSolve -- n-body indexing ([[]]) problem
- To: mathgroup at smc.vnet.net
- Subject: [mg112237] Re: NDSolve -- n-body indexing ([[]]) problem
- From: Greylander <greylander at gmail.com>
- Date: Mon, 6 Sep 2010 04:14:37 -0400 (EDT)
- References: <i5vnri$2e1$1@smc.vnet.net>
Hello Themis, Thanks for the reply. I think you mis-interpreted my problem. The differential equation(s) are not stochastic. The RandomReal[] function in the example is only used for the initial conditions. I should have chosen an example that was easier to read. See my new thread which states the problem more clearly: ""NDSolve -- indexing of dependent variable that is arbitrary list". I have found a workaround, which I will post on that thread. Scott On Sep 5, 5:28 am, Themis Matsoukas <tmatsou... at me.com> wrote: > The problem is that your differential equations are stochastic. I asked wolfram about it (see email below) using the following as a minimal example (which doesn't work): > > Remove@g1 > g1[t_?NumberQ] := (RandomReal[] - 0.5)*t; > sln = NDSolve[{ > y'[t] == g1[t], > y[0] == 0 > }, {y}, {t, 0, 1}] > Plot[Evaluate[y /. sln[[1]]][t], {t, 0, 1}, PlotRange -> All, > AxesOrigin -> {0, 0}] > > Wolfram's answer is basically that you cannot do this NDSolve. Tech support suggested to use RecurrenceTable: > > Remove@g1 ; Clear [a, pp]; > g1[t_?NumberQ] := (RandomReal[] - 0.5)*t; dt = 0.0001; > > pp = RecurrenceTable[{a[n + 1] - a[n] == dt*g1[n], a[0] == 0}, > a[n], {n, 1, Round[1/dt]}] ; > ListPlot[pp, PlotRange -> All] > > This, however, forces you to apply a simple Euler integration and that's unfortunate because you cannot take advantage of advanced integration algorithms (stiff systems, adjustable time steps, etc) unless you code them yourself. I hope that Mathematica will come up with a module similar to NDSolve that is truly numerical, i.e. it would work with tabulated data, not just functions that can be expressed in analytic form. > > Themis > > =========================== > From: Themis Matsoukas > Date: Wed, 16 Jun 2010 11:42:03 -0500 > Subject: Premier Service Help Form > To: supp... at wolfram.com > > Suggestion or Bug: > I want to solve a differential equation of the form, > > {y'[t]==G[t], y[0]==y0} > > where G[t] is a stochastic function. In the problem I have in mind, the value of G[t] is calculated by running a Monte Carlo simulation, so its actual value at each point is subject to some noise. However, I found out that NDSolve does not accommodate ODEs whose right-hand side contains stochastic terms. In a minimal example (which I am attaching), the definition of G is > > G[t_] := (RandomReal[] - 0.5) t; > > When G is used inside NDSolve, it seems that the random number is calculated just once and not each time an evaluation of G[t] is called for. That is, NDSolve treats G as if > > G[t_] := A t > > where A is a constant that is randomly picked at the beginning of the calculation. Is there a way to force NDSolve to use the actual values that would returned by the delayed assignment in the definition of G? > > Thanks > > Themis Matsoukas > ========================== > > Hello Mr. Matsoukas, > > Thank you for the email. Please refer to the attached notebook. Essentially > NDSolve is not well suited to solve Stochastic type differential equations. > The use of RecurrenceTable is a more appropriate option. > > Sincerely, > > Paritosh Mokhasi, Ph.D. > Technical Support > Wolfram Research, Inc.http://support.wolfram.com