Thin lens image distance calculator
Know where to put the screen: a lens with a focal length of 10 and an object 30 away forms a real, inverted image 15 away, in whatever length unit you used for both inputs. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Focal length
- 10
- Object distance
- 30
- Image distance
- 15
- Image type
- real
- Orientation
- inverted
- Precision
- 10
The thin lens image distance calculator solves the Gaussian thin lens equation when you know the lens focal length and the object's signed distance from the lens. It returns the signed image distance and labels the result as a real or virtual image, making the sign meaningful instead of presenting an unexplained number. Use any consistent length unit—millimeters, centimeters, meters, or inches—because the equation depends on ratios.
Enter distances with a consistent sign convention
A thin-lens calculation is only as clear as its sign convention. Enter a positive focal length for a converging lens and a negative focal length for a diverging lens. A normal real object placed in front of the lens has a positive object distance.
Both inputs must use the same physical unit, but you do not need to tell the calculator which unit it is. If focal length is entered in millimeters, image distance is returned in millimeters; if both inputs are in centimeters, the answer is in centimeters. Do not mix a focal length in millimeters with an object distance in centimeters unless you convert one first.
The result is signed: a positive image distance describes a real image on the image side of the lens, while a negative image distance describes a virtual image on the object side. This convention lets one equation cover converging lenses, diverging lenses, real objects, and virtual-object setups without silently discarding the physical meaning of direction.
Understand the equation and the singular case
Combining the fractions and inverting gives di = f·do/(do-f). The calculator evaluates that expression with finite-number validation and rounds only the returned fields to the requested precision. One configuration needs special attention: when object distance equals focal length, the denominator do-f is zero.
Geometrically, rays leaving the lens are parallel, so the image is described as being at infinity rather than at a finite location. Inputs of zero are also rejected because the reciprocal form of the thin lens equation would be undefined. Values extremely close to the focal plane can produce very large finite answers, matching the strong sensitivity expected near focus; ensure your measurements have enough precision before interpreting such a result as an exact placement distance.
Interpret the result in optical work
A positive value is labeled real and inverted, which is the common case when a real object sits beyond the focal point of a converging lens. A screen or sensor can be placed approximately that signed distance from the lens to intercept the focused image, subject to the limits of the thin-lens approximation. A negative value is labeled virtual and upright.
Such an image cannot be projected directly onto a screen at that location; an observer sees it by tracing the emerging rays backward. This occurs for a converging lens when the object lies inside its focal length and for many ordinary uses of a diverging lens. Real lenses have thickness, principal planes, aberrations, wavelength dependence, and mounting tolerances that the ideal equation does not model.
Measure distances from the appropriate principal plane when precision matters, and regard the result as a first-order design value.
What you can do with it
Place a camera sensor
Estimate the sensor-to-lens distance required to focus an object at a known distance with an ideal thin lens.
Check a classroom optics problem
Solve image distance and confirm whether the expected image is real and inverted or virtual and upright.
Screen an optical design
Evaluate many focal-length and object-distance combinations before moving to a detailed ray-tracing model.
FAQ
What units should I use?
Use any length unit, but use the same unit for focal length and object distance. The image distance is returned in that unit.
Why is my image distance negative?
A negative image distance indicates a virtual, upright image under the stated Gaussian sign convention.
What happens when object distance equals focal length?
The ideal image is at infinity, so the calculator returns an input error rather than a finite distance.
Where do I place the screen for a lens of focal length 10 and an object at 30?
At 15 from the lens, in the same unit as your inputs. The positive value means a real, inverted image that a screen or sensor can catch on the far side of the lens.
How do I enter a diverging lens?
Give it a negative focal length and keep a normal object in front of the lens at a positive distance. The image distance then comes out negative, which the result labels as virtual and upright.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/optics/image-distance-thin-lens \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"focal_length":10,"object_distance":30}'const res = await fetch("https://api.kit.forhosting.com/optics/image-distance-thin-lens", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"focal_length": 10,
"object_distance": 30
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/optics/image-distance-thin-lens",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"focal_length": 10,
"object_distance": 30
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/optics/image-distance-thin-lens", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"focal_length":10,"object_distance":30}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"focal_length":10,"object_distance":30}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/optics/image-distance-thin-lens", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"focal_length": 10,
"object_distance": 30
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "optics.image_distance_thin_lens",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
The calculation is deterministic, runs without network access, and is available for individual checks or repeatable API workflows.
Enter distances with a consistent sign convention
This calculator uses the Gaussian convention represented by 1/f = 1/do + 1/di.
Understand the equation and the singular case
Starting from the thin lens equation, 1/f = 1/do + 1/di, isolate the unknown reciprocal to obtain 1/di = 1/f - 1/do. Because infinity is not a usable JSON distance, the calculator reports that configuration as an input error instead of returning a misleading enormous number or a null field.
Interpret the result in optical work
The returned image_distance is the primary answer. For repeated calculations, the API costs $0.002 per request and returns the formula, normalized inputs, classification, and chosen precision alongside the distance so downstream records remain understandable.
Technical questions
Which equation does the calculator use?
It uses 1/f = 1/do + 1/di and solves it as di = f·do/(do-f).
How much does the API request cost?
Each API calculation costs $0.002. The computation is deterministic and requires no external service.