Subtitles section Play video Print subtitles (bell rings) - Hello and welcome to a black hole coding challenge. Time has really slowed down for me, or maybe it's sped up. I can't remember which is which because I'm actually now recording this many days after the actual livestreamed coding challenge. In a little bit, I will change my clothes and travel into the past through the black hole. I don't know how it's all going to work, but you will see me live coding, writing the code to do this simulation. In truth, it's less simulation than visualization. On April 10th, the first ever image of a black hole was published. This image was put together by a team of scientists known at the Event Horizon Telescope. It was compiled from data from many telescopes all over the Earth all synchronized. I looked at this image and I thought, it looks kind of fuzzy and glowy and maybe there's some way I could reproduce this image through a simulation. I started to sort of dig into this. I quickly realized I'm many, many steps away from doing that and I wanted to find the place to start, somewhere where I could at least begin to simulate or visualize the behavior of space time and black holes. Here are the resources that I used to learn about this. First, let me thank Veritasium's video, the how to understand the image of a black hole. This video was actually published the day before the image was revealed, which is really kind of amazing. If you watch this video, the explanation is superb. In particular, there's a short animation in the video that depicted beams of light traveling towards the black hole, some disappearing into the black hole, some wrapping around in an orbit. That's my starting point where I was interested in. I also learned quite a bit from Chris Orbin and the STEM Coding YouTube channel. STEM Coding, if you're not familiar with that YouTube channel, you should definitely check it out. They have a lot of videos about physics and science taught through the lens of coding and visualization. In particular, they have a video called Slingshot with Gravity and Chris Orbun published an article explaining how that code example could be tweaked a little bit to kind of get at some of the ideas around how gravity and black holes. Finally, there's a wonderful paper from 1978. Thank you to Veritasium also for this reference called Image of a Spherical Black Hole with Thin Accretion Disk. This paper has diagrams and the mathematics behind the photon trajectories around a black hole. It gives you a lot of background into what you would want to do to visualize a black hole. Of course, I'm not the first one to try this. Many people have made beautiful visualizations and artistic renderings of black holes. There's the one that you might remember from the move Interstellar. Kip Thorn, a Caltech physicist, was actually an advisor on that film, but there's a lot of artistic license there. I also want to point out to you Ricardo Antonelli who's written this wonderful article How to Draw a Black Hole, Geodesic Raytracing in Curved Space Time. In the article he goes through step-by-step a bunch of different computer graphic tricks and techniques along with the sort of physics of black holes themselves to create a 3D visual of what a black hole might look like. If you've watched me before, you know I am not a physicist, I'm not a scientist. There are many caveats. I don't play a physicist on YouTube. I'm just here wanting to make something in 2D Canvas JavaScript. In fact, I already did it. What I'm here right now, let me talk to you about the pieces that I want to put in this visualization as a sort of reference point for when I start coding. The black hole that I want to visualize is in the galaxy M87. It previously didn't have a name. It was just called M87 star, the star for black hole, but it was recently named Powehi. I'm not sure if I'm pronouncing that correctly, but it is from a Hawaiian chant and it means something like adorn, dark, fathomless creation, something like that. Very appropriate for a black hole. This is what's known as a super massive black hole. Not all black holes are super massive, but this one is and its mass is equivalent to 2.6 billion solar masses, or suns. Take the sun, our sun, the one up in the sky that shines on us, and put together 2.6 billion of those and you have a black hole. It's so massive, we can't see it. Why? Because the gravitational pull is so strong, there's so much matter in there, that any light traveling towards it, once it gets to a certain proximity, can no longer escape. You couldn't be inside the black hole and shine a flashlight. You could be there, but outside the black hole, you couldn't see it 'cause the light can't get out. Of course, you couldn't also be there because you would be dead, very, very dead in the black hole, or you'd just be like Matthew McConaughey, one or the other is true. This little ring here, this distance from the center of black hole at which nothing can escape, not even light, not even the fastest thing we know about light can escape, is known as the event horizon. There's actually a formula for calculating the distance from the center of black hole to that event horizon itself, the Schwarzschild radius, or R sub S. The Schwarzschild radius is calculated as two times G, the universal gravitational constant, times M, the mass of the black hole itself, remember, 2.6 billion solar masses, divided by C squared where C is the speed of light. Of course, the event horizon isn't really a circle. It's a sphere, but for us in our 2D simulation, we're going to make it flat. In order to actually calculate this, I need some of these values. I have the mass, I also need C, the speed of light, which I'm looking over there, I don't have this memorized, which is 299,792,458 meters per seconds squared. That's very, very fast. Not seconds squared. I don't know why I put seconds squared there. It's just meters per second. This number, meters per second. That's the speed of light. I also need G, the universal gravitational constant, which is 6.67 times 10 to the negative 11th power. Now, with these values, with the mass of the black hole, with the universal gravitational constant, with the speed of light, you can actually calculate this. I will leave that to you to calculate and leave your answer in the comments, or you could probably looks it up because people are calculating this stuff all the time. Another element that I want to include in my visualization is the accretion disk. The accretion disk is a whole lot of matter that's outside of the event horizon orbiting the black hole and sort of feeding the black hole. This is a particularly active one. Again, a black hole isn't emptiness. It's we think of it as emptiness. There's just so much matter there that the light cannot escape so it's nothingness. So crazy. The accretion disk is this orbit that's outside of matter orbiting. It has a specific measurement where it is, which is three times the Schwarzschild radius. From the center, one, two, three. You can see not drawn to scale,