Object distance thin lens calculator
Give the focal length and the image distance and get the object position: f of 10 with an image at 15 puts the object at 30, with magnification −0.5, so the image is real and inverted. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
The identities are fully deterministic: one over f equals one over do plus one over di, which rearranges to do equals f times di over di minus f, and the lateral magnification is m equals negative di over do. Classic checks include a converging lens with f equals ten and di equals fifteen, which places a real inverted image from an object at do equals thirty with m equals negative one half, and a virtual image with f equals ten and di equals negative ten, which yields do equals five with m equals two. The engine uses only finite arithmetic with no network calls, no sampling, and no date-dependent shortcuts.
Where object-distance checks fit in study, labs, and software
Students meet this solve when a lab or homework set gives them a desired image plane and a known lens and asks how far the object must sit, when a contest problem wants do without a full ray diagram, or when they need to reverse-check an image-distance result from the companion thin-lens tool. Teachers can pre-generate answer keys for modest lengths without trusting opaque calculator apps that silently switch sign conventions or drop the minus in m.
Developers call the same contract from scripts to seed deterministic test vectors for optics widgets, to normalize user-entered f and di before a classroom demo, or to satisfy programming-challenge statements that demand object distance rather than a hand-waved sketch. Contest practice often needs a fast, offline source of object distances so solutions can be checked without graphing calculators under time pressure.
Product and education tools use the solve when a learner types focal length and image distance and the UI must show where the object should be, magnification, and whether the image is inverted.
What you can do with it
Homework and lab checks
Compute do and m from textbook f and di values; verify real vs virtual and inverted vs upright before sketching rays.
Tutoring and optics widgets
Normalize user-entered focal length and image distance for interactive lessons and object-placement demos.
FAQ
What does the object distance thin lens calculator cost?
It is free in your browser on this page.
How is object distance defined here?
Transverse magnification is m = −di/do (negative means inverted).
What happens if image distance equals focal length?
When di equals f, do is infinite (parallel rays in reverse) and the result is non-finite.
Why are results rounded to a precision?
Default precision is 10 decimal places; you can set precision from 0 to 15.
How do I know if the image is real or virtual?
Look at the sign of the image distance you entered. A positive value means a real image, a negative one a virtual image; for example, f of 10 with an image at −10 needs the object at 5, magnification 2.
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/object-distance-thin-lens \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"focal_length":10,"image_distance":15}'const res = await fetch("https://api.kit.forhosting.com/optics/object-distance-thin-lens", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"focal_length": 10,
"image_distance": 15
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/optics/object-distance-thin-lens",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"focal_length": 10,
"image_distance": 15
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/optics/object-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,"image_distance":15}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"focal_length":10,"image_distance":15}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/optics/object-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,
"image_distance": 15
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "optics.object_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.
Limits
max_abs_length | 1000000000000000 |
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
This object distance thin lens calculator takes a focal length and an image distance and returns the object distance and transverse magnification from the thin-lens equation used in introductory geometric optics.
What the object-distance solve returns and how to read the fields
The thin-lens equation relates three signed lengths along the optical axis: the object distance do, the focal length f, and the image distance di. Solving for the unknown object location gives do equals the product of f and di divided by di minus f. The transverse magnification m equals negative di over do, so a negative m means an inverted image and a positive m means an upright image, while the absolute value of m is the size ratio of image height to object height under the usual paraxial assumption. This calculator returns the normalized focal_length and image_distance you supplied, the computed object_distance and magnification rounded to the requested precision, an image_type tag of real when di is positive or virtual when di is negative, an orientation tag of inverted or upright from the sign of m, the precision used, a short formula string, and the method tag object_distance_thin_lens. There is no approximate ray-trace path and no random sampling of surfaces: the engine either builds exact floating-point do and m inside the supported length range or rejects the input with invalid_input. Rejected cases include missing f or di, non-finite values, magnitudes above the documented ceiling, any focal length or image distance that is zero or numerically zero, and the special case di equals f where the object recedes to infinity and do is non-finite.
How focal length and image distance are read and stay reproducible
Optional leading plus signs and scientific notation on length strings are allowed when they parse as finite decimals; embedded spaces, hex prefixes, and non-numeric tokens are rejected with a clear message so a bad cell does not become a wrong object plane. The preferred fields are focal_length for f and image_distance for di, but aliases f and focalLength for the focal length, and di, v, s_i, and imageDistance for the image distance, are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. Zero for either length is never valid: if absolute f or di is at or below a tiny epsilon, the request fails with invalid_input because one over that length is undefined. Equally important, when di equals f the denominator vanishes and the formula for do divides by zero, so that geometry is rejected with a clear invalid_input message rather than returning Infinity or NaN. An optional precision field, with aliases decimals and dp, chooses how many decimal places to expose for the numeric fields, defaulting to ten and capped at fifteen so JSON goldens stay stable. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing the object-distance formula yourself.
Where object-distance checks fit in study, labs, and software
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with the thin-lens image-distance and focal-length tools and other math and science endpoints when you are building a small lab of free, deterministic helpers for geometry, algebra, and introductory physics.
Integration use cases
Deterministic test fixtures
Generate reproducible object_distance and magnification for unit tests, property checks, and CI assertions.
Technical questions
Can focal length or image distance be zero?
No. f = 0 or di = 0 makes 1/f or 1/di undefined; both cases return invalid_input.