The thin lens model describes how an ideal lens forms images when its thickness is small compared with the other distances in the problem.
In that approximation, the main equation is the thin lens equation,
\[
\frac{1}{f}=\frac{1}{d_o}+\frac{1}{d_i}.
\]
Here \(f\) is the focal length, \(d_o\) is the object distance, and \(d_i\) is the image distance.
The sign of \(f\) depends on the lens type. A converging lens has \(f>0\), while a diverging lens has \(f<0\).
In the standard classroom convention used in this calculator, a real object placed to the left of the lens has \(d_o>0\).
A positive image distance means the image appears on the right side of the lens and is therefore a real image.
A negative image distance means the image is on the same side as the object and is therefore virtual.
The image size and orientation are described by the magnification
\[
m=-\frac{d_i}{d_o}.
\]
If the object height is \(h_o\), then the image height is
\[
h_i=m\,h_o.
\]
The sign of \(m\) tells you the image orientation. If \(m<0\), the image is inverted. If \(m>0\), it is upright.
The magnitude \(\lvert m\rvert\) tells you the size comparison: greater than 1 means enlarged, less than 1 means reduced, and equal to 1 means the same size.
For the standard example of a converging lens with \(f=20\ \text{cm}\) and \(d_o=30\ \text{cm}\), the equation becomes
\[
\begin{aligned}
\frac{1}{20} &= \frac{1}{30}+\frac{1}{d_i},\\
\frac{1}{d_i} &= \frac{1}{20}-\frac{1}{30}=\frac{1}{60},
\end{aligned}
\]
so
\[
d_i=60\ \text{cm}.
\]
The magnification is then
\[
m=-\frac{60}{30}=-2.
\]
That tells us the image is real, inverted, and twice as tall as the object.
This is the familiar situation where a converging lens produces a large real image on the opposite side of the lens.
A diverging lens behaves differently. Because \(f<0\), the thin lens equation usually gives a negative \(d_i\) for a real object.
That means the image is virtual and appears on the same side as the object.
The magnification is positive in that case, so the image is upright, and its magnitude is typically less than 1, so the image is reduced.
This is why diverging lenses are often associated with wide field-of-view optics and correction for nearsightedness.
The ray diagram in this calculator uses two standard construction rays from the top of the object. The first ray travels parallel to the optical axis
until it reaches the lens. For a converging lens, it then passes through the far focal point. For a diverging lens, it leaves the lens diverging in such a way
that its backward extension passes through the near focal point. The second ray goes through the optical center of the lens and continues straight, because in the thin lens model
the central ray is treated as undeviated.
Where the refracted rays meet, the top of the real image is located. If the refracted rays do not actually meet on the far side,
their backward dashed extensions are used instead, and that intersection marks the virtual image.
This is exactly the logic used in elementary ray tracing.
A camera lens is a classic converging-lens application. For an object beyond the focal length, the lens can form a real inverted image on a sensor.
A magnifier is another converging-lens example, but there the object is placed inside the focal length so the image becomes virtual, upright, and enlarged.
At a more advanced level, real imaging systems may require the thick-lens model, multiple lens elements, or aberration analysis, but the thin lens equation remains the essential starting point for geometric optics.