› Lens Magnification & Ray Tracing Simulator Back
Optics

Lens Magnification & Ray Tracing Simulator

Change focal length and object distance to calculate image position, magnification, and real/virtual nature in real time. Confirm principal ray paths via Canvas ray diagram for converging and diverging lenses.

Parameters

Preset
Results
Real, inverted
Image distance b
—
Magnification m
—
Image height
—
Image type
—
Rays
Blue: object / red: real image (dashed: virtual image) / yellow: focal points / orange and green: rays
1
Visualization
Theory & Key Formulas

$\dfrac{1}{a} + \dfrac{1}{b} = \dfrac{1}{f}$

Magnification: $m = -\dfrac{b}{a}$

b > 0 → real image; b < 0 → virtual image
m < 0 → inverted (real image); m > 0 → upright (virtual image)

Dialogue: deepen your understanding

🙋
Professor, when I look at something through a magnifying glass I can see an enlarged image without any screen. Where is that image?
🎓
What you see through a magnifier is a virtual image. If you place the object inside the focal length (a < f), the rays never actually converge, but looking through the lens you see an enlarged image where their extensions meet. It can't be projected on a screen, but the lens of your eye converges the rays again and forms a real image on the retina, so you “see” it. It appears on the same side as the object, enlarged and farther away.
🙋
What about a camera, then? The image appears on the sensor, so that's a real image, right?
🎓
Exactly! A camera uses a real image. It forms a reduced real image of a distant scene (a ≫ 2f) on the sensor. For example, photographing a person 10 m away with a 50 mm lens gives an image distance b = 1/(1/50 − 1/10000) ≈ 50.25 mm and a magnification b/a ≈ 0.005, about 1/200 of the original size. That image is then enlarged digitally for display.
🙋
A projector is the reverse of a camera, isn't it? It throws the film onto a big screen, so that's an enlarged real image?
🎓
Precisely! A projector uses a camera “in reverse”. Place the film between the focal length f and twice the focal length 2f (f < a < 2f) and an enlarged real image forms far away on the other side. The “Projector” preset uses f = 15 cm and a = 18 cm (between f and 2f), so you can see the strongly enlarged real image for yourself.
🙋
When I put the object exactly at the focus (a = f) it says “no image”. Why?
🎓
Substitute a = f into 1/a + 1/b = 1/f and you get 1/b = 0, i.e. b = ∞. Light from the focal point leaves the lens as a parallel beam that “meets” only at infinity, so there is no crossing point at any finite distance. Flashlights and searchlights use exactly this principle: the light source sits at the focus so the beam travels far as parallel light.
🙋
Is it true that a concave lens can only ever form a virtual image? I heard they are used in glasses for short-sightedness.
🎓
Yes. Wherever you place the object, a concave lens only forms a reduced virtual image. Glasses for myopia use a concave lens to spread the parallel light from distant objects slightly. The eye would otherwise focus in front of the retina (which is why things look blurred); the concave lens diverges the light so the focus moves back onto the retina. Interestingly, because a concave lens shows things reduced, people with myopia may see the scene slightly smaller when they put their glasses on.

Frequently Asked Questions

The formula is $\dfrac{1}{a} + \dfrac{1}{b} = \dfrac{1}{f}$. Here, a: object distance (always positive), b: image distance (positive for real image, negative for virtual image), f: focal length (positive for convex lens, negative for concave lens). Magnification is given by $m = -b/a$, where |m| > 1 means enlargement, 0 means an upright image (virtual image).
A real image is formed when light rays actually converge at a point; it can be projected onto a screen, photographic film, or sensor (e.g., camera, projector). A virtual image is an "apparent image" formed by the extension of light rays; it cannot be projected onto a screen but can be seen by the eye (e.g., magnifying glass, plane mirror, concave lens). In ray diagrams, real images are shown with solid arrows, and virtual images with dashed lines.
For a convex lens, when a 1). The magnification is expressed as $m = f/(f-a)$, approaching infinity as a approaches f. This is the operating principle of a magnifying glass or loupe.
In a camera, the object is placed at a > 2f (distant subject), forming a reduced real image on the sensor. In a projector, the object (film) is placed at f < a < 2f, forming an enlarged real image on the screen (at a distant position). When a = 2f, b = 2f, producing a life-size real image. This "symmetry of two 2f points" means an object between 2f and 2f forms a real image of the same size at the opposite 2f point.
For nearsightedness (myopia), the eyeball is too long, so the image forms in front of the retina. A concave lens (negative focal length) diverges light, shifting the image point backward (onto the retina). For farsightedness (hyperopia), the eyeball is too short, so the image forms behind the retina. A convex lens converges light. The lens power (diopter D) is the reciprocal of the focal length in meters: D = 1/f. For example, a myopic lens with f = −0.5 m is written as −2.0 D.

How to Use

  1. Enter object distance (sa) in centimeters from the lens principal plane
  2. Input focal length (sf) in centimeters; use positive values for converging lenses, negative for diverging lenses
  3. Set object height (sh) in millimeters to trace ray paths and calculate image magnification
  4. Click Calculate to apply the thin lens equation (1/f = 1/so + 1/si) and determine image distance, magnification, and image type
  5. Review ray diagram showing object, lens, focal points, and principal rays for optical verification

Worked Example

A biconvex lens with focal length f = 50 mm positions an object 120 mm away. Using 1/f = 1/so + 1/si: 1/50 = 1/120 + 1/si yields si = 85.7 mm (real, inverted image beyond the focal point). Magnification m = -si/so = -0.714, so a 10 mm tall object produces a 7.14 mm inverted image. Ray tracing confirms convergence at the image plane, typical for microscopy and camera optics applications.

Practical Notes

🎬 Watch it in motion

Thin Lens | rays converge and an image appears #Shorts
Thin Lens | rays converge and an image appears #Shorts