Mirror equation calculator
Give the focal length and the object distance, and you get the image distance and magnification: an object at 30 in front of a mirror with focal length 10 forms its image at 15, inverted and half size. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Object distance (dₒ)
- 30
- Focal length
- 10
- Image distance
- 15
- Magnification
- -0.5
The mirror equation relates the focal length of a curved mirror to where an object sits and where its image forms, while lateral magnification tells you how large and whether the image is upright or inverted. Students checking homework ray diagrams, teachers building answer keys, optical technicians verifying simple spherical-mirror setups, and tutoring platforms that need structured numbers all run into the same pair of formulas: one over f equals one over do plus one over di, and m equals minus di over do.
What the mirror equation returns and which two inputs you need
For a single spherical or parabolic curved mirror treated in the thin-mirror paraxial approximation, the classical mirror equation states that the reciprocal of the focal length f equals the sum of the reciprocals of the object distance do and the image distance di. Rearranged, di equals f times do divided by do minus f. Lateral magnification is then m equals minus di over do: the sign shows inversion versus upright orientation, and the absolute value is the image height over object height for a small object on axis.
Search intent clusters around phrases such as mirror equation calculator, image distance from focal length, magnification of a curved mirror, concave mirror calculator, and convex mirror image distance. People want numeric di and m they can check against a worksheet or embed in a pipeline—not only a reminder that the formulas exist. Keep both inputs in the same length units—centimetres with centimetres, metres with metres—because the engine does not convert units.
How the image distance and size are found
Numeric strings that parse to finite numbers are accepted so forms and CSV-style pipelines can pass values without an extra cast. Zero object distance is always rejected per the product contract. After validation, di is computed as f times do over do minus f, and m as minus di over do.
Under the common school sign convention, positive f means a concave (converging) mirror and negative f a convex (diverging) mirror; positive di is a real image in front of the mirror and negative di a virtual image behind it. There is no multi-mirror train, no lens combination, and no aspheric ray trace; this is ideal paraxial single-mirror algebra from the two known distances.
What you can do with it
Homework and lab mirror drills
Students and graders confirm image distance and magnification for given do and f, with clear rejection when object distance is zero or the object sits at the focus.
Concave and convex design sanity checks
Quick structured numbers for whether an image is real or virtual and how large it is, without standing up a full optical design stack.
FAQ
What happens if object distance is zero?
Zero object distance is rejected by contract and those calls are not charged.
Is the mirror equation calculator free?
The browser tool runs free on your device.
What sign convention does this use for concave and convex mirrors?
Common school convention: positive focal length for concave (converging) mirrors, negative for convex (diverging). Positive image distance is real (in front); negative is virtual (behind).
How do I calculate image distance with the mirror equation?
Multiply the focal length by the object distance and divide by the object distance minus the focal length. With a focal length of 10 and the object at 30, the image forms at 15.
What does a magnification of -0.5 mean?
The minus sign means the image is upside down, and 0.5 means it is half the height of the object. Magnification is minus the image distance divided by the object distance, here 15 over 30.
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/mirror-equation \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"object_distance":30,"focal_length":10}'const res = await fetch("https://api.kit.forhosting.com/optics/mirror-equation", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"object_distance": 30,
"focal_length": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/optics/mirror-equation",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"object_distance": 30,
"focal_length": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/optics/mirror-equation", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"object_distance":30,"focal_length":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"object_distance":30,"focal_length":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/optics/mirror-equation", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"object_distance": 30,
"focal_length": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "optics.mirror_equation",
"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
This capacity accepts finite object distance and focal length, rejects zero object distance and object-at-focus degeneracies with a clear invalid_input error, and returns image distance, magnification, formula, and method as deterministic JSON.
What the mirror equation returns and which two inputs you need
Delivering object_distance, focal_length, image_distance, magnification, formula, and method as JSON makes the result easy to paste into notes, diff in automated tests, or reuse across languages without reimplementing the arithmetic.
How this calculator validates input and applies 1/f = 1/do + 1/di
Send a JSON body with required object_distance and focal_length. Aliases do, u, and object map to object distance; aliases f and focal map to focal length. Every provided field must be finite: missing fields, empty strings, non-numeric text, NaN, and Infinity all fail immediately with invalid_input before any result is returned, and failed validation is not charged. When object_distance equals focal_length the object sits at the focal plane, reflected rays are parallel, and di would be infinite—so that case is also rejected instead of returning Infinity. Results are rounded to a stable decimal precision so the same input always yields the same JSON across JavaScript engines.
Practical use, limits, pricing, and delivery channels
Use the browser tool when you want an immediate mirror-equation check while grading homework, verifying a lab spherical-mirror bench, sketching whether an image is real or virtual, or sanity-checking magnification for a concave shaving-mirror demo. Choose signs consistently with the school convention described above so inverted real images carry negative magnification as textbooks expect. There is no language model, no external optics service, and no randomness, so the capacity is safe to pin in continuous-integration checks and reproducible lesson materials. Each successful request is one billable item at $0.002; failed validation does not consume balance. Results are fully deterministic: the same two inputs always yield the same image_distance and magnification. Wire the endpoint into optics drills, contest answer checkers, ray-diagram worksheets, or preprocessing steps where you already prefer explicit domain errors—such as rejecting zero object distance—over opaque black-box widgets that cannot explain why a bad input was refused.
Integration use cases
Deterministic fixtures for optics tests
Pipelines that seed unit tests or interactive ray-diagram demos can call a pure mirror-equation oracle instead of reimplementing 1/f=1/do+1/di in every language.
Technical questions
How do I compute image distance and magnification with this API?
Send a JSON body with object_distance and focal_length to optics.mirror_equation. The response returns image_distance, magnification, formula, and method.
Which formulas does the mirror equation calculator use?
The curved-mirror equation 1/f = 1/do + 1/di, rearranged to di = (f·do)/(do−f), and lateral magnification m = −di/do.