Determining earthquake distance

Let tE = time that earthquake occurs (unknown)
tP = time that P wave arrives at station
d = distance between earthquake and station
vP = velocity of P wave

Then, since distance = velocity * time,

d = vP(tP-tE)

Plotted, this looks like:

If we know tP-tE and vP, then we can determine d. The problem is that we don't know tP-tE, since we don't have any way of knowing when the earthquake occurred. All we know is the record of when the earthquake was recorded at a distant station --- we know tP but not tE.In other words, we have one equation but two unknowns.

Luckily, we have another piece of data that is easily read from a seismogram---the arrival time of the S wave, tS. Assuming we also know the velocity of S waves (vS), then we can write a second equation, similar to the first but in terms of S-wave velocity and travel time tS-tE:

d = vS*(tS-tE)

This would also plot as a line, and since vS < vP, would have a steeper slope than the P-wave line plotted above.

Consider these two equations: we now have 2 equations and 2 unknowns (d, tE). So we can solve simultaneously for these two unknowns. Since we're interested mostly in d, not tE, the easiest way to solve is to subtract the first equation from the second, which eliminates tE. The result, after doing this subtraction and solving for d is

d = (tS-tP/(1/vS-1/vP)

On a graph, this looks like:

So we can determine tS - tP from a seismogram, then use it to determine the distance of the station from the earthquake.