# How to eliminate an independent variable from two coupled differential equations?

I want to solve following differential equations using mathematica (I know the solution as it is easy to compute): $$\dot{r}^2+r^2\dot{u}^2=2\kappa^2\frac{1}{r}+h,$$ $$r^2\dot{u}=c.$$ To computer the solution we substitute second equation in the first and then eliminate the time variable from these equations using, $$\dot{r}=\frac{dr}{du}\frac{du}{dt}=\frac{dr}{du}cr^{-2}.$$ Substituting this we get $$\left(\frac{dr}{du}\right)^2\frac{c^2}{r^4}+r^2\frac{c^2}{r^4}=2\kappa^2\frac{1}{r}+h.$$ Can someone please show me how to do this using mathematica?

I have tried following things, but that didn't work:

expr = r'[t]^2 + r[t]^2 u'[t]^2 - 2 κ^2/r[t] - h

expr1 = expr /. r -> (r[u[#]] &)

expr2 = Eliminate[{expr1 == 0, u'[t] == c r[u[t]]^-2}, u'[t]]

expr3 = expr2 /. {r'[u[t]] -> c r[u[t]]^-2 r'[u[t], u[t]], u'[t] -> c r[u[t]]^-2}

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Mar 7 '16 at 12:44
• You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful – Michael E2 Mar 7 '16 at 12:46
• Do you know about DSolve and NDSolve? – Michael E2 Mar 7 '16 at 12:48
• @michael-e2 I know about DSolve and NDSolve. But to solve this question further I have to do another change of variable. Therefore I'm not using them. – siddhesh Mar 7 '16 at 13:20
• – Artes Mar 7 '16 at 13:27

What do you want us to show you is not quite clear. I understand your question is the following way: "How to make within Mma the same steps you have done on the paper?" Is that right? If yes, the answer is as follows.

This is the left-hand part of your first equation:

expr1 = r'[t]^2 + r[t]^2 u'[t]^2 - 2 \[Kappa]^2/r[t] - h


Let us substitute your second expression into it. You might use Eliminate, but in this simple case substitution is easier:

    expr2 = expr1 /. u'[t] -> c/r[t]^2
(*  -h + c^2/r[t]^2 - (2 \[Kappa]^2)/r[t] + Derivative[1][r][t]^2  *)


Now, you replace the derivative by your third equation, and r[t] replace by r[u]. Let us do it:

 expr3 = expr2 /. {r[t] -> r[u], r'[t] -> r'[u]*c/r[u]^2}

(*  -h + c^2/r[u]^2 - (2 \[Kappa]^2)/r[u] + (c^2 Derivative[1][r][u]^2)/
r[u]^4  *)


That's all. Here is your equation:

Then you can solve it using DSolve. You could have done this from the very beginning without transformations though. The solution is not very comfortable, but one can use it in several ways.

Have fun!

• Thanks @Alexei. That was very simple indeed. – siddhesh Mar 7 '16 at 14:18