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

• To: mathgroup at smc.vnet.net
• Subject: [mg102066] Re: [mg102035] Re: [mg102000] How can I "perturbate" a NDSolve
• From: DrMajorBob <btreat1 at austin.rr.com>
• Date: Wed, 29 Jul 2009 05:04:52 -0400 (EDT)
• References: <200907260754.DAA18931@smc.vnet.net>

```BTW, the perturbation (at that probability) makes virtually no difference
because, for instance, after running the code,

DownValues[a][[All, -1]]
Length@%

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

180

That is, a was called 180 times, and all the results were zero.

When I change the probability to 0.1, there are lots more a values and

DownValues[a][[All, -1]];
Length@%
Length@DeleteCases[%%, 0]

2100

208

...but there's no visible difference in the plot! (Interpolations are
being used, and that smoothes everything.)

There's a critical point around p = 0.17 or 0.18, where NDSolve begins to
give error messages and the plot changes radically.

Bobby

On Tue, 28 Jul 2009 00:18:39 -0500, 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:
>
>>
>> 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

```

• Prev by Date: Re: Re: Re: How can I "perturbate" a
• Next by Date: Re: Re: The audience for Mathematica (Was: Re: Show doesn't work inside
• Previous by thread: Re: Re: Re: How can I "perturbate" a
• Next by thread: Re: Re: Re: Re: How can I