MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: How can I "perturbate" a

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102090] Re: [mg102056] Re: [mg102035] Re: [mg102000] How can I "perturbate" a
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Wed, 29 Jul 2009 05:09:38 -0400 (EDT)
  • References: <200907260754.DAA18931@smc.vnet.net>
  • Reply-to: drmajorbob at bigfoot.com

Ask the original poster. His code was

If[RandomReal[]<0.001,a=RandomReal[],a=0]

Bobby

On Tue, 28 Jul 2009 11:58:28 -0500, Pratip Chakraborty  
<pratip.chakraborty at gmail.com> wrote:

> Hi,
> I want to ask that with this condition RandomReal[] < 0.001 what you  
> want to
> do?
> It is obvious that this condition will not assure a[t]<0.001.
> yours,
> Pratip
> On Tue, Jul 28, 2009 at 6:31 PM, Pratip Chakraborty <
> pratip.chakraborty at gmail.com> wrote:
>
>> Hi,
>> Clear[a, x1, x2]
>> a[t_?NumericQ] :=
>>  a[t] = If[RandomReal[] < 0.001, RandomReal[], 0]
>> soln = Reap[
>>    NDSolve[{x1'[t] == (Sin[t] + a[t])*x2[t],
>>      x2'[t] == (Cos[t] - a[t]*x1[t]^2)*x1[t], x1[0] == 1,
>>      x2[0] == 0}, {x1, x2}, {t, 0, 10},
>>     EvaluationMonitor :> Sow[a[t]]]];
>> This reports that there was actually not perturbation in the solution.  
>> a[t]
>> remained zero in all the time step.
>> regards,
>> Pratip
>>
>>
>> On Tue, Jul 28, 2009 at 8:03 AM, DrMajorBob <btreat1 at austin.rr.com>  
>> wrote:
>>
>>> You'll need something like
>>>
>>> Clear[a,x1,x2]
>>> a[t_?NumericQ]:=a[t]=If[RandomReal[]<0.001,RandomReal[],0]
>>>
>>> soln=NDSolve[{x1'[t]==(Sin[t]+a[t])*x2[t],x2'[t]==(Cos[t]-a[t]*x1[t]^2)*x1[t],x1[0]==1,x2[0]==0},{x1,x2},{t,0,10}];
>>> {x1,x2}={x1,x2}/.First@soln
>>>
>>>
>>> {InterpolatingFunction[{{0.,10.}},<>],InterpolatingFunction[{{0.,10.}},<>]}
>>>
>>> Plot[{x1@t,x2@t},{t,0,10}]
>>>
>>> NumericQ prevents symbolic evaluation of the equations, and
>>> a[t_?NumericQ]:=a[t]=... makes sure that a[t] is the same every time a
>>> specific t is used. That's what it takes to make a[t] truly a function  
>>> of
>>> t.
>>>
>>> Bobby
>>>
>>> On Mon, 27 Jul 2009 04:55:20 -0500, Iván Lazaro <gaminster at gmail.com>
>>> wrote:
>>>
>>> > Thanks for the answers!
>>> >
>>> > I need a more specific perturbation. I need something like this (with
>>> > this I
>>> > expect to manipulate the frequency of the perturbation)
>>> >
>>> >
>>> > If[RandomReal[]<0.001,a=RandomReal[],a=0]
>>> >
>>> >
>>> >  NDSolve[{x1'[t] == (Sin[t] + a)*x2[t],
>>> >   x2'[t] == (Cos[t] - a*x1[t]^2)*x1[t], x1[0] == 1,
>>> >   x2[0] == 0}, {x1[t], x2[t]}, {t, 0, 10}]
>>> >
>>> > But I need that the If condition evaluates in each time step. But I
>>> > haven't
>>> > been able to introduce the conditional in the ndsolve statment.
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> DrMajorBob at bigfoot.com
>>>
>>>
>>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: bvdae error when using NDSolve for initial value
  • Next by Date: Re: Re: How can I "perturbate" a NDSolve
  • Previous by thread: Re: Re: Re: How can I "perturbate" a
  • Next by thread: Re: Re: How can I "perturbate" a NDSolve