The Lens and Mirror Equation, Explained
After reading this you can predict where an image forms, how large it is, and whether it is real or virtual, upright or inverted, for any thin lens or spherical mirror using a single equation.
What the equation does
Point a magnifying glass at this page and the print swells. Turn it toward a distant window and, at the right distance, an upside-down miniature of the window appears on the wall. Both effects come from one relation between three lengths: the focal length of the optic, the distance from object to optic, and the distance from optic to image.
That relation is the thin-lens equation, and the same algebra governs spherical mirrors. Given the focal length f and the object distance d_o, you solve for the image distance d_i and the magnification m. The signs of those answers tell you the character of the image.
The word "thin" matters. The equation assumes the lens is thin compared with the distances involved, and it assumes rays travel close to the optical axis (the paraxial approximation). Real lenses violate both assumptions slightly, which is why a cheap magnifier blurs at the edges.
When to use it, and when not to
Use it for a single thin lens or a single spherical mirror, with light from one point source or one flat object, and with rays that stay near the axis. Under those conditions the predictions are accurate to a few percent.
Do not trust it for thick compound lenses, for wide-angle rays far from the axis, or when you care about color. Real glass bends blue light more than red, so the focus for blue sits closer to the lens than the focus for red. This is chromatic aberration, and the single-focal-length model ignores it entirely. For the refraction physics behind that color spread, see the Snell's Law and Refraction Calculator.
A camera lens made of eight glass elements cannot be described by one focal length in this equation. Manufacturers quote an effective focal length that reproduces the same image scale, but the internal ray paths are far more complex than 1/f = 1/d_o + 1/d_i suggests.
The formula and the intuition
Here f is the focal length, d_o is the object distance (measured from the optic to the object, taken positive for a real object in front), and d_i is the image distance you solve for. Solve for d_i directly:
The magnification follows from similar triangles drawn through the center of the lens:
A magnification of m = -2 means the image is twice as tall as the object and inverted. A value of m = +0.5 means half height and upright. The intuition behind the reciprocal equation: focal length sets how strongly the optic bends light. As the object moves toward the focal point, d_o - f shrinks toward zero, so d_i grows without bound. That is why an object placed exactly at the focus produces parallel outgoing rays and no image at finite distance.
Sign conventions differ between textbooks. This tool uses the convention where f \gt 0 for converging optics (a convex lens or concave mirror), d_i \gt 0 for a real image, and m \gt 0 for an upright image. Check which convention your source uses before comparing numbers.
A worked example with the demo numbers
Converging lens, object at 30 cm
Take the demo values: a thin lens with focal length f = 10 cm and object distance d_o = 30 cm.
- Compute the denominator: d_o - f = 30 - 10 = 20 cm.
- Image distance: d_i = (10 \times 30) / 20 = 300 / 20 = 15 cm. Positive, so the image is real.
- Magnification: m = -d_i / d_o = -15 / 30 = -0.5. Negative, so the image is inverted, and its size is half the object.
- Check with the reciprocal form: 1/15 = 1/30 + 1/d_i gives 1/d_i = 0.06667 - 0.03333 = 0.03333, so d_i = 30? No: recompute. 1/f = 1/10 = 0.1, 1/d_o = 1/30 = 0.03333, so 1/d_i = 0.1 - 0.03333 = 0.06667 and d_i = 15 cm. Consistent.
So an object 30 cm from a 10 cm converging lens forms a real, inverted image 15 cm behind the lens at half size. A screen placed there catches a sharp upside-down picture. This is exactly how a film projector or a camera works.
How the image changes as you move the object
Fix the focal length at 10 cm and slide the object inward from far away. Three regimes appear. Far beyond 2f (20 cm here) the image is real, inverted, and shrunk. Between f and 2f the image is real, inverted, and enlarged. Inside the focal length the image flips to virtual, upright, and enlarged: that is the magnifying-glass mode.
| d_o (cm) | d_i (cm) | m | Real or virtual | Orientation |
|---|---|---|---|---|
| 50 | 12.5 | -0.25 | Real | Inverted |
| 30 | 15 | -0.5 | Real | Inverted |
| 20 | 20 | -1 | Real | Inverted |
| 15 | 30 | -2 | Real | Inverted |
| 10 | ±∞ | ±∞ | None | None |
| 5 | -10 | +2 | Virtual | Upright |
Reading and interpreting the results
Three numbers carry the meaning: the sign of d_i, the sign of m, and the magnitude of m.
- Positive d_i
- Real image. Light rays actually converge there, so a screen placed at that spot shows the image. Cameras, projectors, and your retina all catch real images.
- Negative d_i
- Virtual image. Rays only appear to diverge from that point. You see it by looking through the optic, but no screen can catch it. The enlarged view in a magnifying glass is virtual.
- Negative m
- Inverted image, always paired with a real image from a single optic.
- Positive m
- Upright image, paired with a virtual image.
- |m| greater than 1
- Enlarged. Less than 1 means reduced. Exactly 1 means same size, which happens at d_o = 2f for a converging optic.
For a spherical mirror the arithmetic is identical, only the geometry differs: a concave mirror has f \gt 0 and a convex mirror has f \lt 0. A convex mirror always gives a virtual, upright, reduced image, which is why passenger-side car mirrors carry the warning that objects are closer than they appear.
Common mistakes
The first error is a wrong sign on the focal length. A diverging lens or a convex mirror needs f \lt 0. Enter -10, not 10, and the image comes out virtual as it should.
The second error is confusing focal length with radius of curvature for mirrors. They are related by f = R/2. A mirror with a 20 cm radius has a 10 cm focal length, not 20.
The third is treating the object-at-focus case as a real answer. When d_o = f the denominator d_o - f is zero and d_i is infinite. No image forms at any finite distance; the emerging rays are parallel.
If you measured f and d_o yourself and want to know how their uncertainties spread into d_i, run the values through the Error Propagation Calculator. Because d_i blows up near d_o = f, a small error in either input can produce a large error in the image position there.
Related tools
Optics sits inside the broader physics of waves and light on this site. The Doppler Effect Calculator handles the frequency shift of moving sources, and the Photon Energy Calculator connects a wavelength to the energy each photon carries. For the wave nature of matter itself, the de Broglie Wavelength Calculator assigns a wavelength to a moving particle. When you compare a measured image distance against the predicted one, the Percent Error Calculator reports the gap as a percentage.
Frequently asked questions
Why is my image distance negative?
A negative d_i means a virtual image. This happens whenever the object sits inside the focal length of a converging optic, or for any object with a diverging lens or convex mirror. The image is on the same side as the object and cannot be projected onto a screen.
What focal length do I enter for a mirror described by its radius?
Use half the radius of curvature: f = R/2. A concave mirror gets a positive value, a convex mirror a negative one. So a convex mirror with R = 40 cm takes f = -20 cm.
Why does the magnification carry a minus sign?
The minus sign encodes orientation. It comes from the similar triangles formed by the ray through the lens center. When the image forms on the far side (real, d_i \gt 0), the sign of m = -d_i/d_o is negative, marking the inverted image you actually observe.
Does this work for the human eye or a camera?
As a first approximation, yes. Model the eye as a single thin lens with f near 17 mm and the retina fixed at d_i near 17 mm; the eye changes f to focus objects at different d_o. The numbers are close enough to explain why near objects strain the muscles more, but the real eye is a multi-surface system with a curved retina.
What happens exactly at the focal point?
The equation gives an infinite image distance because d_o - f = 0. Physically, rays leave the optic parallel and never reconverge, so there is no image at any finite place. Move the object slightly and a distant image snaps into existence.