You have indeed made some errors in your calculation. 156543.04 meters/pixel is a constant "based on the diameter of the Earth and the equations Microsoft used to set the zoom levels" used in two equations on the page you reference - it's not a variable. Your mistake was in substituting the map resolution your openlayers code returned for the constant. The first equation is:
Map resolution = 156543.04 meters/pixel * cos(latitude) / (2 ^
In theory, according to the table provided at the page you linked, this would be 611.5 m/p at zoom level 8, at the equator. That's almost exactly the number you were given by your openlayers code, but if you solve that equation at 51.02 lat it comes out to be closer to 384.7 m/p. That matches up with the sentence under their chart, which gives an example (at a different zoom level) for a lat other than the equator. However it is a bit odd that your openlayers code is returning 611.5 for zoom level 8 at 51.02 and not 384.7. That suggests to me that the equation may not hold for openlayers [actually it looks like very similar numbers in the openlayers docs] - the page you link to is specific to Bing maps and as noted above is based on their equations to set zoom levels. Or it may just be that code returns the at-the-equator value, regardless of where you're actually looking, while the displayed scalebar takes the lat into account.
The formula you actually want to solve (theoretically, with your values) should be:
1733376.065 = [(ScreenRes ppi * 39.37 inches/meter * 156543.04 meters/pixel * cos(51.02)) / (2^8)]
Now, as I mentioned in my comment, your true screen resolution in terms of ppi is hardware/device dependent and varies from display to display. If you want to find it, it may be a published specification or you may have to calculate it. You first need the native 'resolution' of the display. This would be more properly termed pixel dimensions, because resolution is actually the density of pixels (ppi) - but we use resolution interchangeably.
So let's say 1920x1080, a standard HD display (and note this needs to be the native number, NOT what it's being run at). Since we need the diagonal pixel dimension, simple a^2 + b^2 = c^2 gives us 2202.9 diagonal pixels. Now we need the actual diagonal dimension of the display. For instance a 24" display may only be 23.8" - this is pretty much always in the specs (usually as 'viewable' or some similar adjective). Diagonal pixels divided by diagonal inches gives us 92.6 ppi. Were it a 27" display at the same resolution, it would be 81.6 ppi. A 5" gives 440.6 ppi. I found a handy calculator on the web that can do this math for you if you have the right numbers.
This will give you a much more accurate (possibly even correct) result than trying to use the Microsoft equation and should be easier. The relationship, per your question title, is somewhat complex - we're talking about scaled scales essentially. And if you run a resolution (or rather pixel dimension) different than native, it gets even more complicated.
Go back to what scale is - unit x on map representing unit y in the real world. In computers there is no scale relative to anything but pixels. That's the first equation, what they term map resolution. Say 100 pixels represents 600m. On a phone display those 100 pixels may only be 0.25 inch, while on a 30" computer monitor they might be 1 inch - but they still both represent 600m. That's why the page has the second equation - because most people don't think of map scale in terms of pixels, they want a inch : mile ratio (or whatever units). The problem is that ratio changes depending on what display you're looking at while the pixel : real world unit ratio doesn't, assuming the same pixel dimensions and zoom on the image.