Why is aperture expressed as a function of focal length (eg. f/2, f/4), and not in absolute size, say mm (eg. 40mm)?
The brightness of the image is proportional to the amount of light admitted by the lens. We are interested in quantifying image brightness because we will use this value to determine what settings are needed when adjusting for exposure. The key factors are 1. Subject Brightness 2. Aperture Diameter 3. Focal Length 4. Sensitivity of Sensor or Film. All four of these factors are intertwined.
Your question revolves around the association between focal length and aperture diameter. The aperture is the diameter of the entrance pupil which is controlled by a mechanism with adjustable overlapping leaves. This is a device that mimics the action of the human eye. This body part is called the iris. This is the colored portion of the eye, named for the goddess of the rainbow. Our eye changes its iris diameter involuntarily, based on the level of ambient light.
For the human eye and the camera, each doubling of the iris diameter increases image brightness 4X. Conversely, should the iris diameter shrink to ½ its diameter, image brightness falls by ¼ of its former value. Note: This is a complex relationship because it is the change in surface area of the iris opening that does this feat.
Focal length is intertwined. Image brightness elevates 4X if the focal length is cut in half. Likewise, image brightness decreases 4X if the focal length is doubled. Again, this is a rather complex interaction.
How can we simplify exposure determination when faced with two complex interrelationships of iris diameter change and focal length change? Ratio to the rescue: A ratio is dimensionless. As an example – the 4th grade class has twice as many boys for every girl. A class of 18 has 6 girls and 12 boys. A class of 27 has 9 girls and 18 boys. Note the ratio holds regardless of class size.
Since cameras are available with a hodgepodge of focal lengths and iris diameters, we use the ratio of focal length to iris diameter to cut through the fog. A lens 100mm focal length with an iris diameter of 25mm operates at 100 ÷ 25 = 4. This is a ratio; the answer is 4. We call this the focal ratio f/4. Likewise, a lens 20mm in focal length with an iris diameter of 5mm functions at the same focal ration f/4. Thus 20 ÷ 5 = 4 stated as f/4.
Now the beauty of this focal ratio system is: Any lens, regardless of dimension set to the same f-number, yields the same image brightness regardless of focal length of iris diameter. With this system the mishmash disappears.
What is important for determining exposure is the amount of light per unit area on the sensor. For a given object and aperture absolute size, a larger focal length lens will produce a larger image compared to a smaller focal length lens so the same amount of light collected from the object is spread over a larger area on the sensor and thus would require a longer exposure. So the absolute size of the aperture does not by itself determine exposure.
My explanation in simpler terms.
Because it is actually a relationship, not an absolute size.
Any division is a relationship between the top number and the bottom one.
When defining the aperture we have two elements, the diaphragm and the focal distance.
We can have an "absolute" diaphragm, that will not change (D) and a given focal length (F)
That will let pass a given amount of light (L) on the sensor.
I am defining the diaphragm as an absolute size because you wanted an absolute size. So I am not changing it, but as I change the focal length to double, for example on a zoom lens, now the amount of useful light (orange) is reduced. Actually divided by four.
The rest of the light that was useful before is marked as yellow.
What we want to know is this "amount of useful light". However as the light might change on the scene, the only real elements to relation are 1 diaphragm / the focal length.
So we have 1/F.
The nomenclature is an adaptation of that notation. f/2.
Because that way you don't have to keep doing math for every lens you use. A given aperture diameter lets in different amounts of light for different focal lengths.
f/2 (where f is focal_length) lets in the same proportional amount of light whether it's a 25mm opening on a 50mm lens or 200mm on a 400mm lens.
Normalizing for all focal lengths means you no longer have to account for it.
There are already a lot of great answers on here, but perhaps a simple addition I would like to add is that the f-number is in theory, as already mentioned, just a ratio of = focal length/diameter of entrance pupil. The “aperture size” can often be calculated from the f-stop number, but it is crucial to note that f-stop values are not unique to aperture sizes.
An f/4 on a 50mm lens will have double the diameter of the entrance pupil, compared to a 25mm lens at an f/4.
F-stop values are usually an indicator of exposure. Aperture stops by definition are physical stops that reduce the exposure of light reaching the sensor. In practice the same f-stop values can be considered to give the same exposure values, however, in practice as it is only a theoretical ratio, it doesn’t account for the reflections and absorptions that happen inside the lens due to its elements and coatings (hence the existence of transmission, t-stops).