How do I program a partial differential operator to perform both explicit & symbolic differentiations simultaneously?

resolvent's picture

Thank you everyone for all your help.
However, what I am leading up to in my research requires
that I overcome the following hurdle.

Let p[m] represent an unspecified function of three variables,
e1, e2, and e3. (In reality, the explicit formula for the
function is known, but I will not use that formula.)
m is an index. So, p[1], p[2], p[3] etc are different functions of e1, e2, e3.

I need to program an operator, T, which acts on p[m] and
returns - symbolically -
T(p[m]) = 1*e1*diff(p[m],e1) + 2*e2*diff(p[m],e2)
+ 3*e3*diff(p[m],e3)

In case anyone has guessed already, T has gone under such
names as an "Euler" operator.

Then, I need T to be able to act on T(p[m]) and return
T(T(p[m])) = 1^2*e1*diff(p[m],e1) + 2^2*e2*diff(p[m],e2)
+3^3*e3*diff(p[m],e2) + 1*e1*(1*e1*diff(p[m],{e1,2})
+2*e2*diff(p[m],{e1,e2}) + ...) + ...

in other words: when applied the SECOND time, my operator, T,
will perform the EXPLICIT partial differentiation (please correct my Maple terminology - if it's not called "explicit", what word do Maplers use?) upon the e1, e2, e3 but
differentiate p[m] only symbolically?

My SECOND challenge is: program an operator - which is
really the total differential operator, so I will call it
"D", here - such that when I apply D to p[m] I get in return

D(p[m])= diff(p[m],e1)*diff(e1,x) + diff(p[m],e2)*diff(e2,x)
+diff(p[m],e3)*diff(e3,x)

So, D symbolically partially differentiates p[m] with respect
to the e1, e2, e3, and totally differentiates e1, e2, e3
symbolically with respect to x.

I then need to be able to combine T and D. I will apply
T first, and then D. So, for example,
I need to see what
D(T(p[m]) is as a linear combination of
diff(p[m],e1), diff(p[m],e2), diff(p[m],e3),
diff(p[m],{e1,e2}) ...
with coefficients which are polynomials in
e1, e2, e3, diff(e1,x), diff(e2, x), diff(e3,x)
and integers. Thanks

Doug Meade's picture

differentiation operators

This is a problem that I believe Maple can handle with relative ease. I have uploaded my approach as a worksheet:

View 178_TotalDiff.mw on MapleNet or Download 178_TotalDiff.mw

Since some of this requires some explanation, I will also show the code here:

Start by telling Maple that the p's are functions of e1, e2, and e3. This cuts down on input, and output.

restart;
PDEtools:-declare( seq( p(e1,e2,e3), m=1..3 ) );
                  p(e1, e2, e3) will now be displayed as p
alias( seq(p[m]=p[m](e1,e2,e3),m=1..3 ) );

Now, for the T operator. This is pretty straightforward. I added the collect on diff to help organize the output. (If you want the output in a different form, you might need to replace the -> form with a formal proc.)

T := f -> collect( add( i*e||i*diff(f,e||i), i=1..3 ), diff );

Here are two tests of this operator (the output is much nicer in 2D in the worksheet):

T(p[1]);
             / d                   \        / d                   \
          e1 |---- p[1](e1, e2, e3)| + 2 e2 |---- p[1](e1, e2, e3)|
             \ de1                 /        \ de2                 /

                    / d                   \
             + 3 e3 |---- p[1](e1, e2, e3)|
                    \ de3                 /
T(T(p[1]));
      / d                   \        / d                   \
   e1 |---- p[1](e1, e2, e3)| + 4 e2 |---- p[1](e1, e2, e3)|
      \ de1                 /        \ de2                 /

             / d                   \     2 / d   / d                   \\
      + 9 e3 |---- p[1](e1, e2, e3)| + e1  |---- |---- p[1](e1, e2, e3)||
             \ de3                 /       \ de1 \ de1                 //

                / d   / d                   \\
      + 4 e1 e2 |---- |---- p[1](e1, e2, e3)||
                \ de2 \ de1                 //

                / d   / d                   \\
      + 6 e1 e3 |---- |---- p[1](e1, e2, e3)||
                \ de3 \ de1                 //

            2 / d   / d                   \\
      + 4 e2  |---- |---- p[1](e1, e2, e3)||
              \ de2 \ de2                 //

                 / d   / d                   \\
      + 12 e2 e3 |---- |---- p[1](e1, e2, e3)||
                 \ de3 \ de2                 //

            2 / d   / d                   \\
      + 9 e3  |---- |---- p[1](e1, e2, e3)||
              \ de3 \ de3                 //

We turn now to the total derivative operator. I will not use D ad Maple already defines this as a builtin differentiation operator. The only real trick here is to explicitly replace each ei with ei(x) before taking the derivatives. Once again, collecting on diff helps to put the output in a form that highlights the linearity in the derivatives.

Dtot := f -> collect( diff(eval(f,[seq(e||i=e||i(x),i=1..3)]),x), diff );

To suppress the dependence on x in the output, we use:

alias( seq(e||i=e||i(x),i=1..3) );

This generates 9 warning messages, 1 for each of the three variables, ei, for the three functions p[m].

And, now, some tests, with the disclaimer that the output is much more pleasing in the worksheet:

Dtot(p[1]);
                             / d    \                          / d    \
      D[1](p[1])(e1, e2, e3) |--- e1| + D[2](p[1])(e1, e2, e3) |--- e2|
                             \ dx   /                          \ dx   /

                                  / d    \
         + D[3](p[1])(e1, e2, e3) |--- e3|
                                  \ dx   /

Dtot(T(p[1]));
(D[1](p[1])(e1, e2, e3) + 2 e2 D[1, 2](p[1])(e1, e2, e3)

                                                                    / d    \   
   + e1 D[1, 1](p[1])(e1, e2, e3) + 3 e3 D[1, 3](p[1])(e1, e2, e3)) |--- e1| + 
                                                                    \ dx   /   

  (2 e2 D[2, 2](p[1])(e1, e2, e3) + e1 D[1, 2](p[1])(e1, e2, e3)

                                                                / d    \      
   + 2 D[2](p[1])(e1, e2, e3) + 3 e3 D[2, 3](p[1])(e1, e2, e3)) |--- e2| + (2 
                                                                \ dx   /      

  e2 D[2, 3](p[1])(e1, e2, e3) + e1 D[1, 3](p[1])(e1, e2, e3)

                                                                / d    \
   + 3 D[3](p[1])(e1, e2, e3) + 3 e3 D[3, 3](p[1])(e1, e2, e3)) |--- e3|
                                                                \ dx   /

Did I come close to the functionality you requested?

Doug

---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}