Stewart's theorem calculator
Find the length of the segment from a triangle's vertex to any point on the opposite side, from the three sides and the two pieces of the base: sides 7, 5 and 6 with the base split into 3 and 4 give 4.391550328268. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- A
- 7
- B
- 5
- C
- 6
- M
- 3
- N
- 4
- Cevian
- 4.3915503283
- Cevian squared
- 19.2857142857
Stewart's theorem is the classical identity that relates the three side lengths of a triangle to the length of a cevian and the two segments that cevian creates on the opposite side. A student given sides seven, five, and six with the base split into three and four needs the internal segment from the opposite vertex; a surveyor who has taped the outer edges and marked a division point needs the same length without building a scale drawing; a game or CAD pipeline that stores triangle meshes and foot-of-segment data needs a deterministic number for collision or UV layout. This capability accepts the standard labeling—side a is the divided base, b and c are the other two sides, m and n are the base segments with m plus n equal to a—checks the triangle inequality and the division consistency, and returns the positive cevian length from the closed-form radical.
What Stewart's theorem says and how the cevian is labeled
Stewart's theorem applies to any triangle with a cevian from one vertex to a point on the opposite side. Label the triangle ABC so that side a equals BC, side b equals AC, and side c equals AB. Draw the cevian from A to a point D on BC, and write BD equals m, DC equals n, and the cevian AD equals d.
The side being divided must satisfy a equals m plus n; that is not optional arithmetic sugar but part of the geometric contract, because m and n are literally the pieces of a. With that labeling, Stewart's relation states that b squared times m plus c squared times n equals a times the quantity d squared plus m times n.
Solving for the unknown cevian length gives d squared equal to m times b squared plus n times c squared, all divided by a, minus the product m n, and d is the non-negative square root of that expression.
Special cases recover familiar results: when m equals n equals a over two, the cevian is a median and the formula collapses to the median length formula; when the cevian is an altitude to a right angle you can cross-check against half base times height or Pythagoras in the two right triangles; when D is a vertex the setup degenerates and is rejected.
Every step is elementary arithmetic and one square root on five positive scalars, so there is no iteration, no sampling, no dependence on wall-clock time, and no need for angles in the input contract.
Practical tips, limits, worked checks, and related searches
When teaching, prefer a classic integer split such as a equals seven, b equals five, c equals six, m equals three, n equals four, which satisfies m plus n equals a and yields a clean positive cevian you can recompute by hand from the Stewart radical. Pair that with a median check on a three-four-five right triangle: a equals five, b equals four, c equals three, m equals n equals two point five, and the formula reduces to the known median length to the hypotenuse.
Force the error path deliberately by sending m plus n not equal to a—for example m equals two, n equals two, a equals seven—to show students that an inconsistent division is rejected before any square root is taken. Prefer Stewart when you measured or were given the three outer sides and the two base pieces and need the internal cevian without constructing altitudes.
Round-trip checks are easy: after solving, confirm that m plus n equals a, recompute d squared from the closed form, and verify that b squared m plus c squared n equals a times d squared plus m n within floating tolerance.
What you can do with it
Surveying and layout from outer edges plus a marked foot
Turn taped triangle edges and a division mark on one side into the internal distance to the opposite vertex without a full scale drawing.
Game, CAD, and mesh tooling for internal segment lengths
Compute a cevian or median length when a triangle face stores three edge lengths and a parameterised foot on one edge.
FAQ
What is Stewart's theorem?
Stewart's theorem relates triangle sides a, b, c to a cevian of length d that splits side a into segments m and n: b²m + c²n = a(d² + mn). Solving yields d = sqrt((m b² + n c²)/a − mn).
What does inconsistent division mean?
The base segments must satisfy m + n = a, because m and n are the two pieces of side a.
How are m and n labeled relative to b and c?
With side a = BC, b = AC, c = AB, and foot D on BC: m = BD (next to side c) and n = DC (next to side b). Swapping m and n without swapping b and c will give the wrong length.
Does this compute medians or altitudes specially?
A median is the special case m = n = a/2; enter those segments and you get the median length from the same formula. An altitude works only when the foot is the true perpendicular foot—you must supply the correct m and n for that foot.
Is the Stewart's theorem calculator free?
The browser tool is free and runs locally.
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/geom/stewart-theorem \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"a":7,"b":5,"c":6,"m":3,"n":4}'const res = await fetch("https://api.kit.forhosting.com/geom/stewart-theorem", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"a": 7,
"b": 5,
"c": 6,
"m": 3,
"n": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/stewart-theorem",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"a": 7,
"b": 5,
"c": 6,
"m": 3,
"n": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/stewart-theorem", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"a":7,"b":5,"c":6,"m":3,"n":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"a":7,"b":5,"c":6,"m":3,"n":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/stewart-theorem", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"a": 7,
"b": 5,
"c": 6,
"m": 3,
"n": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.stewart_theorem",
"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
What Stewart's theorem says and how the cevian is labeled
If the radicand would be clearly negative, the inputs do not form a consistent figure and the tool returns invalid_input rather than an imaginary length.
Input contract, response shape, and when division is inconsistent
The three sides must also satisfy the strict triangle inequality: a plus b greater than c, a plus c greater than b, and b plus c greater than a. Send a JSON body with five required positive finite numbers. Field a is the length of the divided base BC; aliases side_a and base are accepted. Field b is side AC; alias side_b maps to the same meaning. Field c is side AB; alias side_c is accepted. Field m is the base segment BD; aliases segment_m and bd are accepted. Field n is the base segment DC; aliases segment_n and dc are accepted. On success the response echoes a, b, c, m, and n, adds cevian (the length d), cevian_squared (the radicand before the square root), method set to stewart, and a short formula block documenting the Stewart relation, the closed form for d, and the division identity a equals m plus n. Failed validation—missing a required field, a non-finite or non-positive length, a length outside published limits, a broken triangle inequality, an inconsistent m plus n versus a, or a negative radicand—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item.
Practical tips, limits, worked checks, and related searches
Keep all lengths inside the published positive range up to one trillion so intermediate products of squares stay finite in IEEE double precision on the Worker and in the browser. Units are whatever you pass—metres, feet, or game units—as long as a, b, c, m, and n share the same unit; the API does not convert units for you. Because the formula only needs sides and segments, learners can expand b squared m plus c squared n by hand for small integers and match the API line by line. This landing targets people searching for a Stewart theorem calculator or a cevian length from sides tool; it is not an angle-chasing SAS solver and not Heron's area formula alone—use dedicated triangle area or SAS capabilities when those are the true intent. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when users type mismatched splits while learning the contract.
Integration use cases
Homework and exam checks for Stewart and cevian problems
Give students sides a, b, c and base segments m, n; compare their hand-computed cevian length against a deterministic API or free browser result.