ABC triangle solver
The ABC triangle solver takes any combination of sides a, b, c and interior angles A, B, C that determines a triangle and returns the sides and angles you did not provide.
Run — free
It applies the law of cosines and the law of sines in the right order for each case — three sides, two sides with the included angle, two angles with any side, or two sides with a non-included angle — and it refuses inputs that describe no triangle, several triangles, or values that contradict each other. Angles are given and returned in degrees; every result is rounded to a stable ten decimal places so the same input always produces the same output.
One endpoint for every solvable combination
Textbook trigonometry splits triangle solving into five separate recipes — SSS, SAS, ASA, AAS and the awkward SSA case — and each one has its own formula sheet. This triangle solver folds all five into a single request: you send whichever fields you happen to know among side_a, side_b, side_c, angle_a, angle_b and angle_c, and the solver works out which recipe applies. Three known sides trigger the law of cosines; two sides with the angle between them use the cosine rule once and the sine rule after; any side paired with two angles is a straight law-of-sines problem. You never have to name the case yourself, and the response always carries a <em>method</em> field that records which path was taken, which is useful when you log or cache results. Because the interface is uniform, the same client code solves a roof pitch, a land survey and a homework exercise without branching on the combination.
Consistency is checked, not assumed
Real measurements disagree. If you send more than the three values a triangle strictly needs — say all three sides plus an angle you measured in the field — the solver does not silently ignore the surplus. It first solves the triangle from a determining subset and then verifies every remaining value against that solution within a tight tolerance. A value that contradicts the rest produces an explicit error naming the field, instead of a plausible-looking triangle that quietly satisfies only part of your input. The same discipline catches the classic failure modes before any arithmetic happens: three angles that do not sum to 180 degrees, three sides that violate the triangle inequality, an SSA pair whose side opposite the known angle is too short to reach, and the ambiguous SSA case where two genuinely different triangles fit the data. In that last situation the solver says so and asks for one more measurement rather than picking a winner you did not choose.
How to integrate it
Send a JSON object with the known fields as numbers — numeric strings are accepted too — and read back the completed triangle: all three sides, all three angles in degrees, the angle unit and the method used. Missing pieces are filled in; pieces you supplied are echoed back so the response is a complete, self-contained record of the triangle. Everything is computed deterministically with double-precision math and rounded to ten decimal places, which makes the output safe to compare byte for byte in tests and caches. The capability runs on our global edge with nothing persisted, and exactly the same module runs free in your browser on this page, so you can prototype a calculation by hand and only pay $0.002 per request when you automate it. There is no per-unit surcharge: one request in, one solved triangle out, $0.002.
What you can do with it
Check a field survey
Send the measured sides and angles together; any value that contradicts the rest is flagged instead of averaged away.
Dimension a roof or a brace
Two sides and the included angle give the third side and the remaining angles for a cut list in one call.
Grade geometry exercises
Compare a student's completed triangle against the solver's stable, rounded output for SSS, SAS, ASA and AAS problems.
FAQ
What does it cost?
$0.002 per request. It is also free to run in your browser on this page.
Which combinations of values can I send?
Any that determine a triangle: three sides, two sides with the included angle, two angles with any one side, or two sides with a non-included angle. You may send extra values too; they are checked for consistency.
What happens with the ambiguous SSA case?
When two different triangles fit two sides and a non-included angle, the request is rejected with an error asking for one more side or angle, rather than guessing.
Are angles in degrees or radians?
Degrees, both in and out. Interior angles must be positive and less than 180.
Why did I get an 'inconsistent input' error?
Because one of the values you sent contradicts the triangle defined by the others beyond a small tolerance — for example an angle that does not match three measured sides. Re-check that measurement.
Can I solve a triangle from three angles alone?
No. Angles fix the shape but not the size, so at least one side is required; the solver returns an error explaining this.
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/abc-triangle \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"side_a":3,"side_b":4}'const res = await fetch("https://api.kit.forhosting.com/math/abc-triangle", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"side_a": 3,
"side_b": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/abc-triangle",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"side_a": 3,
"side_b": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/abc-triangle", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"side_a":3,"side_b":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"side_a":3,"side_b":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/abc-triangle", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"side_a": 3,
"side_b": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.abc_triangle",
"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. |