[Date Index]
[Thread Index]
[Author Index]
Re: Re: Diff. Equations with "Changeable" Parameters
*To*: mathgroup at smc.vnet.net
*Subject*: [mg51712] Re: [mg51693] Re: Diff. Equations with "Changeable" Parameters
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Sat, 30 Oct 2004 03:47:56 -0400 (EDT)
*References*: <clpsou$abt$1@smc.vnet.net> <200410290739.DAA03443@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
This does not do what you think it does. All you are doing is simply
solving the differential equation with f givne by your third
definition:
f[x_, y_] := x + Sin[t] + 2*y.
Your idea, however, is correct, but you need to use the correct syntaxt
for a conditional definition of a function. The following does
essetnially what you intended to do:
(f[x_, y_, t_] /; -1 < y &&
y < 1 := x + Sin[t] + 1*y)*
(f[x_, y_, t_] /; y <= -1 :=
x + Sin[t] + 0*y; )*
(f[x_, y_, t_] /; 1 <= y :=
x + Sin[t] + 2*y)
{f, g} = Flatten[{x, y} /.
NDSolve[{Derivative[1][x][
t] == y[t],
Derivative[1][y][t] ==
f[x[t], y[t], t],
y[0] == 0, x[0] == 0},
{x, y}, {t, 0, 2*Pi}]]
{InterpolatingFunction[],
InterpolatingFunction[]}
Plot[{f[t],g[t]},{t,0,2Pi}]
You can check that this gives the same pair of solutions as given by
Curt Fisher's method (using Unitstep).
Andrzej Kozlowski
Chiba, Japan
http://www.akikoz.net/~andrzej/
http://www.mimuw.edu.pl/~akoz/
On 29 Oct 2004, at 16:39, Peter Valko wrote:
> You need an initial condition for x as well.
> Then a right hand side function definition is handy:
>
> f[x_, y_] := x + Sin[t] + 1*y; -1 < y && y < 1;
> f[x_, y_] := x + Sin[t] + 0*y; y <= -1;
> f[x_, y_] := x + Sin[t] + 2*y; 1 <= y;
>
> NDSolve[{x'[t] == y[t], y'[t] == f[x[t], y[t]],
> y[0] == 0, x[0] == 0}, {x[t], y[t]}, {t, 0, 2Pi}]
>
> The result will be:
> {{x[t] -> InterpolatingFunction[{{0., 6.28319}}, <>][t],
> y[t] -> InterpolatingFunction[{{0., 6.28319}}, <>][t]}}
>
> Regards
> Peter
>
> "Krunom Ilicevic" <krunom at hotmail.com> wrote in message
> news:<clpsou$abt$1 at smc.vnet.net>...
>> 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?
>>
>>
>>
>> Thanks.
>
>
Prev by Date:
**Re: bimodal ditribution form counting signs of Pi digits differences**
Next by Date:
**Re: More on Delete Problems**
Previous by thread:
**Re: Diff. Equations with "Changeable" Parameters**
Next by thread:
**Re: Re: Diff. Equations with "Changeable" Parameters**
| |