Re: Re: Re: How can I "perturbate" a
- To: mathgroup at smc.vnet.net
- Subject: [mg102068] Re: [mg102056] Re: [mg102035] Re: [mg102000] How can I "perturbate" a
- From: Pratip Chakraborty <pratip.chakraborty at gmail.com>
- Date: Wed, 29 Jul 2009 05:05:15 -0400 (EDT)
- References: <200907260754.DAA18931@smc.vnet.net>
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=E1n 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
>>
>>
>
- References:
- How can I "perturbate" a NDSolve expresion?
- From: Iván Lazaro <gaminster@gmail.com>
- How can I "perturbate" a NDSolve expresion?