Let t_{E} = time that earthquake occurs (unknown)

t_{P} = time that P wave arrives at station

d = distance between earthquake and station

v_{P} = velocity of P wave

Then, since distance = velocity * time,

d = v_{P}(t_{P}-t_{E})

Plotted, this looks like:

If we know t_{P}-t_{E} and v_{P}, then we can determine d. The problem is that we *don't* know t_{P}-t_{E}, 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 t_{P} but not t_{E}.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, t_{S}. Assuming we also know the velocity of S waves (v_{S}), then we can write a second equation, similar to the first but in terms of S-wave velocity and travel time t_{S}-t_{E}:

d = v_{S}*(t_{S}-t_{E})

This would also plot as a line, and since v_{S} < v_{P}, 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, t_{E}). So we can solve simultaneously for these two unknowns. Since we're interested mostly in d, not t_{E}, the easiest way to solve is to subtract the first equation from the second, which eliminates t_{E}. The result, after doing this subtraction and solving for d is

d = (t_{S}-t_{P}/(1/v_{S}-1/v_{P})

On a graph, this looks like:

So we can determine t