       Re: NDSolve problem

• To: mathgroup at smc.vnet.net
• Subject: [mg101688] Re: [mg101657] NDSolve problem
• From: "Elton Kurt TeKolste" <tekolste at fastmail.us>
• Date: Tue, 14 Jul 2009 05:37:00 -0400 (EDT)
• References: <200907121058.GAA19030@smc.vnet.net>

```Haibo

I have placed the Mathematica notebook corresponding to this reply at

under the name NDSolve

**************************************************
You are trying to access the elements of a list when you have no list.
For example, e1[t] is undefined:

e1[t]
e1[t]
so it is possible to do only symbolic manipulations on e1[t].  Since
e1[t] is an undefined function, its zeroth part is the head (function
name) and its first part is the dummy variable (t):
{Part[e1[t],0],Part[e1[t],1]}
{e1,t}
Or, equivalently
{e1[t][],e1[t][]}
{e1,t}
But e1[t] has no second part
e1[t][]
Part::partw: Part 2 of e1[t] does not exist. >>
e1[t][]
So you get an error message from the attempt to access e1[t] in the
execution of the function EE.

You must explicity, if symbolically, define the components of e1[t].
for example
e1[t]:=Table[Subscript[e1, i][t],{i,4}]
Then
EE[e1[t]]//MatrixForm
(Subscript[e1, 2][t]/2  Subscript[e1, 3][t]/2   Subscript[e1, 4][t]/2
1/2 (1-Subscript[e1, 1][t])     -(1/2) Subscript[e1, 4][t]
Subscript[e1, 3][t]/2
Subscript[e1, 4][t]/2   1/2 (1-Subscript[e1, 1][t])     -(1/2)
Subscript[e1, 2][t]
-(1/2) Subscript[e1, 3][t]      Subscript[e1, 2][t]/2   1/2
(1-Subscript[e1, 1][t])

)
Unfortunately, fixing this only reveals another problem:
NDSolve[{J.e2'[t]==-kq Transpose[EE[e1[t]]].e1[t]-komega
(IdentityMatrix+4
Transpose[G[e1[t]]]).\[CurlyTheta][t]-(J.S[e2[t]+\[Omega][t]].(e2[t]+\[Omega][t])+S[e2[t]+\[Omega][t]].J.(e2[t]+\[Omega][t])),\[CurlyTheta]'[t]==-a
\[CurlyTheta][t]+b (1/4
IdentityMatrix+G[e1[t]]).e2[t],e1'[t]==EE[e1[t]].e2[t],e1=={1+0.3772,-0.4329,0.6645,0.4783},\[CurlyTheta]=={0.3,0.4,0.2},e2=={0.1,0.2,0.3}},{e1,\[CurlyTheta],e2},{t,0,500}]

NDSolve::dvnoarg: The function e1 appears with no arguments. >>
It seems that you are integrating over e1, which does not feel
consistent with definition of e1[t] as a 4-vector.

At this point I find your symbolism too obscure to be able to puzzle out
your intention.  Do you mean functions (e1[t_],  e2[t_],...), vectors
(e1 = {e1[],e1[],...}), a vcctor-valued function (e1[t] =
{Subscript[e1, 1][t], Subscript[e1, 2][t], ...}), or something else?
I cannot find an example in which the arguments of NDSolve are
vector-valued functions.  In fact, a short experiment reveals that you
cannot define boundary conditions as vectors:
e1[t]
{Subscript[e1, 1][t],Subscript[e1, 2][t],Subscript[e1,
3][t],Subscript[e1, 4][t]}
e1=Range
{1,2,3,4}
Subscript[e1, 1]
Subscript[e1, 1]
e1
{1,2,3,4}
I conclude that it will be necessary to specifiy the boundary conditions
on the components of e1 separately.

On Sun, 12 Jul 2009 02:58 -0400, "Haibo Min" <haibo.min at gmail.com>
wrote:
> Hi, there.
> These days, I am using mathematica to conduct a simulation which is
> composed
> of a set of matrix ODEs. Maybe there is something wrong in my function
> definition or the usage of NDSolve, when implementing the NDSolve
> function,
> it always tells me that some part of my variables do not exist! I am
> really
> puzzled by this. Since the simulation program is pretty short. I paste
> the
>
>
> S[Px_] := ( {
>     {0, -Px[], Px[]},
>     {Px[], 0, -Px[]},
>     {-Px[], Px[], 0}
>    } );
> EE[err_] := 1/2 ( {
>      {err[], err[], err[]},
>      {1 - err[], -err[], err[]},
>      {err[], 1 - err[], -err[]},
>      {-err[], err[], 1 - err[]}
>     } );
> G[e_] := 1/2 ( {
>       {1 - e[], -e[], e[]},
>       {e[], 1 - e[], -e[]},
>       {-e[], e[], 1 - e[]}
>      } ) - 1/4 IdentityMatrix;
> J = ( {
>     {4.35, 0, 0},
>     {0, 4.337, 0},
>     {0, 0, 3.664}
>    } );
> T = 5000; c = \[Pi]/T;
> \[Omega][t_] := 1/5 {-5 cSin[2 ct], 8 cSin[4 ct], 4 cSin[2 ct]};
> kq = 1.2; komega = 4; a = 5; b = 20;
>
> NDSolve[{J.e2'[t] == -kq Transpose[EE[e1[t]]].e1[t] -
>     komega (IdentityMatrix + 4 Transpose[G[e1[t]]]).\[CurlyTheta][
>        t] - (J.S[e2[t] + \[Omega][t]].(e2[t] + \[Omega][t]) +
>       S[e2[t] + \[Omega][t]].J.(e2[t] + \[Omega][t])), \[CurlyTheta]'[
>     t] == -a \[CurlyTheta][t] +
>     b (1/4 IdentityMatrix + G[e1[t]]).e2[t],
>   e1'[t] == EE[e1[t]].e2[t],
>   e1 == {1 + 0.3772, -0.4329, 0.6645, 0.4783}, \[CurlyTheta][
>     0] == {0.3, 0.4, 0.2},
>   e2 == {0.1, 0.2, 0.3}}, {e1, \[CurlyTheta], e2}, {t, 0, 500}]
>
>
> When evaluating the above code, error occurs:
> Part::partw: Part 2 of e1[t] does not exist. >>
> Part::partw: Part 3 of e1[t] does not exist. >>
> Part::partw: Part 4 of e1[t] does not exist. >>
>
> It seems that mathematica does not know what e1 is since e1 is also a
> parameter of EE and G, which are included in the ODE equation. Does that
> mean that I have to give a definition of e1? But if so, it still doesn't
> make sense in the NDSolve function...
>
>
> Any suggestion will be appreciated.
>
> Best regards,
>
> Haibo
>
>

```

• Prev by Date: Re: ColorFunction and question about how to use it
• Next by Date: Re: Add syntax highlighting to own command
• Previous by thread: NDSolve problem
• Next by thread: Re: Re: NDSolve problem