Defining rules seems to be quite troublesome, because whatever rule I make has to have the exact syntax ordering of the expression I want to modify.
For example,
take this differential form
(Dt[t2 t3]) . (Dt[t1 t3]) . (Dt[t1 t2])
expr = Distribute[%, Plus, Dot]
(I used Dothere rather than Wedgebecause I thought Mathematica would have more inbuilt rules to help simplify it.):
This returns:
(t3 Dt[t2]) . (t3 Dt[t1]) . (t2 Dt[t1]) + (t3 Dt[t2]) . (t3 Dt[
t1]) . (t1 Dt[t2]) + (t3 Dt[t2]) . (t1 Dt[t3]) . (t2 Dt[
t1]) + (t3 Dt[t2]) . (t1 Dt[t3]) . (t1 Dt[t2]) + (t2 Dt[
t3]) . (t3 Dt[t1]) . (t2 Dt[t1]) + (t2 Dt[t3]) . (t3 Dt[
t1]) . (t1 Dt[t2]) + (t2 Dt[t3]) . (t1 Dt[t3]) . (t2 Dt[
t1]) + (t2 Dt[t3]) . (t1 Dt[t3]) . (t1 Dt[t2])
Then I want to define a rule to make the t's factor out. Naively I'd want to do something like:
Simplify[%, ( a_ Dt[b_]) . (c_ Dt[d_]) == a c (Dt[b_] . Dt[d_])]
Unfortunately that doesn't work, so instead I had to examine FullForm[expr] while repeatedly making new rules trying to match parts of the expression. The list of rules I ended up creating were:
% //. Dot[x_, y_*z_Dt] :> y (x . z)
% //. Dot[t_ * dot_Dot, other___] :> t Dot[dot, other]
% //. Dot[y_*z_Dt, other___] :> y Dot[z, other]
Which eventually managed to factor out the t's as I wanted. i.e. it returned:
t2 t3^2 Dt[t2] . Dt[t1] . Dt[t1] + t1 t3^2 Dt[t2] . Dt[t1] . Dt[t2] +
t1 t2 t3 Dt[t2] . Dt[t3] . Dt[t1] +
t1^2 t3 Dt[t2] . Dt[t3] . Dt[t2] + t2^2 t3 Dt[t3] . Dt[t1] . Dt[t1] +
t1 t2 t3 Dt[t3] . Dt[t1] . Dt[t2] +
t1 t2^2 Dt[t3] . Dt[t3] . Dt[t1] + t1^2 t2 Dt[t3] . Dt[t3] . Dt[t2]
Continued Example
Then I wanted to make a rule to make repeated differentials 0. Such as $dx*dy*dx = 0$ because dx is repeated.
Here's my naive code:
% //. Dot[ ___, Dt[x_], ___, Dt[x_], ___ ] -> 0
Which did nothing.
Finally I gave up and deleted terms by hand:
t1 t2 t3 Dt[t2] . Dt[t3] . Dt[t1] + t1 t2 t3 Dt[t3] . Dt[t1] . Dt[t2];
Questions
I realize there's packages out there that do differential forms, (and I would be open to hearing suggestions about which ones are good. However, my question is how I would be able to make rules like this, because in other settings, there may not be a package that does what I want.
- How would I define rules like this that work without being so picky about the exact syntax of FullForm[expr]
- How would I do this with other techniques? Can I get a simplify with assumptions to work?