Physics

Thin-Lens Equation Calculator

Image distance and magnification for a thin lens, from the focal length and object distance.

Real Larzscript running in your browser74 automated checksOpen source · MITNo sign-up · your inputs never leave your device

Thin-lens equation

Image distance dᵢ
—
Magnification (-dᵢ/dₒ)
—
Show the Larzscript program that just ran
Run a calculation to see the exact program.

This is the real program the page sent to the Larzscript interpreter (compiled to WebAssembly) in your browser. The library it imports is the same code the automated tests check.

The formula

1/f = 1/d₀ + 1/dⁱ    m = -dⁱ/d₀

Worked example, computed above

f = 10 cm, dₒ = 30 cm: image distance 15 cm, magnification -0.5 (inverted, reduced).

What is verified

The focal length round-trips exactly back out of a computed object/image distance pair, matching the thin-lens equation in reverse — see tests/test_emwaves.lz.

Frequently asked questions

What is the thin-lens equation?

1/f = 1/dₒ + 1/dᵢ — relates the focal length f, object distance dₒ and image distance dᵢ for an idealized thin lens. A converging lens of f = 10 cm with the object at dₒ = 30 cm forms an image at dᵢ = 15 cm.

What does the magnification mean?

m = -dᵢ/dₒ. Here m = -0.5: negative means inverted, and |m| < 1 means smaller than the object — a real, inverted, reduced image, as a camera lens forms.

What if the object is inside the focal length?

Putting the object closer than f (dₒ = 5 cm with f = 10 cm) gives a negative image distance (-10 cm) and magnification 2: a virtual, upright, magnified image — exactly how a magnifying glass is used.

Does the sign convention matter?

Yes — this page uses the common convention where a positive f is a converging lens, positive dₒ is a real object in front of the lens, positive dᵢ is a real image on the far side, and negative dᵢ signals a virtual image on the same side as the object.

Every number on this page is computed by the open-source larzscript-physics library (emwaves, physmath), written in Larzscript, and checked against independent references in its test suite. How it is verified →