# Solving and plotting an ODE in polar coordinates

I'm super new to Mathematica, but it's the software used at my school, and I'm really trying to get better at it. While I'm new to Mathematica, I'm not new to other STEM topics and am doing some research on spinning black holes. I'm doing a presentation in a few weeks and am trying to put together some animations of some plots.

One I'm working on involves integrating and plotting the equation:

$$\dfrac{dr}{d\phi} = \dfrac{(r - M)^2}{r}\sqrt{\dfrac{ r^3}{2M^3} + \dfrac{r}{2M}}$$

The result should look something like the attached image, If anyone could offer me any assistance, I'd really appreciate it.

• As a first step, I would write r as an explicit function of phi (e.g. replace every r with r[phi]). Then find an expression for the derivative r'[phi]. This would give a differential equation, that you might solve analytically with DSolve or numerically with NDSolve. Putting M=1 to normalise your coordinates would probably help. – mikado Apr 24 at 20:32
• For an inflection point $r^2+2 r{'2}= r r^{''}$ holds good. $r^{'}=\frac{dr}{d\phi};$ For constant $M, r_{inflection\, point} /M \approx 2$ Differentiate and verify. The original equation does not tally dimensionally.. so it could be in error – Narasimham Apr 24 at 21:10
• Maybe this GitHub repository is useful to you: github.com/anderote/kerr-solutions (clone it and the open the notebooks from the repository) – Arnoud Buzing Apr 24 at 21:52
• Thank you so much for the responses! @Mikado, isn't the equation itself already a derivative of r with respect to phi? – Nathan June Apr 24 at 22:02
• Welcome to Mathematica.SE, Nathan! I suggest the following: 1) Take the tour and check the faqs. 2) 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! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – Chris K Apr 25 at 11:44

To get a plot like the one you show, I have to correct a sign error in your equation. After doing so, the equation is easily solved with NDSolveValue. Like so.

rF =
NDSolveValue[
{r'[ϕ] == -(r[ϕ] - 1)^2/r[ϕ]/Sqrt Sqrt[r[ϕ]^3 + r[ϕ]], r == 100},
r, {ϕ, 0, 8 π}]

PolarPlot[rF[ϕ], {ϕ, 0, 8 π}, PlotRange -> {{-2, 8}, {-1.5, 1.5}}] ### Update

The following is added to address concerns raised by the OP in a comment to this answer.

Mathematica is has so much stuff in it that it is indeed hard for beginners to find there way around the app. The documentation is quite extensive and there really is a lot of introductory material in it, but again, there is so much of it that it hard for beginners to use it.

I recommend that you begin your further exploration of Mathematica by following this link (or its equivalent in the built-in Documentation Center).

Now let's look into how Manipulate can be used to make a demonstration of a particle moving along the spiral shown in the polar plot. The main point is add an Epilog option to the plot which will draw the moving point.

Manipulate[
PolarPlot[rF[ϕ], {ϕ, 0, 1080 °},
Epilog -> {Red, AbsolutePointSize, Point[rF[Φ °] {Cos[Φ °], Sin[Φ °]}]},
PlotRange -> {{-2, 6}, {-1.5, 1.6}},
PerformanceGoal -> "Quality",
ImageSize -> Medium],
{{Φ, 5, "ϕ (deg)"}, 5, 1080, 5, Appearance -> {"Large", "Labeled"}}] ### Notes

• I have an engineering background, so I like to see polar plots read out in degrees. If I didn't have this prejudice, the demo code could be made a little simpler. If you have a scientific mind, you can simplify the code by removing all references to degrees.
• What looks like a simple slider controling the position of red point is actually an animator control. If you click on the plus ( + ) button at its right end, it will reveal a full set of animation controls. You should also click on the plus button at the top-right of the demonstration panel and see what it reveals.
• The Point graphics primitive in the Epilog specification must be in expressed in Cartesion coordinates. Hence, Point[rF[Φ °] {Cos[Φ °], Sin[Φ °]}]
• The PerformanceGoal option is given to keep the spiral from being distorted when the slider is moving.
• Ahhh! Thank you so much! I hate to be a bother, but is there any way you could explain to me what you did there? I'm sure it's probably so simple to someone who's somewhat familiar with this program, but I just can't seem to find a good place to start learning. I've looked at so many videos online and it just seems like none of them have much to do with what I'm trying to do. Out of all the people I've talked to, all the professors, the fellow students, you've been the first person to be able to tackle this so quickly. Any resources you know of I should be checking out? Thanks again! – Nathan June Apr 25 at 1:06
• And a follow-up question, any chance you could coach me on how to get a point to follow along that path? I know I need to use the manipulate command (or at least I think I do), but I'm not sure how to specify the point's "location". – Nathan June Apr 25 at 1:13
• @NathanJune. I have updated my answer to address the issues you raise in your comments. Also, since you seem to find my answer useful, please consider accepting it. You can do that by clicking on the check mark that appears on the left of the answer below the down arrow. – m_goldberg Apr 25 at 5:02

Putting

$$u= \frac{r}{2M,}$$

we get a long analytic WA solution involving three types of Elliptic Integrals. A numeric solution can be attempted with NDSolve.