ForHosting KIT · Science

Thin lens calculator

An object 30 units from a lens with a focal length of 10 forms a real, inverted image 15 units away at half size. Enter object distance and focal length to get image distance, magnification and image type. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Object distance (dₒ)
30
Focal length
10
You get
Image distance
15
Magnification
-0.5
Image type
real
Orientation
inverted

This thin lens calculator takes an object distance and a focal length and returns the image distance and transverse magnification from the thin-lens equation used in introductory geometric optics. The identities are fully deterministic: one over f equals one over do plus one over di, which rearranges to di equals f times do over do minus f, and the lateral magnification is m equals negative di over do. Classic checks include a converging lens with do equals thirty and f equals ten, which places a real inverted image at di equals fifteen with m equals negative one half, and a near object with do equals five and f equals ten, which yields a virtual upright image at di equals negative ten with m equals two. The engine uses only finite arithmetic with no network calls, no sampling, and no date-dependent shortcuts.

Where thin-lens checks fit in study, labs, and software

Students meet the thin-lens equation when a lab asks them to measure image distance for a known lens, when a homework set asks whether an image is real or virtual, or when a contest problem wants magnification without a full ray diagram. 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 do and f before a classroom demo, or to satisfy programming-challenge statements that demand di and m rather than a hand-waved sketch. Contest practice often needs a fast, offline source of image distances so solutions can be checked without graphing calculators under time pressure.

Product and education tools use the solve when a learner types object distance and focal length and the UI must show image location, magnification, and whether the image is inverted.

Homework and lab checks

Compute di and m from textbook do and f values; verify real vs virtual and inverted vs upright before sketching rays.

Tutoring and optics widgets

Normalize user-entered object distance and focal length for interactive lessons and quick magnification demos.

What does the thin lens calculator cost?

It is free in your browser on this page.

How are image distance and magnification defined?

Transverse magnification is m = −di/do (negative means inverted).

What if the object sits at the focal point?

When do equals f, di is infinite (parallel rays).

Why are results rounded to a precision?

Default precision is 10 decimal places; you can set precision from 0 to 15.

How can I tell whether the image is real or virtual?

Look at the sign of the image distance. A positive value means a real image on the far side of the lens; a negative one means a virtual image. An object at 5 with a focal length of 10 gives −10: a virtual, upright image twice as large.

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.

POSThttps://api.kit.forhosting.com/optics/thin-lens

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.

curl -X POST https://api.kit.forhosting.com/optics/thin-lens \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"object_distance":30,"focal_length":10}'
{
  "object_distance": 30,
  "focal_length": 10
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "optics.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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_abs_length1000000000000000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

What the thin-lens equation 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 image location gives di equals the product of f and do divided by do 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 object_distance and focal_length you supplied, the computed image_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 thin_lens. There is no approximate ray-trace path and no random sampling of surfaces: the engine either builds exact floating-point di and m inside the supported length range or rejects the input with invalid_input. Rejected cases include missing do or f, non-finite values, magnitudes above the documented ceiling, any object distance that is zero or numerically zero, and the special case do equals f where the image recedes to infinity and di is non-finite.

How object distance and focal length 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 image plane. Focal length may be positive for a converging lens or negative for a diverging lens under the Gaussian sign convention used here; object distance is treated as a signed length as well, matching textbook problem sets that place real objects on the incident side with positive do. The preferred fields are object_distance for do and focal_length for f, but aliases do, u, s_o, and objectDistance for the object distance, and f and focalLength for the focal length, are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. Zero for object distance is never valid: if absolute do is at or below a tiny epsilon, the request fails with invalid_input because both one over do and magnification over do are undefined. 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 thin-lens formulas yourself.

Where thin-lens 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 other math and science endpoints when you are building a small lab of free, deterministic helpers for geometry, algebra, and introductory physics.

Deterministic test fixtures

Generate reproducible image_distance and magnification for unit tests, property checks, and CI assertions.

What happens if object distance is zero?

The input is rejected with invalid_input. do = 0 is undefined for the thin-lens equation and for m = −di/do.

Read the full KIT documentation →