Lens Equation Solver – Thin Lens Formula with Magnification
Use this free Lens Equation Solver to work with the thin lens formula 1/f = 1/do + 1/di. Solve for image distance, focal length or object distance, and get the magnification m = −di/do plus a plain-English description of the image at the same time.
Every camera, projector, magnifying glass and pair of spectacles is this equation wearing a case. A lens bends light by a fixed amount determined by its focal length; an object stands at some distance do; and the bent rays conspire to form an image at exactly one distance di, with exactly one size, m. The thin lens formula is the conspiracy written in algebra: three quantities locked together so that knowing any two determines the third — and with it, whether the image is real or virtual, upright or inverted, enlarged or diminished.
It earns the name "thin" honestly: the formula treats the lens as if all the bending happened at a single plane through its centre, ignoring the lens's thickness. For the glass in cameras, eyes and classroom kits that is an excellent approximation, and it buys a formula of beautiful economy — the same reciprocal sum that governs mirrors, because geometrically a lens and a mirror are doing the same job of mapping object points to image points. Master this one equation and the mirror equation comes free, and vice versa.
The solver's three modes mirror the three questions optics actually asks. Where will the image fall? — the camera and projector question. What lens is this? — the optician's question, answered by measuring a known object–image pair. Where must the object stand? — the question asked every time a slide, a phone screen or a film frame must throw its picture onto a screen a fixed distance away. Each mode is the same formula; only the unknown changes chairs.
Formula
1/f = 1/do + 1/di • magnification m = −di / do = image height ÷ object height • lens power P = 1/f (f in metres)
Rearrange for the quantity you need: 1/di = 1/f − 1/do locates the image, 1/do = 1/f − 1/di places the object, and 1/f = 1/do + 1/di identifies the lens. The optician's version of the same physics is the power in dioptres, P = 1/f with f in metres: our f = 10 cm lens is a +10 D lens, an f = 20 cm lens is +5 D, and a diverging lens of f = −25 cm is −4 D. Powers, unlike focal lengths, simply add when thin lenses are stacked — the reason prescriptions are written in dioptres and the reason two weak lenses in contact behave as one stronger one.
| Symbol | Meaning | Units & signs |
|---|---|---|
| f | focal length of the lens | cm; + converging, − diverging |
| do | object distance, lens to object | cm; + on the incoming-light side |
| di | image distance, lens to image | cm; + real (far side), − virtual (object side) |
| m | magnification, hi/ho | no units; − inverted, + upright |
| P | power, P = 1/f (metres) | dioptres (D) |
Real versus virtual: the screen test
The deepest idea inside the lens equation is the distinction its signs keep making: real images are places, virtual images are appearances. A real image forms where rays genuinely converge and cross; put a screen, a sensor or a piece of film there and the picture lands on it, whether or not anyone is watching. Every photograph ever taken is a real image arrested mid-flight. The camera's whole focusing mechanism exists to satisfy this equation — sliding the lens until di, the fixed lens-to-sensor distance, matches the value the formula demands for the subject's do.
A virtual image is the opposite arrangement: the lens bends the rays apart so that they only seem to come from a point on the object's own side. No screen can catch it, because no light ever visits that point; yet an eye placed behind the lens sees a perfectly convincing picture floating there. Magnifying glasses, spectacle lenses correcting sight, and the viewfinder optics of cameras all deal in virtual images. The equation flags them with a negative di — the sign is the screen test, encoded.
Notice, too, the elegant trade the formula enforces between the two distances. Object and image are conjugate: bring the object closer and the image retreats, growing; push the object away and the image crowds towards the focal plane, shrinking. At do = 2f they meet symmetrically, image the same size as object. The photographer racking focus, the projector being carried back from the screen, and your own eye's lens squeezing to read this page are all sliding along that one reciprocal curve.
How to use
- Choose what to solve for from the drop-down — that input box hides, because it becomes the answer.
- Enter the other two values in centimetres, using the sign convention: focal length positive for a converging (convex) lens, negative for a diverging (concave) lens.
- Click "Solve Lens Equation" for the missing value, the magnification and a description of the image.
- Interpret the signs: positive di means a real image a screen can catch; negative m means inverted. To work in dioptres instead, convert f to metres and take 1/f.
Worked examples
Example 1 — the projector arrangement. An object is placed 15 cm from a converging lens of focal length 10 cm.
1/di = 1/f − 1/do = 1/10 − 1/15 = 1/30, so di = 30 cm.
Magnification m = −30 ÷ 15 = −2 — a real, inverted image twice the size of the object, exactly how a projector lens behaves.
Example 2 — a camera focusing on a portrait. A 50 mm camera lens (f = 5 cm) photographs a sitter 2 m away, do = 200 cm.
1/di = 1/5 − 1/200 = 39/200, so di = 5.13 cm and m = −0.03. The sensor sits barely 1.3 mm beyond the focal plane — portraits focus close to f — and the image is a thirtieth of life size, which is why a face fits on a 24 mm-tall sensor.
Example 3 — the magnifying glass. Hold the f = 10 cm lens just 6 cm from the page, inside its focal length.
1/di = 1/10 − 1/6 = −2/30, so di = −15 cm and m = +15 ÷ 6 = +2.5. Negative di: virtual image, on the same side as the page. Positive m: upright and two and a half times bigger — the only arrangement in which a single lens helps you read.
Example 4 — a diverging lens. Spectacle-style diverging lens, f = −20 cm, object at 30 cm.
1/di = −1/20 − 1/30 = −5/60, so di = −12 cm and m = +12 ÷ 30 = +0.4. Always virtual, upright and diminished for a real object — a diverging lens can do nothing else, which is precisely what a short-sighted eye needs its spectacles to do to incoming parallel light.
Example 5 — the long throw. A projector lens of f = 12 cm has its slide just 13 cm away — barely outside the focal point.
1/di = 1/12 − 1/13 = 1/156, so di = 156 cm and m = −12. Working a whisker outside f buys a twelve-fold enlargement across the room; nudge the slide a millimetre closer and the image races metres further away and swells again — the touchiness every projectionist knows.
Example 6 — identifying a lens. A lens forms an image 20 cm away from an object 20 cm away. Solve for f:
1/f = 1/20 + 1/20 = 2/20, so f = 10 cm (a +10 D lens), with m = −1. Object and image equidistant means both sit at 2f — the fastest bench test of a lens's focal length there is.
Lens equations in real life
Camera focusing. The focus ring slides the lens by fractions of a millimetre, trimming di to the value this equation demands for each subject distance — Example 2's 5.13 cm versus 5 cm at infinity. Macro photography is the extreme: at 1:1 magnification do = di = 2f, and the lens sits twice as far from the sensor as its infinity position.
Cinema and home projectors. Example 5 scaled up: a short-focal-length lens, a film frame or micro-display just outside f, and a screen metres away. The "throw ratio" printed on projector boxes is this equation's geometry repackaged.
Spectacles and contact lenses. A prescription is a power in dioptres — P = 1/f in metres. A −4 D lens (f = −25 cm) diverges light so a short-sighted eye can focus it; a +2 D reading lens (f = 50 cm) adds the convergence that an ageing eye's own lens can no longer supply.
The human eye itself. Your eye is a converging lens of roughly +60 D total power whose retina is the fixed screen; focusing is done not by moving the lens but by changing its focal length with the ciliary muscle — accommodation, this equation solved by squeezing.
Phone cameras. A phone lens of f ≈ 4 mm images a face 40 cm away at di ≈ 4.04 mm with m ≈ −0.01: the whole scene compressed a hundredfold onto a sensor a few millimetres wide. Fixed focus works because at such short f, di barely moves between portrait and landscape distances.
Relay lenses in endoscopes. A rigid endoscope passes its image down a narrow tube through a chain of relay lenses, each stage a 1:1 conjugate pair — object and image both at 2f, m = −1 — handing the picture from hop to hop. Two hops restore the orientation; the chain is this equation repeated until the image reaches the camera.
Overhead transparencies to microscopes. Every instrument that puts a specimen "just outside the focal point" of a lens to throw a big image on a wall or an intermediate plane — overhead projectors, enlargers in photographic darkrooms, the objective of a microscope — is Example 5 with different furniture.
Quick reference: image behaviour of a converging lens (f = 10 cm)
| Object do | Image di | m | Used by |
|---|---|---|---|
| very far away | 10 cm (at F) | ≈ 0 | camera at infinity focus |
| 30 cm | 15 cm | −0.5 | copy stand, scanner |
| 20 cm (2f) | 20 cm | −1 | 1:1 macro |
| 15 cm | 30 cm | −2 | small projector |
| 12 cm | 60 cm | −5 | enlarger |
| 5 cm (inside f) | −10 cm | +2 | magnifying glass |
The symmetry in the table is the equation's signature: 30 ↔ 15 and 15 ↔ 30 are the same lens with object and image swapping roles. Any conjugate pair can be run in either direction — a projector run backwards is a camera.
When "thin" fails: real lenses
Real camera lenses are centimetres thick and contain a dozen elements, yet this one-element equation still predicts their behaviour — because a compound lens has principal planes, and measured from those planes the same formula holds with the system's effective focal length. Thickness is absorbed into where you measure from. The approximation genuinely fails elsewhere: for a single very thick lens, for the ball lenses in some sensors, and whenever aberrations — the failure of real rays to meet at the equation's ideal point — dominate the design problem. Modern lens design is the art of stacking elements so that the thin-lens answer, which this solver gives instantly, is the answer the hardware actually delivers.
The solver's three unknowns, notice, are also the three questions of every optical bench session — where is the image, what is the lens, where does the object go — and fluency is nothing more than choosing the right chair for the unknown before reaching for the reciprocals.
Common mistakes
- Giving a diverging lens a positive f. Concave (diverging) lenses take negative focal lengths. Enter +20 for a −20 cm lens and the solver will happily design you a projector that doesn't exist.
- Expecting the image on the object's side to be real. For a single lens, real images form only on the far side. A negative di is a virtual image — visible through the lens, impossible on a screen.
- Confusing lens power units. Dioptres demand metres: P = 1/f(m). Feeding centimetres into 1/f inflates the power a hundredfold — a +10 D lens is not a +0.1 D lens.
- Assuming magnification is always −di/do with a "mistake" minus. The minus sign is the inversion of every real image. Dropping it loses the orientation, and with it half the marks in any description question.
- Placing the object exactly at f and hunting for the image. At do = f the emergent rays are parallel and the image is at infinity. The solver says so; a screen slid along the whole bench will agree, finding nothing.
FAQ
What is the difference between a real and a virtual image?
A real image is formed where the light rays actually meet, so it can be caught on a screen or camera sensor (positive di). A virtual image only appears where the rays seem to come from — you can see it through the lens, like with a magnifying glass, but no screen will catch it (negative di).
When does a converging lens make a virtual image?
When the object is closer to the lens than the focal length (do < f). Then 1/di comes out negative, giving an upright, magnified virtual image — the magnifying-glass case.
Can I use metres instead of centimetres?
Yes — the equation works in any unit as long as all three distances use the same one. The answer then comes out in that unit too.
What does "thin lens" actually assume?
That the lens's thickness is negligible next to the distances involved, so both refractions can be treated as happening at one central plane. It is an excellent approximation for spectacle, camera and classroom lenses; compound camera lenses are handled by measuring from their principal planes, where the same formula applies.
Why do camera lenses move when focusing?
Because the sensor's position is fixed, di must be trimmed to match each subject distance: 5.13 cm for a sitter at 2 m with a 50 mm lens, exactly 5 cm for a mountain at infinity. The focus mechanism is a di adjustment of a millimetre or so, driven by this equation.
How do two lenses in contact combine?
Their powers add: P = P1 + P2. A +10 D lens against a +5 D lens behaves as a single +15 D lens (f ≈ 6.7 cm). This is why opticians stack trial lenses, and why focal lengths — which do not add — are the awkward way to combine lenses.
Can a diverging lens ever form a real image?
Not from a real object — its image is always virtual, upright and diminished. Paired with a stronger converging lens it can shift a real image (that is its job in telephoto and zoom designs), but alone it never projects.
What focal length do my eyes use?
The eye's optics total about +60 D, an effective focal length near 17 mm inside the eye, projecting an inverted real image onto the retina with m of roughly −0.005 for a face across the room. Your brain flips it; the lens equation does not.
Why is the image from a projector upside down — and how is it fixed?
Because m is negative for every real image from a single lens: the picture crosses at the image plane. Projectors simply load the source upside down (or flip it electronically) so the unavoidable inversion lands it right side up.
What happens to the image if half the lens is covered?
It stays exactly where the equation puts it, at the same size — every part of a lens images every part of the object. Covering half the lens only halves the light gathered, dimming the image; it never crops it. (Try it with a magnifier and a thumb.)