Tabellab
Data, tech, science & health

Thin lens equation calculator: image distance and magnification

The thin lens equation links the focal length f, the object distance dₒ and the image distance dᵢ: 1/f = 1/dₒ + 1/dᵢ. Solved for the image, dᵢ = 1 ÷ (1/f − 1/dₒ), and the magnification is m = −dᵢ ÷ dₒ. A 50 mm lens with a flower 150 mm away forms a sharp image 75 mm behind the lens at half size (m = −0.500, real and inverted). The calculator below solves seven setups, from a camera to a projector and a magnifying glass, in one row each.

Updated 21 Oct 2026 6 min read By Tabellab team

The thin lens equation

1/f = 1/dₒ + 1/dᵢ

  • f is the focal length of the lens.
  • dₒ is the distance from the object to the lens.
  • dᵢ is the distance from the lens to the image.

Usually f and dₒ are known and you want the image. Rearranged: dᵢ = 1 ÷ (1/f − 1/dₒ), or equivalently dᵢ = f·dₒ ÷ (dₒ − f). In Excel: =1/(1/B4-1/C4). For the close-up, 1 ÷ (1/50 − 1/150) = 1 ÷ 0.01333 = 75 mm. All three distances must be in the same unit. Millimetres are convenient for camera lenses.

Worked example: seven lens setups in one table

Focal lengths and object distances are inputs (yellow), in millimetres. Column D solves the thin lens equation for the image distance, column E calculates the magnification and column F names the image type. Rows 10 to 13 size the projected slide, convert the projector lens to dioptres and check the close-up by solving back for f.

Worked example: seven lens setups in one table
ABCDEF
1Setupf (mm)dₒ (mm)dᵢ (mm)mImage
2Camera, subject at 5 m505,00050.5-0.010Real, inverted
3Portrait lens at 2 m852,00088.8-0.044Real, inverted
4Close-up of a flower5015075.0-0.500Real, inverted
5Object at 2f100200200.0-1.000Real, inverted
6Slide projector1001052,100.0-20.000Real, inverted
7Magnifying glass10060-150.02.500Virtual, upright
8Diverging lens-200300-120.00.400Virtual, upright
9
10Slide height in the projector (mm)24
11Image height on the screen = |m| × slide height (mm)480
12Power of the projector lens = 1000 ÷ f (dioptres)10.0
13Check: f back from dₒ and dᵢ of the close-up (mm)50.0
Key formulas
  • D2=1/(1/B2-1/C2)Image distance from the thin lens equation
  • E2=-D2/C2Magnification
  • F2=IF(D2>0,"Real, inverted","Virtual, upright")Image type
  • F11=ABS(E6)*F10Projected image height
  • F12=1000/B6Lens power in dioptres

Ideal thin lenses, distances in millimetres, real-is-positive sign convention. Educational calculations only, not eye-care or engineering advice.

Sign convention: real is positive

The calculator uses the common "real is positive" convention:

  • f > 0 for a converging (convex) lens, f < 0 for a diverging (concave) lens.
  • dᵢ > 0: a real image on the far side of the lens, which you can catch on a screen or sensor.
  • dᵢ < 0: a virtual image on the same side as the object, which you only see by looking through the lens.

Some textbooks use the Cartesian convention instead, with the lens formula written 1/v − 1/u = 1/f and object distances counted as negative. The physics is identical, only the signs move. Pick one convention and keep it for the whole problem.

Magnification and image type

The magnification is m = −dᵢ ÷ dₒ. A negative m means the image is upside down, a positive m that it is upright, and |m| > 1 that it is larger than the object. The image height is m times the object height.

For a single lens, a real image is always inverted and a virtual image always upright, so one IF on dᵢ gives the image type: =IF(D2>0,"Real, inverted","Virtual, upright"). The slide projector shows the effect of a large m: a 24 mm slide just outside the focal length of a 100 mm lens appears 2,100 mm away at m = −20, so the picture on the screen is 480 mm high.

Where the image lands: the five cases

  • Object far away: the image sits almost exactly at f. A 50 mm camera lens focused on a subject 5 m away is only 50.5 mm from the sensor, half a millimetre further than at infinity.
  • Object at 2f: the image is also at 2f, real, inverted and the same size (m = −1).
  • Object between f and 2f: a large real image far away, the projector case.
  • Object inside f: a virtual, upright, enlarged image. The magnifying glass with the object 60 mm from a 100 mm lens gives dᵢ = −150 mm and m = 2.5.
  • Object exactly at f: the rays leave parallel and no image forms. The formula divides by zero, and Excel shows #DIV/0!.

A diverging lens always gives a virtual, upright, smaller image: f = −200 mm with an object at 300 mm gives dᵢ = −120 mm and m = 0.4.

From focal length to dioptres

Opticians describe lenses by their power in dioptres: P = 1 ÷ f with f in metres, or P = 1000 ÷ f with f in millimetres. The 100 mm projector lens has a power of 10 D. Thin lenses in contact simply add their powers, which is why glasses are written in dioptres rather than focal lengths. Spectacle lenses come in 0.25 D steps, so a calculated power is rounded with =ROUND(P*4,0)/4, the same trick as in rounding to the nearest 0.05.

Mirrors use the same equation

Curved mirrors follow the same relationship, 1/f = 1/dₒ + 1/dᵢ, with the focal length equal to half the radius of curvature, f = R ÷ 2. A concave mirror has f > 0 and works like a converging lens, a convex mirror has f < 0 and, like a car's passenger-side mirror, always shows a smaller upright virtual image.

Common mistakes

  • Mixed units. A focal length in millimetres and an object distance in metres give nonsense. Convert everything to one unit first.
  • Mixed sign conventions. A formula from one textbook with signs from another flips real and virtual images. Use one convention throughout.
  • Dropping the minus in m. m = dᵢ ÷ dₒ without the minus sign makes inverted images look upright.
  • An object at the focal point. 1/f − 1/dₒ is zero and the formula returns #DIV/0!. Wrap it in IF(C2=B2,"No image",…) if your inputs can hit f.
  • Applying it to thick lenses. Real camera lenses contain many elements. The equation still works, but distances are measured from the lens's principal planes, not from the front glass.
  • Dioptres from millimetres. P = 1 ÷ f needs f in metres. With f in millimetres use 1000 ÷ f, or a 100 mm lens comes out as 0.01 D instead of 10 D.

Frequently asked questions

What is the thin lens equation?

1/f = 1/do + 1/di, where f is the focal length, do the object distance and di the image distance, all measured from the lens in the same unit.

How do you calculate the image distance of a lens?

Rearrange the thin lens equation: di = 1 ÷ (1/f − 1/do), or di = f × do ÷ (do − f). A 50 mm lens with an object 150 mm away gives an image 75 mm behind the lens.

How do you know if an image is real or virtual?

With the real-is-positive convention, a positive image distance is a real image you can project on a screen, a negative one is a virtual image you can only see through the lens.

What is the magnification formula for a lens?

m = −di ÷ do. A negative value means the image is inverted, a positive value that it is upright, and a magnitude above 1 that it is larger than the object.

Practise it in a lab

Related guides

Reading is step one. Doing is step two.

Every guide links to a lab where you build the same calculation in an online spreadsheet and get instant feedback.

Open the lab