Ellipse perimeter
Semi-axes of 5 and 3 give an ellipse perimeter of 25.526986, found with Ramanujan's formula because no exact elementary formula exists. Enter the two semi-axes in either order and get the edge length to six decimals. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Semi major
- 5
- Semi minor
- 3
- Perimeter
- 25.526986
Unlike the area, which has a clean closed form, the perimeter of an ellipse has no elementary exact formula — it involves a complete elliptic integral of the second kind. In practice nobody evaluates that integral by hand, because Ramanujan's approximation gets the answer right to a tiny fraction of a percent. You send the semi-major and semi-minor axes, and you get back the perimeter, computed deterministically, in one request. The same code runs free in your browser on this page.
Why the ellipse perimeter has no simple formula
Everyone learns that a circle of radius r has perimeter 2·pi·r, and it is natural to expect something equally tidy for an ellipse. There is not one. The exact perimeter is 4·a·E(e), where E is the complete elliptic integral of the second kind and e is the eccentricity — a function that cannot be written with elementary arithmetic, roots and pi alone.
For two centuries mathematicians published approximations, and the one that stuck is Ramanujan's second formula: pi times the quantity three times the sum of the axes minus the square root of (3a+b)(a+3b). Its worst-case relative error is on the order of a few hundred-thousandths of a percent, even for extremely flattened ellipses where most simpler formulas fall apart badly.
That makes it the standard choice in engineering software, CAD kernels and surveying tools: cheap to compute, accurate far beyond any measurement you could make of the physical object, and free of iterative numerical methods.
Inputs, validation and the number you get back
The two axes do not need to be sorted: the formula is symmetric in a and b, so passing them swapped yields the same perimeter. If the axes are equal the ellipse is a circle and the result is the exact circumference, which the response notes explicitly. The perimeter itself is rounded to six decimal places so that the output is byte-stable across machines and runs — the same request always returns the same bytes, which matters when you cache results or compare outputs in a test suite.
The response also echoes the axes and names the formula used, so a stored result remains self-explanatory months later.
What you can do with it
Material length for an elliptical rim
Compute how much trim, gasket or cable is needed to go around an elliptical part from its two axis measurements.
Sanity-check a CAD or survey figure
Verify the perimeter reported by design software with an independent, documented formula before ordering material.
FAQ
What does it cost?
The same computation is free in your browser on this page.
How accurate is Ramanujan's formula?
Its worst-case relative error is a few hundred-thousandths of a percent, even for very flat ellipses. For equal axes it is exact.
Do I need to pass the larger axis first?
No. The formula is symmetric in the two axes, so swapping them gives the same perimeter.
Is the exact perimeter computable?
Only through a complete elliptic integral of the second kind, which has no elementary closed form. The approximation returned here is the industry-standard practical answer.
Is anything stored?
No. The input is processed and discarded; only the result is returned.
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/math/ellipse-perimeter \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"semi_major":5,"semi_minor":3}'const res = await fetch("https://api.kit.forhosting.com/math/ellipse-perimeter", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"semi_major": 5,
"semi_minor": 3
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/ellipse-perimeter",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"semi_major": 5,
"semi_minor": 3
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/ellipse-perimeter", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"semi_major":5,"semi_minor":3}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"semi_major":5,"semi_minor":3}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/ellipse-perimeter", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"semi_major": 5,
"semi_minor": 3
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.ellipse_perimeter",
"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 ellipse perimeter API answers one of the oldest awkward questions in geometry: how long is the edge of an ellipse?
Why the ellipse perimeter has no simple formula
This endpoint implements exactly that formula, with input validation and stable rounding, so the number you see here is the number your automated calls will see.
Inputs, validation and the number you get back
The ellipse perimeter calculator takes two fields: semi_major and semi_minor, conventionally called a and b, the distances from the center to the edge along the longest and shortest axes. Both must be finite numbers, and neither may be negative — a negative axis is a geometric impossibility, so the request is rejected with a clear invalid_input error that names the offending field instead of silently producing a wrong result.
Where it is used and what it costs
Elliptical perimeters turn up wherever circles get stretched: the length of material needed to edge an elliptical table or mirror, the cable around an elliptical duct, the seam of an oval tank, the track of a planetary orbit estimated from its axes, the rim of a stadium running track. Pay when you automate — batch jobs over catalogs of parts, validation inside a design pipeline, or a mobile app that needs the answer offline of a textbook — and prototype for free until then. Doing this by hand means looking up the formula, keeping the parenthesization right and hoping the eccentricity of your shape does not push a cruder approximation out of tolerance; doing it here is one POST. The call runs on our global edge, keeps nothing, and contains no randomness or clock dependence, so it is safe to memoize.
Integration use cases
Batch processing in a pipeline
Loop over a catalog of elliptical dimensions and attach a perimeter to each record at $0.002 per call.
Technical questions
What happens with a negative axis?
The request is rejected with an invalid_input error naming the field. Negative axes have no geometric meaning.