Physics: Mechanics, Waves & Thermodynamics Waves, Sound & Optics Thin lens equation, Gaussian (real-is-positive) sign convention

Thin Lens Equation and Magnification Calculator

Give this calculator a focal length, an object distance and an object height, and it locates the image from 1/f = 1/d₀ + 1/dᵢ. It reports the image distance, the magnification, the image height, the lens power in dioptres, and whether the image is real or virtual and upright or inverted. Enter a negative focal length for a diverging lens. It uses the Gaussian convention, in which a positive image distance means a real image on the far side of the lens.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Focal length fPositive for a converging (convex) lens, negative for a diverging (concave) one.100 mm
Object distance d₀Distance from the object to the lens, measured along the optical axis; always enter it positive.300 mm
Object height h₀Height of the object above the optical axis; used only to scale the image height.20 mm

It returns

  • Image distance dᵢ — Positive means a real image on the opposite side of the lens; negative means a virtual image on the same side as the object.
  • Magnification m
  • Image height hᵢ
  • Lens power
  • Object-to-image distance

The formula

1f=1d0+1di
m=did0=hih0
di=d0fd0f

In plain text: 1/f = 1/d₀ + 1/dᵢ

  • fFocal length — positive converging, negative diverging (mm)
  • d₀Object distance from the lens, positive for a real object (mm)
  • dᵢImage distance — positive for a real image beyond the lens (mm)
  • mTransverse magnification, negative when inverted (×)
  • PLens power, the reciprocal of the focal length in metres (D)

Valid for a thin lens — one whose thickness is negligible compared with the focal length — with paraxial rays close to the optical axis and a single wavelength.

Updated Category Waves, Sound & Optics Verified against published test cases Reading time 11 min

What a lens does and what focal length means

A lens bends every ray that passes through it, and the amount of bending depends on where the ray strikes the surface. Both surfaces refract according to Snell's law, and for a thin lens with spherical surfaces the net effect on paraxial rays is startlingly simple: all rays leaving one point on the object are brought back together at one point on the image side. That is what makes imaging possible at all.

Focal length is the distance at which a converging lens brings parallel rays to a point. Light from a very distant object arrives essentially parallel, so its image forms at the focal plane — which is why a camera focused at infinity has its sensor exactly one focal length behind the lens, and why you can measure a lens's focal length in seconds by imaging a window onto a wall.

The thin lens equation, 1/f = 1/d₀ + 1/dᵢ, follows from applying the refraction equation at each surface and dropping the thickness. Written as reciprocals it is not obviously intuitive, so it helps to see what it says: bring the object closer and 1/d₀ grows, so 1/dᵢ must shrink, so the image moves further away and gets bigger. That is focusing. A camera lens focusing from infinity down to its minimum distance is doing exactly this, and the barrel extension you can feel is the change in di.

Optometrists work in dioptres instead, P = 1/f with f in metres. Dioptres are convenient because thin lenses in contact simply add: a +2.00 D reading lens over a −3.00 D distance correction gives −1.00 D overall. A +2.00 D lens has a focal length of 500 mm; a −4.00 D lens has −250 mm.

Signs, and the five cases a converging lens can produce

The sign convention does the work here, so it is worth stating exactly. This calculator uses the Gaussian, real-is-positive convention: d0 is positive for a real object in front of the lens; di is positive for a real image formed beyond the lens and negative for a virtual image on the object side; f is positive for a converging lens and negative for a diverging one; and m = −dᵢ/d₀, so a negative magnification means an inverted image.

A converging lens then has five distinct regimes, and moving the object through them is the whole of elementary lens optics:

  • Object beyond 2f. The image is real, inverted and reduced, between f and 2f. This is the camera and the eye.
  • Object at exactly 2f. The image is real, inverted and the same size, at 2f. The object-to-image distance is 4f, which is the minimum possible for a real image and the standard 1:1 macro setup.
  • Object between f and 2f. The image is real, inverted and enlarged, beyond 2f. This is the projector.
  • Object at f. No image: the rays emerge parallel and meet only at infinity. This is the collimator.
  • Object inside f. The image is virtual, upright and enlarged, on the same side as the object. This is the magnifying glass, and it is why you must hold a loupe close to the thing you are inspecting.

A diverging lens is far simpler. With a real object it produces a virtual, upright, reduced image every single time, at any object distance, and the image always sits between the lens and its focal point. There are no cases to remember, which is why a diverging lens can never be used to project.

Worked example: a slide projector

You have a 150 mm projection lens and a 36 mm-wide slide. You want the image to be 1.44 m wide on a screen. Where do the slide and the screen go?

  1. Required magnification. m = image height ÷ object height = 1440 ÷ 36 = 40 in size. The image is real and therefore inverted, so m = −40.
  2. Object distance from magnification. m = −dᵢ/d₀, so di = 40 d0. Substituting into the lens equation: 1/150 = 1/d₀ + 1/(40 d₀) = (41)/(40 d₀), giving d0 = 150 × 41 ÷ 40 = 153.75 mm.
  3. Image distance. di = 40 × 153.75 = 6,150 mm, so the screen sits 6.15 m from the lens.
  4. Check with the lens equation. 1/153.75 + 1/6150 = 0.0065041 + 0.0001626 = 0.0066667 = 1/150. It closes.
  5. Sanity-check the geometry. The slide sits just 3.75 mm outside the focal point, which is the regime that produces a large real image, exactly as expected. That tiny margin is also why projector focusing is so touchy: moving the slide 0.5 mm shifts the screen distance by roughly 800 mm.

Now reverse the lens's job. Put the same 150 mm lens 200 mm from an object: di = 200 × 150 ÷ 50 = 600 mm and m = −3. And at 100 mm, inside the focal length: di = 100 × 150 ÷ (−50) = −300 mm, a virtual upright image three times life size, 300 mm in front of the lens. One lens, three completely different behaviours, all from the same equation.

Reading the answer and checking it is physical

Read the sign of the image distance first, because it decides everything else. A positive value means light really converges there and you can put a sensor or a screen at that point. A negative value means the rays only appear to come from there — nothing is projected, and you must look through the lens to see the image. Photographic and projection work needs positive image distances; magnifiers, eyepieces and spectacle lenses for myopia work in the negative regime.

Then check the magnification against the object position. For a converging lens, |m| passes through 1 exactly when the object is at 2f. Object further than 2f means |m| < 1; object between f and 2f means |m| > 1. If your numbers contradict that, the focal length or the object distance has the wrong sign.

Watch out for the minimum-conjugate result. For a real image, the total object-to-image distance d₀ + dᵢ has a minimum of exactly 4f, reached at the 2f–2f pair. If you have a bench 500 mm long and want a real image, no lens longer than 125 mm can do it, no matter where you put things. This is the calculation that tells a photographer whether a given macro setup can physically reach 1:1.

Finally, remember what the thin lens model omits. It assumes a lens of negligible thickness, rays close to the axis, a single wavelength and perfect spherical surfaces. Real lenses show spherical aberration, coma, astigmatism, field curvature, distortion and chromatic aberration; a real thick lens has two principal planes and distances must be measured from those, not from the glass. The equation gets you the design point; ray-tracing software and a real optical bench get you the last few percent.

Image position and size across the whole object range

Both distances are given as multiples of the focal length of a converging lens, from dᵢ/f = k/(k−1) and m = −1/(k−1) where k = d₀/f.
Object distance d₀Image distance dᵢMagnificationImage character
0.50 f−1.00 f+2.00Virtual, upright, enlarged
0.90 f−9.00 f+10.00Virtual, upright, strongly enlarged
1.00 finfiniteinfiniteNo image — rays emerge parallel
1.10 f+11.00 f−10.00Real, inverted, strongly enlarged
1.50 f+3.00 f−2.00Real, inverted, enlarged
2.00 f+2.00 f−1.00Real, inverted, same size
3.00 f+1.50 f−0.50Real, inverted, reduced
5.00 f+1.25 f−0.25Real, inverted, reduced
10.0 f+1.11 f−0.111Real, inverted, reduced
very large→ 1.00 f→ 0Real image at the focal plane

Multiply the middle column by your own focal length to get millimetres. A diverging lens is not tabulated because it gives a virtual, upright, reduced image at every object distance.

Errors that misplace the image

  • Adding the reciprocals wrong. 1/f = 1/d₀ + 1/dᵢ does not mean f = d₀ + dᵢ. Solve for di as d₀f/(d₀−f) rather than inverting term by term.
  • Mixing sign conventions. Some texts use a Cartesian convention in which the object distance is negative. Pick one and stay in it; this calculator takes a real object as positive throughout.
  • Forgetting that magnification is negative for real images. A converging lens forming a real image always inverts, so a positive magnification alongside a positive image distance is a contradiction.
  • Using a diverging lens to project. It cannot form a real image from a real object at any distance, so no screen position will ever work.
  • Measuring distances from the glass on a thick lens. Distances belong to the principal planes, which for a thick or compound lens can sit centimetres away from the physical elements — sometimes outside the barrel entirely.
  • Ignoring chromatic aberration. The focal length depends on refractive index, which depends on wavelength, so a simple lens has a different focal length for blue and red light.
  • Expecting a real image inside 4f of total separation. The object-to-image distance for a real image can never be less than four focal lengths.

Beyond a single thin lens

The focal length itself comes from the lensmaker's equation, 1/f = (n − 1)(1/R₁ − 1/R₂), which links it to the refractive index of the glass and the curvature of the two surfaces. That index is exactly the quantity that governs how each surface bends light, so the thin lens formula sits directly on top of Snell's law: it is what you get when you apply refraction at two spherical surfaces and take the thin limit.

Multiple lenses are handled by chaining: the image formed by the first becomes the object for the second, with a negative object distance if it falls beyond the second lens. Two thin lenses in contact simply add their powers. That is how a compound microscope reaches 1,000× and how a telescope's magnification comes out as the ratio of objective to eyepiece focal lengths.

Resolution is not covered by the thin lens equation at all. Even a geometrically perfect lens cannot resolve detail finer than roughly 1.22λ/D in angle, set by diffraction at the aperture — which depends on the wavelength rather than on the ray geometry. That is the limit optical microscopes hit at about 200 nm, and the reason electron microscopes exist.

If you are working through an optics problem set, the neighbouring calculations are usually refraction at a plane surface, the critical angle for total internal reflection inside a prism, and the intensity falling on the image plane. The last of these follows an inverse-square law of the same shape as the one behind sound levels, which is why a projector image dims as the square of the throw distance.

Sign convention used on this page

Object distance positive for a real object. Image distance positive for a real image on the far side of the lens, negative for a virtual image on the near side. Focal length positive for converging, negative for diverging. Magnification negative when inverted. If a textbook gives you a different answer's sign, check its convention before assuming an arithmetic error.

Frequently asked questions

What is the difference between a real and a virtual image?

A real image forms where light rays actually converge, so you can catch it on a screen or a sensor; the calculator reports it as a positive image distance. A virtual image forms where the rays only appear to originate after passing through the lens, so nothing lands on a screen and you must look through the lens to see it. Magnifying glasses, eyepieces and spectacle lenses all produce virtual images.

Why does my magnifying glass flip the image when I move it away?

Because you have crossed the focal point. Held closer than one focal length, it gives a virtual, upright, enlarged image. Beyond that distance the image becomes real and inverted, and at slightly more than f it is also very large — which is why the flip is so abrupt and why there is a blurred dead zone right at the focal point where no image forms.

How do I convert focal length to dioptres?

Divide 1 by the focal length in metres: a 500 mm lens is +2.00 D, a 250 mm lens is +4.00 D, and a −200 mm lens is −5.00 D. Dioptres add for thin lenses in contact, which is why a trial frame stacks lenses and simply sums their powers, and why a spectacle prescription quotes sphere and cylinder in the same unit: the power in the steeper meridian is the sphere plus the cylinder.

Can a diverging lens ever produce a real image?

Not from a real object. With a positive object distance and a negative focal length the image distance is always negative, giving a virtual, upright, reduced image at every distance. A diverging lens can produce a real image only from a virtual object — that is, when converging light from another lens is intercepted before it comes to focus.

Why can't I get a real image with the object and screen close together?

Because the object-to-image separation for a real image has a hard minimum of four focal lengths, reached when both distances equal 2f. Below that, the lens equation has no real solution. If your bench is 400 mm long, only lenses of 100 mm focal length or shorter can form a real image on it.

What does a negative magnification mean?

The image is inverted top-to-bottom relative to the object. The magnitude gives the size ratio, so m = −0.5 means half the height and upside down. Real images from a single converging lens are always inverted; virtual images are always upright.

Does this work for mirrors as well?

The arithmetic is identical — the mirror equation is also 1/f = 1/d₀ + 1/dᵢ, with f = R/2 — but the sign convention differs, because a real image from a mirror forms on the same side as the object. Use a mirror-specific convention rather than reusing this page's, or you will end up with the image on the wrong side of the glass.

How do I measure a lens's focal length quickly?

Image a distant object — a window or a light across the room — onto a sheet of paper and measure the lens-to-paper distance. Because the object is effectively at infinity, that distance is the focal length to within a percent or two. For a more precise result, use the 2f–2f conjugate: find the position where the image is exactly the same size as the object, and the total separation is 4f.

References