Barn-pole paradox calculator
The barn-pole paradox is the classic thought experiment of special relativity: a pole longer than a barn is driven through it at near light speed, and in the barn's frame the pole is Lorentz-contracted enough to fit inside — while in the pole's frame it is the barn that shrinks.
Run — free
This calculator takes the proper lengths of the pole and the barn plus their relative speed as a fraction of light speed, and returns the Lorentz factor, the contracted length of the pole in the barn frame, and a clear verdict on whether it fits. It runs the same deterministic arithmetic in your browser for free and through the API for $0.002 per call.
What the barn-pole paradox actually asks
A farmer has a barn ten meters long and a pole twenty meters long. At everyday speeds the pole can never fit inside the barn. But special relativity says that objects moving relative to an observer are shortened along their direction of motion by the Lorentz factor gamma. If the pole moves fast enough relative to the barn, then in the barn's rest frame the moving pole becomes shorter than the barn, and for an instant both doors can be shut with the pole entirely inside. The apparent paradox appears when you switch to the pole's rest frame: there the pole keeps its full twenty meters and it is the barn that contracts, so the pole should fit even less. The resolution is the relativity of simultaneity — the two doors do not close at the same time in the pole's frame. This calculator quantifies the barn-frame side of the story: given the two proper lengths and the relative speed, it tells you exactly how long the pole appears in the barn frame and whether that contracted length is small enough to fit.
How the contracted length is computed
The input is three numbers: the proper length of the pole in meters, the proper length of the barn in meters, and the relative speed expressed as a fraction of the speed of light, written here as speed_c. Proper length means the length measured in the object's own rest frame, which is the longest length the object ever has. The calculator first forms the Lorentz factor, gamma equals one divided by the square root of one minus speed_c squared. The contracted length of the pole in the barn frame is then the proper pole length divided by gamma. Because gamma grows without bound as speed_c approaches one, any pole can in principle be contracted below any barn length if it moves fast enough — though the required speeds are extravagantly close to light speed for macroscopic objects. The fit verdict compares the contracted length with the barn's proper length: if the contracted pole is shorter than or exactly as long as the barn, the verdict is that it fits. All arithmetic is plain double-precision floating point, deterministic, with results rounded to six decimals so the same input always produces byte-identical output.
Reading the verdict and its limits
The verdict answers one precise question: in the rest frame of the barn, is the moving pole momentarily shorter than the barn? It says nothing about what an observer riding the pole would report, because that is the frame-dependent half of the paradox that numbers alone cannot settle — simultaneity differs between frames, and the door-closing events that are simultaneous in the barn frame are not simultaneous in the pole frame. The speed input must be strictly greater than zero and strictly less than one: at zero there is no contraction to compute, and at exactly light speed the Lorentz factor diverges, so the calculator rejects both with a clear invalid-input error rather than returning a misleading number. Typical use is educational: students checking homework on length contraction, teachers building examples, and authors of science outreach who want an exact figure for a given scenario. It costs $0.002 per call through the API, and the identical calculation runs free in the browser on this page, so you can explore parameter ranges interactively before automating anything.
What you can do with it
Check a relativity homework problem
Verify the contracted length and fit verdict for the exact numbers in a textbook exercise on length contraction.
Build a teaching example
Find the speed at which a given pole just fits a given barn, by sweeping speed_c and watching the verdict flip.
Fact-check a science article
Confirm that a claimed scenario — a ladder through a garage at 0.8c — really produces the contraction the author describes.
FAQ
What does it cost?
$0.002 per request through the API. The same calculation also runs free in your browser on this page.
Why must the speed be less than 1?
The speed is given as a fraction of light speed. At exactly 1 the Lorentz factor is infinite, and no massive pole can reach light speed, so the input is rejected.
What length units does it use?
Meters for both the pole and the barn. The contracted length is returned in meters too. Convert your values first if they are in other units.
In which frame does the pole fit?
The verdict is computed in the barn's rest frame, where the moving pole is contracted. In the pole's frame the barn contracts instead, and simultaneity resolves the apparent contradiction.
What happens at speed zero?
A speed of exactly zero is rejected: with no relative motion there is no contraction to compute. Any positive speed below light speed works.
Is the result exact?
The arithmetic is standard double-precision floating point, rounded to six decimals, and fully deterministic: the same input always yields the same output.
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/phys/barn-pole-paradox \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"pole_length":20,"barn_length":10,"speed_c":0.8}'const res = await fetch("https://api.kit.forhosting.com/phys/barn-pole-paradox", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"pole_length": 20,
"barn_length": 10,
"speed_c": 0.8
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/phys/barn-pole-paradox",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"pole_length": 20,
"barn_length": 10,
"speed_c": 0.8
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/phys/barn-pole-paradox", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"pole_length":20,"barn_length":10,"speed_c":0.8}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"pole_length":20,"barn_length":10,"speed_c":0.8}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/phys/barn-pole-paradox", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"pole_length": 20,
"barn_length": 10,
"speed_c": 0.8
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "phys.barn_pole_paradox",
"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. |