MathGroup Archive 2011

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

Search the Archive

Re: NDSolve, three 2-d order ODE, 6 initial conditions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115197] Re: NDSolve, three 2-d order ODE, 6 initial conditions
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 4 Jan 2011 04:24:14 -0500 (EST)

No error here, in version 8.

In any version, there's REALLY no reason to type in d[x[t],t] instead of  
x'[t], D[x[t], {t, 2}] instead of x''[t], or D[x[t], t] /. {t -> 0}  
instead of x'[0]. The long version is what the short one means, so type  
the short one.

Bobby

On Mon, 03 Jan 2011 14:16:31 -0600, michael partensky  
<partensky at gmail.com> wrote:

> *
>
> *
> *On Mon, Jan 3, 2011 at 2:16 PM, DrMajorBob <btreat1 at austin.rr.com>  
> wrote:
> *
>>
>> Perhaps a call to ndSol with some parameters (known only to you) will  
>> cause
>> an error message... but the statement you posted, as it is, gives NO  
>> error
>> message.
>>
>> *Sorry, Bob. The error message came with the evaluation (see below), but
> it was not sensitive to the choice of parameters.
>
> *
>
>> That said, it seems to me that {t, t1} needs replacement with something
>> like {t, t1, t2}, as NDSolve needs lower AND upper limits.
>>
>> *By default, {t,t1} = {t,0,t1} (I checked  it in Help). However, the  
>> later
> version includes*
> *tmin, tmax, and the error message was the same.
>
> *
>
>> {x[t], y[t], z[t]} should be {x, y, z}, since NDSolve will return
>> InterpolatingFunction results, not symbolic ones.
>>
> *Yes, I fixed it. The outcome did not change.  *
>
>>
>> Though it's not necessary, I'd also replace D[x[t], {t, 2}] with x''[t],
>> D[x[t], t] with x'[t], and (D[x[t], t] /. {t -> 0}) with x'[0].
>>
> *I used both. Just thought (apparently it was wrong) that  D[ ] is
>  bullet-proof.*
> *Thanks for the advise.*
>
>>
>> The result is
>>
>> ndSol[w_,w0_,w1_,x0_,y0_,z0_,v0x_,v0y_,v0z_,t1_,t2_]:=NDSolve[{-w Sin[t  
>> w]
>> (x^\[Prime])[t]+w Cos[t w] (y^\[Prime])[t]+Cos[t w]
>> (x^\[Prime]\[Prime])[t]+Sin[t w] (y^\[Prime]\[Prime])[t]==(w-w0) (Sin[t  
>> w]
>> (x^\[Prime])[t]-Cos[t w] (y^\[Prime])[t]),-Sin[t w]
>> (x^\[Prime]\[Prime])[t]+Cos[t w] (y^\[Prime]\[Prime])[t]==(w-w0) (Cos[t  
>> w]
>> (x^\[Prime])[t]+Sin[t w] (y^\[Prime])[t])+w1 (z^\[Prime])[t],0==w1  
>> (Sin[t w]
>> (x^\[Prime])[t]-Cos[t w1]
>> (y^\[Prime])[t]),(x^\[Prime])[0]==v0x,(y^\[Prime])[0]==v0y,(z^\[Prime])[0]==v0z,x[0]==x0,y[0]==y0,z[0]==z0},{x,
>> y, z},{t,t1,t2}];
>>
>> That will fail if w1 == 0, since it causes one of the equations to be
>> trivially True, and the equation is unnecessarily complicated when w1  
>> is NOT
>> zero.
>>
>> In case w1 == 0, z is also uncoupled from x and y, and it will be simply
>>
>> z[t_] = z0 + v0z t
>>
> *Absolutely. This is when the normal (oscillating) magnetic field is  
> absent,
> and the projection on the stationary field (along the  z axis) is  
> conserved.
> I can not ignore w1. Effectively, this is the normal component of B1
> (w1=B1/gamma, denominator being giro-magnetic ratio) rotating with the
> angular frequency w, and it introduces the resonance (unless I screwed  
> the
> equations  up- will check it later) *
>
>>
>> Hence, we could redefine ndSol as:
>>
>> Clear[ndSol]
>>
>> ndSol[w_,w0_,0,x0_,y0_,z0_,v0x_,v0y_,v0z_,t1_,t2_]:=
>> Append[NDSolve[{-w Sin[t w] x'[t]+w Cos[t w] y'[t]+Cos[t w]  
>> x''[t]+Sin[t w]
>> y''[t]==(w-w0) (Sin[t w] x'[t]-Cos[t w] y'[t]),-Sin[t w] x''[t]+Cos[t w]
>> y''[t]==(w-w0) (Cos[t w] x'[t]+Sin[t w]
>> y'[t]),x'[0]==v0x,y'[0]==v0y,x[0]==x0,y[0]==y0},{x,  
>> y},{t,t1,t2}],z->z0+#
>> v0z&]
>>
>> ndSol[w_,w0_,w1_,x0_,y0_,z0_,v0x_,v0y_,v0z_,t1_,t2_]:=NDSolve[{-w Sin[t  
>> w]
>> x'[t]+w Cos[t w] y'[t]+Cos[t w] x''[t]+Sin[t w] y''[t]==(w-w0) (Sin[t w]
>> x'[t]-Cos[t w] y'[t]),-Sin[t w] x''[t]+Cos[t w] y''[t]==(w-w0) (Cos[t w]
>> x'[t]+Sin[t w] y'[t])+w1 (z')[t],0==Sin[t w] x'[t]-Cos[t w1]
>> y'[t],x'[0]==v0x,y'[0]==v0y,(z')[0]==v0z,x[0]==x0,y[0]==y0,z[0]==z0},{x,  
>> y,
>> z},{t,t1,t2}];
>>
>> *Thanks. *
> *My last version was *
> *
> *
> *ndSol[w_, w0_, w1_, x0_, y0_, z0_, v0x_, v0y_, v0z_, t1_, t2_] :=*
> *  NDSolve[{Cos[w t ] D[x[t], {t, 2}] + Sin[ w t] D[y[t], {t, 2}] - w  
> Sin[w
> t] D[x[t], t] + w Cos[w t] D[y[t], t] == (w - w0) ( Sin[w t ] D[x[t], t]  
> -
> Cos[w t] D[y[t], t]),*
> *    -Sin[w t] D[x[t], {t, 2}] + Cos[w t] D[y[t], {t, 2}] == (w - w0)  
> (Cos[w
> t] D[x[t], t] + Sin[w t] D[y[t], t]) + w1 D[z[t], t],*
> *    D[z[t], {t, 2}] == w1 (Sin[w t] D[x[t], t] - Cos[w1 t] D[y[t], t]),
> (D[x[t], t] /. {t -> 0} ) == v0x, (D[y[t], t] /. {t -> 0} ) == v0y,  
> (D[z[t],
> t] /. {t -> 0})  == v0z, x[0] == x0, y[0] == y0, z[0] == z0 }, {x, y, z},
> {t, t1, t2}];*
> *
> *
> *
> *
> *I evaluated it in Mathematica 7.0 with the following parameters
> ndSol[10,10.1,1,0,0,0,1,0,1,0,10]*
> *
> *
> *The message was:*
> NDSolve::ndnco: The number of constraints (6) (initial conditions) is not
> equal to the total differential order of the system (5). >>
> *
> *
> *I just heard from Daniel Lichtblau  that the message from Mathematica  
> 7.1
> was different, and that Mathematica 8. did solve it without troubles.  
> Hence,
> Daniel suggested that this was a bug.*
> *I am surprised by encountering a bug so effortlessly. Previously, the
> errors have always been mine. :) Is it possible that I did introduce and
> error, but Mathematica 8. is simply more flexible in its defaults  
> (functions
> are more "overloaded" bla-bla ?). *
> *What do you think?
>
> Btw, I have just installed M. 8  but did not give it a try yet.*
> *
> *
> *Thanks*
> *Michael*
>
> Whether that is solvable for the parameters you'd like to pass, I can't
>> venture to guess.
>>
>> Bobby
>>
>>
>> On Mon, 03 Jan 2011 02:56:52 -0600, michael partensky  
>> <partensky at gmail.com>
>> wrote:
>>
>>  Hi, group!
>>>
>>> An attempt  to demonstrate a (restricted)  analogy between the Bloch
>>> (magnetic resonance) equation and the motion equation for a charged
>>> particle
>>> in the magnetic field leads to the following equation:
>>>
>>> ndSol[w_, w0_, w1_, x0_, y0_, z0_, v0x_, v0y_, v0z_, t1_] :=
>>>  NDSolve[{Cos[w t ] D[x[t], {t, 2}] + Sin[ w t] D[y[t], {t, 2}] - w  
>>> Sin[w
>>> t] D[x[t], t] + w Cos[w t] D[y[t], t] == (w - w0) ( Sin[w t ] D[x[t],  
>>> t] -
>>> Cos[w t] D[y[t], t]),
>>>    -Sin[w t] D[x[t], {t, 2}] + Cos[w t] D[y[t], {t, 2}] == (w - w0)  
>>> (Cos[w
>>> t] D[x[t], t] + Sin[w t] D[y[t], t]) + w1 D[z[t], t],
>>>    D[z, {t, 2}] == w1 (Sin[w t] D[x[t], t] - Cos[w1 t] D[y[t], t]),
>>> (D[x[t], t] /. {t -> 0} ) == v0x, (D[y[t], t] /. {t -> 0} ) == v0y,
>>> (D[z[t],
>>> t] /. {t -> 0})  == v0z, x[0] == x0, y[0] == y0, z[0] == z0 }, {x[t],
>>> y[t],
>>> z[t]}, {t, t1}];
>>>
>>> Apparently there is an error - u will see the message. Could you please
>>> help
>>>  catching  it?
>>> Thanks
>>> Michael Partenskii
>>>
>>>
>>>
>>
>> --
>> DrMajorBob at yahoo.com
>>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: pattern bugs and comment on intuitive syntax for the New Year
  • Next by Date: AstronomicalData. How can be taken into account when a planet is
  • Previous by thread: Re: NDSolve, three 2-d order ODE, 6 initial conditions
  • Next by thread: Re: NDSolve, three 2-d order ODE, 6 initial conditions