MathGroup Archive 2004

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

Search the Archive

Re: Diff. Equations with "Changeable" Parameters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51701] Re: Diff. Equations with "Changeable" Parameters
  • From: Curt Fischer <crf3 at po.cwru.edu>
  • Date: Fri, 29 Oct 2004 03:40:05 -0400 (EDT)
  • References: <clpsou$abt$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Krunom Ilicevic wrote:
> I have solved diff. equations in this kind of a way:
> 
> NDSolve[{x'[t]=y[t],y[0]=0}, {y'[t]=x+Sin[t]+c*y[t]},{x,y},{t,0,2Pi}]
> 
> and parameter c was 1, but how to write this algorithm if c is:
> 
> c=0, if y<=-1
> 
> c=1, if -1<y<1
> 
> c=2, if y>=1
> 
> How to include this variable parameter c in my NDSolve method?

You used single equals "=" rather than the double equals "==" that 
Mathematica expects when using NDSolve.

The answer to your question is to use UnitStep.

varCsoln = NDSolve[{x'[t] == y[t], y[
     0] == 0, y'[t] == x[t] + Sin[t] + (UnitStep[y[t] + 1] +
        UnitStep[y[t] - 1])*y[t], x[0] == 0}, {x[t], y[t]}, {t, 0, 2Pi}]

-- 
Curt Fischer


  • Prev by Date: Re: Matrix Problem
  • Next by Date: bimodal ditribution form counting signs of Pi digits differences
  • Previous by thread: Re: Diff. Equations with "Changeable" Parameters
  • Next by thread: Re: Diff. Equations with "Changeable" Parameters