For example, I saw the next expression for matallicity in a paper: $\log(O/H) + 12$.
I understand O/H is the O(Oxygen) to H(Hydrogen) ratio but why is there the number 12? And why the logarithm?
Astronomy Stack Exchange is a question and answer site for astronomers and astrophysicists. It only takes a minute to sign up.
Sign up to join this communityThe distribution of metallicities appear to be more evenly spread out in logspace than in linear space. The reason for this can be ascribed to there being no preferred scale for the abundance of a given element; rather they span several orders of magnitude. The same can be said for instance about the distribution of dust grain sizes, the distribution of the mass of dark matter halos, and the distribution of the area of lakes on Earth.
So, if you measure the number of oxygen atoms (or ions) in ten stars, and divide by the number of hydrogen atoms, you may get values like $$\mathrm{O}/\mathrm{H} = \{0.03,3.5,25,0.003,0.9,0.4,0.09,0.01,8,0.02\}\times10^{-4}.$$ Plotting this in a linear and a logarithmic plot, you see that on a log scale, the values are easier to tell apart:
(Another reason, as zibadawa timmy writes in his/her answer, is that taking the log you don't need to write all those $10^x$ factors).
Now why add 12? This factor corresponds to measuring the number of a given atom per $10^{12}$ hydrogen atoms. I've been asking colleagues from students to professor level, and the best answer we can come up with, is that the least abundant elements in the Sun (uranium, rhenium, thorium, …) have abundances of the order of one per $10^{12}$ hydrogen atoms, so adding 12 to $\log(X/\mathrm{H})$ makes all values positive. This angst of negative values, I don't understand, though. Usually, we're okay with minuses. And measuring metallicities in stars or gas of sub-solar metallicity yield negative values anyway. Moreover, the scale was in use even when we had only lower thresholds for uranium and bismuth of $\log(\mathrm{U}/\mathrm{H})+12<0.8$ and $\log(\mathrm{Bi}/\mathrm{H})+12<0.6$, respectively (Grevesse 1969) and didn't know if they were actually smaller.
The logarithm is there because the ratio $O/H$ is really tiny. The log converts essentially points out the order of magnitude. If we have $O/H= 10^{-14}$, then $\log(O/H)=-14$. Taking logarithms is a standard practice in science and mathematics when the numbers range over several orders of magnitude (especially so when they are either very large or very small).
As for the +12, that is most likely because they want their preferred example to have value 0. It is then easy to tell at a glance if other stars/galaxy have more ($>0$) or less ($<0$) oxygen-to-hydrogen metallicity than the preferred example. In most cases this will be our own Sun, but without knowing where you saw this it's impossible to say for certain. We have far more information about our own sun than any other star, so it is the most reliable measuring stick we have for comparison.
Indeed, the value tells you approximately how many of orders of magnitude more or less metallicity it has. For, supposing $\log(O_\mbox{sun}/H_\mbox{sun}))=-12$, then $$\log(O/H)+12 = \log(O/H)-\log(O_\mbox{sun}/H_\mbox{sun})) = \log\left(\frac{O/H}{O_\mbox{sun}/H_\mbox{sun}}\right).$$ So if the value of this is 1, then you know the star in question has an $O/H$ ratio $10^1=$ten times that of our sun. Similarly, if it were $-3$, then the star in question would have an $O/H$ ratio that is $10^{-3}=1/1000$-th that of our sun's (or, equivalently, that our sun's ratio is $1000$ times larger). A value of $0$ means the ratios are the same.