2
$\begingroup$

I have an expression $$\dot{r}\dot{\eta}+r^{2}\dot{\theta}\dot{\xi}=0$$ where $\eta$ and $\xi$ are both functions of $r,\theta$. In MM I wrote this as

de = Dt[r, t] Dt[eta[r, th], t] + r^2 Dt[th, t] Dt[xi[r, th], t]

What I wish to do now is solve this equation by separating it into a set of PDEs for each power of $\dot{r}, \dot{\theta}$ and then integrating each to find the functions $\xi,\eta$. What I need is an equivalent of CoefficientArrays for each power of the co-ordinate derivatives.

For instance, the $\dot{r}\dot{\theta}$ term would be $$ \eta_{\theta} +r^2\xi_r$$ where the subscript denotes partial differentiation. Is there a way to do this? I tried the linked answer but couldn't get it to work for my purposes. Thank you!

EDIT: The answer provided by @kglr works perfectly! Simply Normal@Rest@CoefficientArrays[de, {Dt[r, t] , Dt[th, t]}] which for some reason I couldn't get to work.

As an extension to this problem, what happens if xi and eta are also functions of Dt[r,t] and Dt[th,t]? Now coefficient array returns the error "not a polynomial" because it is trying to pattern match inside the functions when I don't want it to. Any ideas?

P.S the Dt[r,{t,2}] and Dt[th,{t,2}] terms that result can be ignored because in practise they are replaced by their respective equations of motion which are functions of Dt[r,t] and Dt[th,t]. For all intents and purposes we can simply use a replace rule to set Dt[r,{t,2}] and Dt[th,{t,2}] equal to 0.

$\endgroup$
3
  • 1
    $\begingroup$ Normal@Rest@CoefficientArrays[de, {Dt[r, t] , Dt[th, t]}]? $\endgroup$
    – kglr
    Aug 7, 2019 at 17:42
  • $\begingroup$ .. or Normal@Rest@ CoefficientArrays[de, {Dt[r, t] , Dt[th, t], Dt[eta, t], Dt[xi, t]}]? $\endgroup$
    – kglr
    Aug 7, 2019 at 17:43
  • $\begingroup$ @kglr That seems to work! I have no idea why what I was doing before didn't... Anyway I am going to extend this question a bit: What happens if xi and eta are also functions of Dt[r,t] and Dt[th,t]? Now coefficient array returns the error "not a polynomial" because it is trying to pattern match inside the functions when I don't want it to. Any ideas? I will edit my question with your answer and this followup. $\endgroup$
    – Takoda
    Aug 8, 2019 at 8:31

2 Answers 2

2
$\begingroup$

The answer is to use CoefficientList.

CoefficientList[de, {Dt[r, t], Dt[th, t]}] //ColumnForm

gives the associated PDEs in each power of your co-ordinate velocities. Then all you need to do is Flatten and DeleteCases of 0 and you get a system of PDEs that you can solve.

DeleteCases[CoefficientList[de, {Dt[r, t], Dt[th, t]}], 0, Infinity] // Flatten
$\endgroup$
2
$\begingroup$

Re:

As an extension to this problem, what happens if xi and eta are also functions of Dt[r,t] and Dt[th,t]?

I take this to mean:

de = Dt[r, t] Dt[eta[r, th, Dt[r, t], Dt[th, t]], t] + 
  r^2 Dt[th, t] Dt[xi[r, th, Dt[r, t], Dt[th, t]], t]

The expression Dt[r, t] as an argument to eta etc. means de is not a polynomial in Dt[r, t]. Interpreting the OP's intention to be to treat the derivatives of eta[r, th, Dt[r, t], Dt[th, t]] as independent of Dt[r, t] for the purposes of treating de as a polynomial in Dt[r, t] and Dt[th, t], the easiest approach seems to be to replace the arguments of eta and xi by new temporary, independent variables, get the coefficient, and then back substitute the original arguments for the temporary variables:

Block[{f},
 vars = List @@ eta[r, th, Dt[r, t], Dt[th, t]];
 tempvars = Unique["vars", Temporary] & /@ vars;
 vars2temp = Pattern[f, Blank[]] @@ vars :> Evaluate[f @@ tempvars];
 temp2vars = Pattern[f, Blank[]] @@ tempvars :> Evaluate[f @@ vars];
 ]

If you want all derivatives of r and th to be treated as variables in de:

ca = Normal@CoefficientArrays[de /. vars2temp, Dt[vars, t]] /. 
  temp2vars

But the OP said that only the first derivatives are to be considered variables in de:

ca = Normal@CoefficientArrays[de /. vars2temp, Dt[{r, th}, t]] /. 
  temp2vars
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.