What is the formula for p- and s-waves in an earthquake?
Depends on what you mean by the term of 'formula'.
There are more than one way to explain this question. For instance velocity of the P and S waves are as below, respectively:
ρ is the density of the material through which the wave propagates . µ is the shear modulus which describes the material's response to shear stress. λ is he first Lame parameter.
Velocity of these waves are different from each other. Their differences can be seen in the graph below. Compression wave and shear wave are representing P and S wave, respectively.
The other way is to detect their arrival to seismic station. For instance if you know the distance between earthquake's location and the location of the seismic station. You can calculate P and S wave arrivals as below:
First formula is used by local earthquakes (epicentral distance: 0-500 km) and the second one is used for regional earthquakes (epicentral distance: up to 1000 km).