How can you determine the distance of a star using the magnitude equation? In high school we are undergoing a short course about astronomy. It is stated that you can use the apparent and absolute magnitude (m, M) to get a distance (D) of a star, with the formula
$$m - M = 5 \times \log(D) - 5$$
From which you free D:
$$D = 10^{\frac{m-M+5}{5}}$$
But how do you get both the m and M in practice, without knowing anything else? I can't imagine it.
I have asked my teacher but his explanation did not make sense to me, and as such I already forgot it.
Scenario:
you have a satellite which can measure the incoming photons  of a star. You now calculate the apparent magnitude using the formula:
$$m = m_\text{ref} - 2.5 \times \log(\frac{I}{I_\text{ref}})$$
Let's say you have a stable reference star and so you get $m=2$.
This is a nice start, but to determine the distance of the star you still need the absolute magnitude. How can you precisely acquire that using a HR-diagram? Because all the HR diagrams I have seen have a very fuzzy curve, and one temperature may map to multiple M.

This is what I'm struggling with: let's say you are somehow able to precisely measure that the star is 7500K. That means M can range from +4 to 0 (I guess we're also assuming it's a main sequence star, which we may not actually know), which gives us a possible D of about 4 to 25 (parsec?), which is an absolutely humongous range.
This can't be right, can it?
This is all absolutely true (pun intended). Finding absolute magnitudes is hard.  For many types of star, we don't really know their absolute magnitude and so we don't really know their distance.
For close-by stars we can get the distance by measuring the parallax (how far the star appears to move over a year due to the orbit of the Earth. Nearer stars appear to move more) From this we can work out absolute magnitude.
For other stars we can get their absolute magnitude in other ways. For example, a type of large bright star called a &quot;Cepheid variable&quot; will have a pulse rate P that is connected to it's absolute magnitude $M_\mathrm{v}$ by the following (empirically derived) formula:
$$M_\mathrm{v} = -2.43(\log_{10}P - 1) - 4.05$$
With this you can easily measure the period in days, and use that to find the absolute magnitude.  The apparent magnitude is easy to measure, it is how bright the star appears to be on Earth.
And with apparent and absolute magnitudes you can find the distance of the star.
Stars like Cepheid variables are called &quot;standard candles&quot;, since their brightness can be determined exactly