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}
  • $\begingroup$ 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! $\endgroup$ – Michael E2 Mar 7 '16 at 12:44
  • $\begingroup$ 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 $\endgroup$ – Michael E2 Mar 7 '16 at 12:46
  • $\begingroup$ Do you know about DSolve and NDSolve? $\endgroup$ – Michael E2 Mar 7 '16 at 12:48
  • $\begingroup$ @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. $\endgroup$ – siddhesh Mar 7 '16 at 13:20
  • $\begingroup$ This is related Working with a system of differential equations that cannot be solved explicitly $\endgroup$ – 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:

enter image description here

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!

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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