MathGroup Archive 1992

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

Search the Archive

Pattern matching with Dt.

  • To: mathgroup at
  • Subject: Pattern matching with Dt.
  • From: Scott Herod <sherod at>
  • Date: Mon, 24 Aug 92 18:43:10 MDT

I have a problem in pattern matching I need to solve.

I have two systems of partial differential equations.  One is general
and of the form

           2       k
F [x,u,Du,D u,...,D u] == 0;  i = 1,..,m.

where x is a vector denoted by (x[1], x[2], ... , x[numind]), and
u is a vector (u1, u2, ... , uj), j = numdep.  (This is only a small
part of some code so I would like to not have to change my notation.)

The other system is more specific.  Each equation is of the form

Sum[xi[k][variables]*Dt[uJ,x[k]], {k,1,numind}] +
	etaJ[variables] == 0,   J=1,...,numdep.

Examples might be

Dt[u1, x[2]] - Dt[u2, x[1]] == 0,
Dt[u2, {x[2],2}] + u1*Dt[u1,x[1]] == 0.         (1)


xi[1][x[1],x[2],u1,u2] * Dt[u1,x[1]] + xi[2][x[1],x[2],u1,u2] * Dt[u1,x[2]] +
	eta1[x[1],x[2],u1,u2]  == 0,

xi[1][x[1],x[2],u1,u2] * Dt[u2,x[1]] + xi[2][x[1],x[2],u1,u2] * Dt[u2,x[2]] +
        eta2[x[1],x[2],u1,u2]  == 0.


What I need to do is solve system (2) for say Dt[_,x[2]] and replace
these terms in system (1).  It is easy to do this only.

For example, the following does this.

Cat[x_,y_] := ToExpression[StringJoin[ToString[x],ToString[y]]];
UnList[{x__}] := Sequence[x];

numdep = 2;
numind = 2;

var = Flatten[{Table[x[i],{i,1,numind}], Table[Cat[u,j],{j,1,numdep}] }]

rhs[i_] := (Cat[eta,i][UnList[var]] - Sum[xi[j][UnList[var]]*
        Dt[Cat[u,i],x[j]], {j,1,numind-1}]) / xi[numdep][UnList[var]];

For[i=1,i<= numdep,i++,
    ru[i] = Dt[Cat[u,i],x[2]] -> rhs[i]

However, I need the rules to also recognize that Dt[u1,x[1],x[2]]
is Dt[ Dt[u1,x[2]] , x[1]] and Dt[u1, {x[2],2}] = Dt[ Dt[u1,x[2]], x[2]].

To extend the problem I need to create these rules for each of the
ui where i = 1, ... , numdep.

I have tried something like

    Dt[a_,b__,x[2]] := Hold[Dt[ Dt[a,x[2]],b]];
    Dt[a_,x[2],z__] := Hold[Dt[ Dt[a,x[2]],z]];
    Dt[a_,b__,x[2],z__] := Hold[Dt[ Dt[a,x[2]],b,z]];
    Dt[a_,{x[2],c_}] := Hold[Dt[ Dt[a,x[2]],{x[2],c-1}]];
    Dt[a_,b__,{x[2],c_}] := Hold[Dt[ Dt[a,x[2]],b,{x[2],c-1}]];
    Dt[a_,{x[2],c_},z__] := Hold[Dt[ Dt[a,x[2]],z,{x[2],c-1}]];
    Dt[a_,b__,{x[2],c_},z__] := Hold[Dt[ Dt[a,x[2]],b,z,{x[2],c-1}]];

But I only want it to convert the derivatives when it sees 
something like Dt[u2,___,x[2],___] not any other derivatives
w.r.t. x[2].

Any suggestions?  I hope this explanation is clear.

Scott Herod
Applied Mathematics
University of Colorado, Boulder
(sherod at

  • Prev by Date: Re: D[myFunc[g[x]]] -> myFunc[D[g[x],x]: How to do in ch
  • Next by Date: Random[]
  • Previous by thread: Re: D[myFunc[g[x]]] -> myFunc[D[g[x],x]: How to do in ch
  • Next by thread: Random[]