Welcome to Project Lovelace! We're still super new so there are still tons of bugs to find and improvements to make. If you have any suggestions, complaints, or any comments at all please let us know on Discourse!

Finding earthquake epicenters

You will learn about: trilateration, equation of a circle, and systems of linear equations.

To figure out how far away an earthquake is you just need one seismograph but to pinpoint where the earthquake happened, it's epicenter, you need three seismographs in three different locations. Say an earthquake occurs at some unknown location $(x_0,y_0)$ on a 2D plane. It will emit seismic waves which travel through the Earth and are detected by seismograph stations. More than one type of wave is emitted but we'll just consider the faster compressional P-waves which travel at around $v = 6 \; \text{km/s}$ and arrive at the seismographs first.

Given the position of three seismographs $(x_i,y_i)$ and arrival time of the seismic waves at each seismograph $t_i$ where $i=1,2,3$ as inputs, determine and return the earthquake's epicenter $(x_0,y_0)$.

Input: $(x_i,y_i)$ in kilometers where $-100 < x,y < 100$ and $t_i$ in seconds for $i=1,2,3$.

Output: The earthquake's epicenter $(x_0,y_0)$ in kilometers.

Example

Input x1: 8.382353226 Input y1: -58.003720814 Input t1: 12.860754193 Input x2: -13.590571819 Input y2: 73.976069096 Input t2: 22.847488548 Input x3: 77.291172370 Input y3: 7.508764456 Input t3: 5.767809783 Output x0: 79.06746127 Output y0: -27.05247781

 Difficulty  Timesink 60 s 250 MiB earthquake_epicenter(x1, y1, t1, x2, y2, t2, x3, y3, t3)

Write a function that accepts the input as function parameters and returns the correct output. Make sure to read the description above to produce the correct output in the correct format and use the correct function signature so we can run your code. A good first step is to try reproducing the example(s). Your code must not take longer than the maximum runtime to run and must not use more memory than the allowed limit.

You must be logged in to view your submissions.

Notes

• The whole process of using points, distances, and circles to determine the location of another point (in our case the earthquake) is called trilateration and is how a GPS determines its location.
• Earthquakes usually happen below the surface so technically the epicenter is the location on the Earth's surface below which the earthquake occured while the earthquake's focus is where it actually happened inside the Earth.
• We're also assuming that the earthquake happens very close to the surface and that the seismographs are close to each other so the Earth's curvature is negligible. When the seismographs are far apart which is typical for earthquakes that happen below the ocean or when the earthquake happens deep below the ground, the Earth's spherical shape matters a lot.
• The actual velocity of the P-waves can vary quite a bit depending on the medium it's traveling through. We picked a typical value of 6 km/s which is roughly the velocity of a P-wave at the Earth's surface.

Let us know what you think about this problem! Was it too hard? Difficult to understand? Also feel free to discuss the problem, ask questions, and post cool stuff on Discourse. You should be able see a discussion thread below. Feel free to post your solutions but if you do please organize and document your code well so others can learn from it.