The thin lens equation
1/f = 1/d₀ + 1/dᵢ Solved for focal length: f = (d₀ × dᵢ) ÷ (d₀ + dᵢ) Example: d₀=30cm, dᵢ=15cm — f = (30×15)÷(30+15) = 10cm d₀ is the object distance (from the object being photographed to the lens), and dᵢ is the image distance (from the lens to where the image actually forms — the camera sensor, for a properly focused shot). This calculator uses the real-is-positive sign convention, standard in most introductory physics courses: positive distances for a real object and a real image forming on the far side of the lens — the everyday case for a camera actually taking a photo. A negative image distance represents a virtual image instead (the kind a magnifying glass produces when held close to an object, rather than a lens projecting light onto a sensor).
Why focusing only moves the lens a tiny amount
Something genuinely counterintuitive falls out of this formula: as the object distance grows very large, the image distance gets closer and closer to the focal length itself, and barely moves from there no matter how much farther the object gets. A 50mm lens focusing on a subject 3 meters away forms its image about 50.85mm behind the lens — less than a millimeter past the focal length. Push the subject out to 10 meters, and that gap shrinks even further. This is exactly why autofocus mechanisms only need to shift a lens element by a fraction of a millimeter to rack focus across most of a scene — the image distance simply doesn't have much room to move once the subject is more than a few focal lengths away. At true infinity, the image distance and focal length become exactly equal, which is the actual definition of what "focal length" means physically: the distance behind the lens where parallel rays from infinitely far away converge.
The Portrait Lens Focus Shift Example
Imagine you are shooting a head-and-shoulder portrait using a standard 50 mm prime lens (f = 50 mm). You start by framing a subject standing far away at infinity, then step in to take a tighter shot at a subject distance of 1.5 m (1,500 mm).
1/50 = 1/∞ + 1/dᵢ ⇒ dᵢ = 50mm 1/50 = 1/1500 + 1/dᵢ 1/dᵢ = 1/50 - 1/1500 = (30 - 1) / 1500 = 29/1500 dᵢ = 1500/29 ≈ 51.72mm Δd = dᵢ(closer) - dᵢ(infinity) = 51.72 - 50 = 1.72mm The resulting magnification is M = -51.72 / 1500 ≈ -0.0345x. This means the image on the sensor is inverted, scaled down to about 3.45% of life size, and roughly 29 times smaller than the subject. Crucially, the internal lens elements only need to travel 1.72 mm to shift focus from infinity down to 1.5 meters, explaining why camera autofocus is so fast and requires microscopic physical movement.
Setting Up 1:1 Macro Photography Example
When capturing a life-size macro photograph of an insect, you want a 1x magnification (M = -1) where the subject and its sensor projection are identical in size. For a single thin lens, this requires the object distance to equal the image distance (d₀ = dᵢ = 2f).
Object Distance (d₀) = 2 × 100mm = 200mm Image Distance (dᵢ) = 2 × 100mm = 200mm Total Track Length (d₀ + dᵢ) = 400mm How to verify with this calculator: Plug d₀ = 200 mm and dᵢ = 200 mm into the calculator above. It will instantly output a focal length of 100 mm and a magnification of exactly -1x.
Frequently asked questions
How do you calculate the focal length of a lens?
Using the thin lens equation: 1/f = 1/d₀ + 1/dᵢ, which rearranges to f = (d₀ × dᵢ) ÷ (d₀ + dᵢ). An object 30cm from the lens forming an image 15cm behind it gives a focal length of 10cm.
What is the difference between object distance and image distance?
Object distance is how far the actual subject is from the lens. Image distance is how far behind the lens the resulting image actually forms — for a camera in focus, that's the distance from the lens to the sensor.
What does negative magnification mean?
The image is inverted (upside down) relative to the object — the normal case for a real image formed by a single converging lens, exactly what happens inside a camera. The magnitude of the number (ignoring the sign) tells you the size ratio: a magnification of -0.5× means the image is half the size of the object, flipped.
How do you calculate object and image distances for 1× (life-size) magnification?
For a true 1:1 life-size reproduction (where magnification M = -1), the object distance must equal the image distance, and both equal twice the focal length (d₀ = dᵢ = 2f). For example, a 100 mm macro lens requires both the subject and the sensor to be positioned 200 mm away from the lens, resulting in a total track length of 400 mm.
Why does changing focus distance require such a tiny physical movement inside a camera lens?
As subject distance increases beyond a few focal lengths, the image distance converges closer and closer to the focal length itself. For instance, shifting a 50 mm lens from infinity to a 1.5-meter subject changes the image distance by only about 1.72 mm, which is why autofocus systems only require microscopic internal movements.