There are two reasons why the subject-to-image distance is not
40 cm at unit magnification:
- the focal length of the lens may not be 100 mm
- the distance between the principal planes may not be zero.
Which of these reasons is the most important is impossible to tell
without detailed information on the optical design of the lens.
Focal length
The value “100 mm” written on the lens itself is a nominal focal
distance, which is normally a rounded value of the real focal distance
when the lens is focused at infinity.
Some lenses, usually called “unit focusing” lenses, achieve focus by
moving the optical assembly as a whole. These lenses have a focal
distance which does not vary with focusing. However, many complex
lenses, including virtually any modern macro lens, have some sort of
“close range correction” (in Nikon parlance): their optical formula
changes as you focus, which enables better correction of aberrations.
These lenses have a focal distance which varies as you focus.
These two facts: the rounding of the nominal focal length and the fact
that it varies when you focus, mean you do not know what the actual
focal length of the lens is at unit magnification.
Principal planes
The Wikipedia page you cite defines do and di as
the distance from the lens to the object (resp. image), but note that
these definitions appear in a section that is specifically about thin
lenses. Your lens being a thick compound lens, this begs the
question of the applicability of the formula.
It turns out that the thin lens approximation is not applicable in
this situation. However, the formula is still valid if interpreted in
the context of the thick lens model. In this model, the plane of the
thin lens is replaced by two planes, which are called “principal
planes”:
- the “front” (or “primary”, or “object side”) principal plane is used
for measuring distances in object space
- the “back” (or “secondary”, or “image side”) principal plane is used
for measuring distances in image space
These are conjugate planes with unit magnification. In the figure below
(source), they are the vertical planes that go through
H1, N1 and H2, N2:
Note that this way of describing an optical system in terms of its
cardinal points (the Fi, Hi and
Ni above) is also applicable to compound lenses. See for
example this old drawing of a telephoto lens (source) where
both principal planes (the vertical planes through Ni and
No) are on the left side of the leftmost element:
Thus, your formula is still valid provided you define:
- do as the distance from the subject to the primary
principal plane
- di as the distance from the secondary principal plane to
the image
This gives the subject-to-image distance as
do + e + di = 4f + e
at unit magnification, where e is the (possibly negative) distance
between the principal planes. Note that the thin lens approximation
essentially says that the principal planes are coincident
(e = 0), but it is not applicable to your case.
For more info about this topic, you can take a look at:
The thin lens misconception
I wrote this answer mostly to help clear a popular misconception, which
appears in some of the answers here, including the one you accepted:
that a photographic lens is equivalent to a thin lens.
It turns out that in most photographic situations (basically all
non-macro situations), the subject-to-lens distance is much larger than
any characteristic distance of the lens itself. In such situations it
doesn't really matter which reference point you use for measuring the
distance to the subject. It is then convenient to forget about the
distance that separates the principal planes and consider that the rear
principal plane is the only one that matters. This is equivalent to
setting e = 0, which is basically the thin lens approximation.
Sticking to this approximation makes learning optics a lot simpler, as
you don't need to understand notions such as principal planes, principal
or nodal points, object space, image space, and so on. Considering that:
- the approximation is good enough for most (non macro) purposes
- knowledge in optics is only useful to a photographer at a qualitative
level, as you are not going to design lenses, and you don't need
optics expertise to become a great photographer
it is understandable that the thin lens is the model most commonly
taught to photographers. And yet the approximation breaks when dealing
with a complex thick lens at macro distances. The answers that tell you
that the focal distance is one quarter of the subject-to-image distance
illustrate how this misconception leads to people posting wrong answers.