# Computation of photon trajectory near a black hole [closed]

I've been given the task to represent the trajectory of a photon near a Schwarzschild Black hole. I've read the physics behind it, and I've derived the equation of photon orbit near a schwarzschild black hole, i.e.,

$$\left(\frac{{\rm d}r}{{\rm d}\lambda}\right)^2=E^2 − \left(1−\frac{2M}{r}\right)\left(\frac{L}{r}\right)^2,$$ and only the representation part is left. I'm not very good with coding and I'm not sure how to do it.

## closed as off-topic by John Rennie, ACuriousMind♦, Diracology, CuriousOne, user36790 Jul 8 '16 at 4:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – John Rennie, ACuriousMind, Diracology, CuriousOne, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

It appears that you've already found this question:

Computing the path of photons near a black hole

In which you're given the following equation for the photon orbit:

$$\left(\frac {dr}{d\lambda}\right)^2 = E^2 - \left(1 - \frac {2M}{r}\right) \frac {L^2}{r^2}$$

where the terms are defined in the link.

This tells you how the orbital radius varies with respect to the affine parameter. The angular coordinate also evolves according to

$$\frac{d\phi}{d\lambda} = \frac{L}{r^2}$$

So the simplest way to numerically integrate these equations is to start off with a pair $(r_0,\phi_0)$, and then use the Euler forward method to advance 'time' by a small step $\Delta\lambda$:

\begin{align} r_{n+1} &= r_n + \Delta\lambda \frac{dr}{d\lambda}\big|_n\\ \phi_{n+1} &= \phi_n + \Delta\lambda \frac{d\phi}{d\lambda}\big|_n \end{align}

where you evaluate the derivatives using the above equations. Then repeat ad infinitum.

• I can easily evaluate the derivative, but how can I represent the orbit,(in 2D or 3D) that is my main problem. Calculation is not the trouble. How should I write a program to represent the orbit? and with which coding language? – Aakanksha Agarwal Jul 7 '16 at 12:33
• @AakankshaAgarwal What do you mean by 'represent'? You have the $(r,\phi)$ coordinates, what more do you want? – lemon Jul 7 '16 at 12:34
• How should I write a program to represent the orbit? and with which coding language? – Aakanksha Agarwal Jul 7 '16 at 12:37
• I'll try once and get back to you if I face some problem. – Aakanksha Agarwal Jul 7 '16 at 12:43
• @AakankshaAgarwal Firstly, you need to figure out the units. The above equations have assumed that $G=c=1$, so you need to pick consistent length and time units. – lemon Jul 10 '16 at 11:29