Re: NDsolve with a quasi random scource
- To: mathgroup at smc.vnet.net
- Subject: [mg107631] Re: NDsolve with a quasi random scource
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Sat, 20 Feb 2010 06:38:33 -0500 (EST)
- References: <hllibo$o3$1@smc.vnet.net>
Clint Zeringue wrote: > Hello, > > I have a quick question regarding the use of a pseudo-random scource inside NDsolve. > > Suppose you have the following: > > scource[z_,]:= RandomReal[{-5,5}] > > Then in NDsolve we have > > NDsolve[f'[z] + f[z] == scource[z],f,{z,0.5}] > > My question is as the integrator works to solve this system within NDsolve is it really putting in a random number at each z-step? or is it just evaluated scource[z] once and returning a number, and then going into the integrator?' > > Nevertheless, How can I keep the algorithm that is actually solving this system to pull random numbers at each z step? > > Thanks, > > -Clint > You really don't want to think about z-steps when you use NDSolve, because NDSolve will use whatever size steps it wants, and it really requires that your function be consistent and preferably continuous :) This problem crops up in simpler contexts than NDSolve, for example, it makes no sense to plot a function such as: Plot[Sin[z]+Random[],{z,0,10}] because the 'frequency' of the random fuzz introduced will depend on the step size that Plot uses. You really need to think a bit more about what your function really is - perhaps you should create a list of equally spaced random points, and generate an interpolation between them to create your random source in a step-independent way. David Bailey http://www.dbaileyconsultancy.co.uk