Lens Formula Calculator — Interactive Ray Diagram and Image Formation

The lens formula relates the focal length of a lens to the object distance and image distance. It underpins all of optics — from your eye and spectacle lenses to microscopes, telescopes, cameras, and projectors. Understanding how lenses form images, and whether those images are real or virtual, upright or inverted, is central to optics and vision science.

Use the interactive ray diagram below to see image formation change as you move the object closer or further from the lens.

Image distance v

40.0 cm (real)

Magnification m

-1.00 (inverted)

Image height

3.0 cm

20 cm
40 cm

The Lens Formula

Using the real-is-positive sign convention:

1v1u=1f\frac{1}{v} - \frac{1}{u} = \frac{1}{f}

where uu is always negative (object is to the left of the lens).

Equivalently written as:

1f=1v+1uwhere u=u\frac{1}{f} = \frac{1}{v} + \frac{1}{u'} \quad \text{where } u' = |u|

SymbolQuantitySign convention
fFocal length+ = convex (converging), − = concave (diverging)
uObject distancealways negative (object on left)
vImage distance+ = real image (right), − = virtual image (left)

Magnification

m=vum = -\frac{v}{u}

  • m>0m > 0: upright image
  • m<0m < 0: inverted image
  • m>1|m| > 1: image is larger than object (magnified)
  • m<1|m| < 1: image is smaller than object (diminished)

Worked Examples

Worked Example

Example 1 — Object beyond 2f (convex lens)

A convex lens has focal length f = 15 cm. An object is placed 45 cm from the lens. Find the image distance and magnification.

Using u=45u = -45 cm, f=+15f = +15 cm:

1v=1f+1u=115+145=345145=245\frac{1}{v} = \frac{1}{f} + \frac{1}{u} = \frac{1}{15} + \frac{1}{-45} = \frac{3}{45} - \frac{1}{45} = \frac{2}{45}

v=452=22.5 cmv = \frac{45}{2} = 22.5 \text{ cm}

Since v>0v > 0, the image is real and on the opposite side of the lens.

Using the Cartesian magnification formula m=v/um = v/u:

m=vu=+22.545=0.5m = \frac{v}{u} = \frac{+22.5}{-45} = -0.5

Since m<0m < 0, the image is inverted. Since m=0.5<1|m| = 0.5 < 1, the image is diminished.

The image is real, inverted, and half the size of the object — exactly what you expect when the object is beyond 2f2f of a converging lens.

Worked Example

Example 2 — Object inside focal length (convex lens)

The same lens (f = 15 cm) with object placed 10 cm away (inside the focal length).

Using u=10u = -10 cm, f=+15f = +15 cm:

1v=115+110=230330=130\frac{1}{v} = \frac{1}{15} + \frac{1}{-10} = \frac{2}{30} - \frac{3}{30} = -\frac{1}{30}

v=30 cmv = -30 \text{ cm}

Since v<0v < 0, the image is virtual — it appears on the same side as the object (this is how a magnifying glass works).

m=vu=3010=+3m = \frac{v}{u} = \frac{-30}{-10} = +3

Since m>0m > 0, the image is upright. Since m=3>1|m| = 3 > 1, it is magnified — this is exactly how a magnifying glass works.


Frequently Asked Questions

Explore more simulations

Every concept on PhysicStuff has an interactive visualisation — no login, no setup required.