Thin Lens Equation Calculator
Introduction to thin-lens imaging and the Gaussian lens equation
A thin lens is an idealisation in which the glass is treated as having no measurable thickness, so that a ray entering and leaving the lens is bent once, at a single plane. That single simplification is what makes first-order optics tractable by hand. Under it, every property of the image formed by a spectacle lens, a loupe, a condenser, a camera objective or the eye itself follows from one relation between three lengths: the focal length of the lens, the distance from the lens to the object, and the distance from the lens to the image. This calculator solves that relation, reports the linear magnification and the image height that follow from it, converts the focal length into optical power in reciprocal metres, and draws the three principal rays so you can see where the answer comes from rather than simply trusting it.
The reason a dedicated tool helps here is not arithmetic difficulty. The reciprocal form of the equation is easy to evaluate but very easy to misread, because the answer changes character abruptly as the object crosses the front focal point. Move a subject from just outside the focal length to just inside it and the image jumps from real, inverted and enormous to virtual, upright and enlarged, with an unbounded discontinuity in between. Signs, not decimals, are where thin-lens problems are lost. Everything on this page is therefore built around making the sign of each quantity explicit, showing the convention being used, and refusing to print a number when the geometry does not actually produce a finite image.
How to use the thin lens equation calculator step by step
Start by choosing a length unit. Millimetres suit photographic and microscope optics, centimetres suit a classroom optical bench, metres suit spectacle and projection work, and inches are provided for imperial catalogue data. The unit you pick applies to all three lengths and to the results, so you never have to convert by hand; internally every value is normalised to metres before the equation is evaluated, which is also why the optical power output is always given in reciprocal metres regardless of the unit selected.
Next enter the focal length. Type a positive value for a converging (biconvex or positive meniscus) element and a negative value for a diverging (biconcave or negative meniscus) element. Enter the object distance as a positive number measured from the lens plane to the object; the calculator does not accept a negative object distance, because a virtual object only arises in a multi-element system where the preceding element has already converged the light, and that case needs a full sequential trace rather than a single application of the lens equation. Finally enter the object height, which sets the vertical scale of the diagram and lets the tool report an image height as well as a magnification.
Press Calculate to solve and draw the static diagram. Press Animate rays to watch the three principal rays propagate; the animation speed field controls what fraction of each ray leg is advanced on every frame, so it is a display setting and not a physical time step. Reset restores the worked example below, and Download CSV saves your solution together with the sensitivity sweep so the numbers can be pasted into a lab notebook or a spreadsheet.
Sign conventions and which formula this calculator implements
Two conventions are in common use and they disagree about signs while agreeing completely about physics. The real-is-positive convention, used by OpenStax University Physics Volume 3, treats a real object in front of the lens as a positive distance and a real image behind the lens as a positive distance, giving the familiar sum
Formula: 1 / f = 1 / d_o + 1 / d_i
The Cartesian convention, preferred in professional optical design and in texts such as Hecht's Optics and the University of Virginia ASTR 5110 optics notes, measures every axial distance from the lens with the direction of light propagation as the positive direction. An object to the left of the lens therefore has a negative coordinate, and the same physics is written as
Formula: 1 / s^′ - 1 / s = 1 / f
with magnification rather than . Because is negative where is positive, the two expressions return the same physical image position and the same inversion. This page implements the real-is-positive convention throughout, in the inputs, in the outputs and in the diagram. If you are working from a source that uses the Cartesian form, negate the object coordinate before entering it and the results will line up.
Formula derivation: Gaussian, Newtonian and magnification forms
Rearranging the Gaussian relation for the unknown image distance gives the expression the calculator actually evaluates,
Formula: d_i = (f d_o) / (d_o - f)
The denominator carries all the interesting behaviour. It is positive when the object lies outside the front focal point, zero when the object sits exactly on it, and negative when the object lies inside it. Linear magnification comes from similar triangles formed by the undeviated ray through the lens centre,
Formula: m = h_i / h_o = - d_i / d_o
so the image height is simply . Substituting the closed form for gives magnification directly in terms of the two lengths you enter,
Formula: m = - f / (d_o - f)
which shows immediately that magnification is unity in magnitude when , the symmetric one-to-one conjugate used for copy work and macro photography.
Measuring the same distances from the focal points instead of from the lens produces the Newtonian form. With the extrafocal distances and , direct substitution yields
Formula: x_o x_i = f^2
The calculator prints this product alongside as an internal consistency check. Finally, optical power is the reciprocal of the focal length expressed in metres,
Formula: P = 1 / f
and is reported in reciprocal metres, the unit conventionally named the dioptre. If you also need the focal length from the surface curvatures, the lensmaker's equation for a thin lens in air is , with each radius counted positive when that surface is convex toward the object.
Worked example: a 100 mm converging lens with the object at 150 mm
Take a converging lens of focal length m, a real object m in front of it, and an object height m. The denominator is m, so the image distance is m. Because that value is positive, the image is real and lies on the opposite side of the lens from the object, which is exactly where you would place a screen or a sensor.
Magnification follows as . The negative sign says the image is inverted; the magnitude says it is twice as large as the object. Image height is therefore m, meaning a 100 mm tall image pointing downward. Optical power is reciprocal metres. As a check, the extrafocal distances are m and m, whose product is 0.0100 square metres, identical to . This is the classic slide-projector geometry: an object a little outside the focal point throws a large inverted real image a long way beyond the lens.
A second example contrasting a diverging lens with a simple magnifier
Keep the object at 0.150 m but swap in a diverging lens of m. The denominator becomes m and the image distance is m, with magnification . Negative image distance means a virtual image on the object side; positive magnification means it is upright; a magnitude below one means it is reduced. That is precisely what you see looking through a myopic spectacle lens, and a diverging lens can never do anything else, whatever the object distance.
Now return to the 0.100 m converging lens but move the object inside the focal length, to m. The denominator is now m, the image distance is m and the magnification is : a virtual, upright, doubled image standing 0.100 m behind the object. This is the simple magnifier, and it is the case in which the phrase "the image is at negative 100 mm" confuses people most, because nothing is physically located there. The table below sets the three scenarios side by side.
| Scenario | f (m) | do (m) | di (m) | m | Image character |
|---|---|---|---|---|---|
| Projector geometry | 0.100 | 0.150 | 0.300 | -2.00 | Real, inverted, enlarged |
| Diverging lens | -0.100 | 0.150 | -0.0600 | 0.400 | Virtual, upright, reduced |
| Simple magnifier | 0.100 | 0.0500 | -0.100 | 2.00 | Virtual, upright, enlarged |
Reading the ray diagram and interpreting your result
The diagram draws the optical axis, the lens plane, and the front and rear focal points marked F and F'. Three principal rays leave the tip of the object arrow. The first travels parallel to the axis and is refracted through the rear focal point. The second passes through the centre of the lens undeviated. The third heads for the front focal point and emerges parallel to the axis. All three cross at the image tip, which is why any two of them are sufficient to construct an image graphically.
Solid lines are real light. Dashed lines are backward extensions that no photon ever travels. Whenever the image distance is negative the calculator draws the refracted rays diverging forwards to the edge of the frame, as they physically do, and traces the dashed extensions back to the virtual image position, which is drawn as a dashed arrow. This distinction is the single most common error in hand-drawn diagrams, and it is worth checking against the sign of your own result: negative image distance and dashed rays should always appear together. When the image lies far beyond the frame the diagram compresses the axis and says so in the caption instead of silently rescaling the object out of visibility.
Object-distance sensitivity and the image-at-infinity limitation
The sweep table generated below your result evaluates the same equation at a series of object distances expressed as multiples of the focal-length magnitude. It exists because the sensitivity of image position to object position is wildly non-uniform. Differentiating the closed form gives
Formula: (d d_i) / (d d_o) = - f^2 / (d_o-f)^2
which is the longitudinal magnification, equal in magnitude to . Near the focal point that derivative blows up, so a millimetre of focusing error moves the image by centimetres; far from the lens it collapses toward zero, which is why a lens focused at infinity barely changes as the subject recedes further. Exactly at the equation has a genuine pole: the emergent rays are parallel and there is no finite image. The calculator detects this with a relative tolerance rather than an absolute one, so the behaviour is identical whether you work in millimetres or metres, and it reports the collimated case in words instead of printing Infinity.
Limitations and assumptions behind the paraxial thin-lens model
Every result here rests on assumptions that are worth stating plainly. The lens is treated as infinitely thin, so the two principal planes coincide at a single point; in a real lens they are separated, and distances must be measured from the appropriate principal plane rather than from the glass. Rays are assumed paraxial, meaning small angles for which the sine of an angle may be replaced by the angle itself; outside that regime spherical aberration, coma, astigmatism and field curvature all displace the image from the position computed here. The model is monochromatic, so chromatic aberration arising from the wavelength dependence of refractive index is absent. Diffraction is ignored entirely, which means the predicted image of a point is a point rather than an Airy pattern, and no resolution limit is implied.
Aperture effects are outside the scope of the equation as well. Image brightness, depth of field and the stop number of a photographic lens depend on the entrance pupil, not on the conjugate distances; ISO 517:2008 defines those aperture quantities and explicitly restricts its stop-number designations to lenses focused on objects at infinity, meaning at least fifty times the focal length. Finally, the calculator handles a single element. A multi-element system can be worked through by applying the equation sequentially, using the image from one element as the object for the next and allowing negative object distances at the later surfaces, but that bookkeeping is not automated here.
Sources consulted for the equations and conventions
The thin lens equation, the magnification definition, the real-is-positive sign convention and the lensmaker's equation are taken from Ling, Sanny and Moebs, University Physics Volume 3, section 2.4 "Thin Lenses", published by OpenStax at Rice University (openstax.org). The contrasting Cartesian convention, in which the lens relation is written with a minus sign and magnification as , follows Hecht, Optics (Pearson), and the University of Virginia course notes for ASTR 5110, "Optics I" (virginia.edu). Aperture terminology and the infinity-focus restriction are from ISO 517:2008, Photography — Apertures and related properties pertaining to photographic lenses — Designations and measurements (iso.org). Geometrical-optics background follows MIT OpenCourseWare 2.71 Optics, Spring 2014 lecture notes (ocw.mit.edu). The dioptre is not a named SI unit; optical power is reported here in reciprocal metres, which is numerically identical.
Related tools on this site include the Lens Maker's Equation Calculator for obtaining a focal length from surface radii and refractive index, and the Thin Lens Magnification Calculator for magnification-only problems.
Object-distance sensitivity sweep
Each row solves the same equation at an object distance expressed as a multiple of the focal-length magnitude, so you can see how quickly the image position and magnification change around your operating point.
Common questions about the thin lens equation
Which sign convention does this thin lens equation calculator use?
It uses the real-is-positive convention published in OpenStax University Physics Volume 3, section 2.4. The object distance do is positive for a real object in front of the lens, the image distance di is positive for a real image on the far side of the lens and negative for a virtual image on the object side, and the focal length f is positive for a converging lens and negative for a diverging lens. Magnification is m = -di/do, so a negative m means an inverted image and a positive m means an upright one.
What does the calculator do when the object distance equals the focal length?
When do equals f the denominator do - f goes to zero, the emerging rays leave the lens parallel to one another, and no image forms at any finite distance. The calculator detects this with a relative tolerance of one part in a million rather than a fixed absolute tolerance, so it behaves the same whether you work in millimetres or in metres, and it reports an image at infinity instead of printing Infinity or NaN.
Why is the image distance negative when a converging lens is used as a magnifier?
A simple magnifier puts the object inside the focal length, so do is smaller than f and the quantity do - f is negative. The image distance di is then negative, which in this convention means a virtual image on the same side of the lens as the object, and the magnification m = -di/do comes out positive, so the image is upright and enlarged. No light actually converges there, which is why the ray diagram draws the backward extensions as dashed lines.
How does the Newtonian form of the lens equation relate to the Gaussian form?
The Newtonian form measures distances from the focal points instead of from the lens plane. Writing xo = do - f and xi = di - f, the Gaussian relation 1/f = 1/do + 1/di rearranges exactly into the product xo times xi = f squared. The calculator prints that product next to f squared so you can confirm the two forms agree for your own inputs, which is a quick way to catch a mistyped focal length.
Can I use this for camera lenses or an eyeglass prescription?
It gives the paraxial first-order answer that optical power and simple focusing calculations are built on, namely P = 1/f with f in metres and P in reciprocal metres, the unit usually called the dioptre. It ignores lens thickness, the separation of the principal planes, aberrations and diffraction, so treat it as a design starting point rather than as a substitute for measured lens data or a professional eye examination.
Arcade Mini-Game: Thin Lens Sign-Convention Drill
Use this quick arcade run to practise separating correct thin-lens statements from the sign-convention mistakes that break most lens problems.
Start the game, then use your pointer or arrow keys to catch correct statements and avoid sign-convention errors.
