MathGroup Archive 2009

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102056] Re: [mg102035] Re: [mg102000] How can I "perturbate" a NDSolve
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 28 Jul 2009 02:03:57 -0400 (EDT)
  • References: <200907260754.DAA18931@smc.vnet.net>
  • Reply-to: drmajorbob at bigfoot.com

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


  • Prev by Date: bvdae error when using NDSolve for initial value problem
  • Next by Date: Re: Mathematica Animations by High School Students
  • Previous by thread: Re: How can I "perturbate" a NDSolve expresion?
  • Next by thread: Re: Re: Re: How can I "perturbate" a