Measuring a lens without a data sheet
A lens often arrives with no focal length marked on it, or with a value you want to confirm. If you can place a bright object at a known distance and find where a sharp image forms on a screen, you have enough to work it out. This page takes those two distances and returns the focal length of the lens. The same arithmetic applies to a magnifier you found in a drawer, a spectacle lens, a projector element or a lens from a physics lab kit. The result stays in whatever length unit you typed, so centimeters in gives centimeters out, as long as both inputs use the same unit. Enter meters if you want the focal length in meters, which is how the default values are labeled.
The thin-lens equation behind the page
For a thin lens the reciprocal of the focal length equals the sum of the reciprocals of the object and image distances: 1/f = 1/o + 1/i. Combine the two fractions over a common denominator and invert, and you get f = o × i / (o + i), which is the expression the page evaluates. OpenStax College Physics presents this relationship in its chapter on image formation by lenses. The equation assumes a lens thin enough that the distance between its two surfaces can be ignored, and rays close to the optical axis so that the paraxial approximation holds. Within those limits it describes converging and diverging lenses with one formula, provided each distance carries the correct sign.
Object at 0.3 m, image at 0.15 m
The page starts with an object distance of 0.3 m and an image distance of 0.15 m. The product is 0.045 and the sum is 0.45, so the focal length is 0.1 m, or 10 cm. A quick check with reciprocals agrees: 1/0.3 is about 3.333 and 1/0.15 is about 6.667, which add to 10, and 1/10 gives back 0.1 m. The object here sits at three times the focal length, so the image forms at one and a half focal lengths on the far side and is smaller than the object. Changing the object distance while holding the lens fixed would move the image, but it would not change the focal length, which is a useful sign that your measurements are consistent.
Sign convention for real and virtual images
The page expects signed distances. Use a positive object distance for a real object in front of the lens, and a positive image distance when a real image forms on the opposite side, where a screen can catch it. A negative image distance means a virtual image on the same side as the object, which is what you see through a magnifying glass. A negative focal length belongs to a diverging lens. Mixing conventions is the most common source of wrong answers. If your textbook measures distances differently, convert them before entering values, and do not enter a magnitude for a virtual image, because dropping its minus sign changes the answer to a different lens entirely.
More worked cases
An object at 0.6 m with a sharp image at 0.3 m gives 0.18 / 0.9, so f = 0.2 m. An object at 0.9 m with an image at 0.1 m gives 0.09 / 1.0, which is 0.09 m. A magnifier held 0.05 m from a stamp that shows an upright virtual image 0.15 m behind the lens on the same side uses the signed value -0.15 for the image. The product is -0.0075 and the sum is -0.10, so f = 0.075 m, a converging lens. A diverging lens might form a virtual image 0.1 m from the lens for an object at 0.4 m. Entering 0.4 and -0.1 gives -0.04 / 0.3, about -0.13333 m, where the negative sign marks the lens as diverging.
Getting good readings on a bench
Mount the lens, the object and the screen on a rail and measure from the lens center, not from the edge of the holder. Slide the screen until the image looks sharpest, then move it a little past that point and back to find the middle of the range where it still looks acceptable. The depth of focus makes the image look sharp over a short span, so repeat the measurement several times and average. Moving the object to a different distance and repeating gives an independent estimate of f. If the estimates disagree by more than your measuring error, check for a lens that is too thick, a tilted screen or an object that is not on the optical axis.
From focal length to lens power
Optometrists and lens makers often quote power in diopters, which is the reciprocal of focal length in meters. The default lens with f = 0.1 m has a power of 10 D, and the 0.2 m lens from the earlier case has 5 D. Converging lenses have positive power and diverging lenses negative power, which matches the sign of f on this page. Because power is the reciprocal, two thin lenses placed close together add their powers, so the combined focal length is the reciprocal of the sum. A 0.2 m lens and a 0.1 m lens in contact behave like a lens of 15 D, or about 0.0667 m. Convert units before comparing numbers from different sources.
Where the model stops
The page is a scalar educational calculator, and it requires a finite result. If the object and image distances add up to zero, the formula divides by zero and there is no finite focal length to report. That situation corresponds to an object at the focal point of a converging lens, where the rays leave parallel and no image forms at a finite distance, or to inconsistent signs in the input. Thick lenses, compound lens systems, aberrations and rays far from the axis all depart from this equation. Use the result as an estimate of a single thin lens, and consult the manufacturer or an optical design tool when precise performance matters.
Camera lenses and distant objects
Photographic lenses give a useful special case. When the subject is far away, the object distance is much larger than the focal length, the sum in the denominator is nearly equal to the object distance, and the formula returns a focal length very close to the image distance. That is why a lens focused at infinity sits one focal length from the sensor. For a 50 mm lens (0.05 m) focused on a subject 3 m away, the sensor must sit at about 0.050847 m behind the lens, so the lens extends by under a millimeter. Entering 3 and 0.050847 returns 0.05 m again. Close-up work shows the opposite effect: as the subject approaches twice the focal length, the image distance also approaches twice the focal length and the image reaches life size.