ForHosting KIT · Math

Hypotenuse calculator

Legs of 3 and 4 give a hypotenuse of 5 and an area of 6, straight from the Pythagorean theorem. Give the hypotenuse and one leg instead and the missing leg comes back; impossible triangles are refused with a clear reason. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
A
3
B
4
You get
Calculation mode
from_legs
C
5
Legs
3, 4
Hypotenuse
5

The hypotenuse calculator applies the Pythagorean theorem to a right triangle with a clear, deterministic contract. Supply both positive legs to obtain the hypotenuse as the square root of the sum of their squares, or supply the hypotenuse with exactly one leg to recover the missing leg as the square root of the difference of squares.

What the hypotenuse is and what you get

In a right triangle the hypotenuse is the unique longest side: it sits opposite the right angle and is strictly longer than either leg that forms that angle. The Pythagorean theorem states that the square of the hypotenuse equals the sum of the squares of the two legs, written c squared equals a squared plus b squared. Solving for the unknown rearranges into two everyday operations.

Given legs a and b, the hypotenuse is the square root of a squared plus b squared. Given the hypotenuse c and one known leg, the other leg is the square root of c squared minus the known leg squared. Those identities are the entire engine of this calculator.

The response always echoes both legs and the hypotenuse as a, b, and c, repeats them as legs and hypotenuse for callers that prefer descriptive keys, and adds the area as one half times a times b because the legs are perpendicular base and height. A mode field records whether the result came from two legs, from the hypotenuse with leg a, from the hypotenuse with leg b, or from a full three-side verification.

A formula string restates the relation used so students and reviewers can match textbook steps without reverse-engineering floating-point output. If you need the fixed ratios of a 45-45-90 or 30-60-90 special right triangle, use those dedicated tools; the search intent here is the general right-triangle hypotenuse and missing-leg problem with an honest error when geometry is violated.

Where hypotenuse solving fits in study, design, and automation

Students meet this problem the moment they learn right triangles: a worksheet gives two legs and asks for the diagonal, or gives the diagonal and one leg and asks for the other side of a rectangular room, a ramp, or a ladder leaning against a wall. Teachers can pre-generate answer keys that list a, b, c, and area, and refuse impossible inputs instead of printing a blank or a complex number.

Carpenters, fabricators, surveyors, and game-level designers often need the diagonal of a rectangle, the length of a brace, or the third side of a right corner when only two measures are known; converting with a shared contract avoids misremembered formulas and silent unit mistakes. Pair it with unit converters when sides arrive in mixed units, with special-triangle calculators when the angles are constrained, and with diagramming notes that keep the right-angle mark next to the numbers so the figure and the formula stay aligned for learners and reviewers alike.

Homework and exam preparation

Complete textbook right-triangle problems from two legs or from the hypotenuse plus one leg, and check the third side and area against answer keys.

Diagonals, braces, and layout

Convert between rectangle sides and diagonals, or recover a missing brace length on a right corner, without hand-rolled square-root arithmetic.

What does the hypotenuse calculator cost?

It is free in your browser on this page.

Which sides do I need to provide?

Provide both legs a and b to compute the hypotenuse, or the hypotenuse c with exactly one leg to recover the other leg. All three may be sent to verify consistency.

What happens if a leg is longer than the hypotenuse?

A leg must be strictly shorter than the hypotenuse; equal or greater values cannot form a real right triangle.

How is the area computed?

Area equals one half times leg a times leg b (½·a·b), because the legs are perpendicular and act as base and height of the right triangle.

Is the algorithm randomized?

No. It uses deterministic squares, sums or differences, and a square root. The same sides and precision always yield the same result.

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.

POSThttps://api.kit.forhosting.com/trig/hypotenuse

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.

curl -X POST https://api.kit.forhosting.com/trig/hypotenuse \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":3,"leg_a":1}'
{
  "a": 3,
  "leg_a": 1
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "trig.hypotenuse",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Every length must be a strictly positive finite number, and a leg that equals or exceeds the hypotenuse is rejected with invalid_input instead of producing a zero or imaginary result. The response returns both legs, the hypotenuse, the triangular area as half the product of the legs, a mode label describing which path was used, and a short formula string for teaching and audit trails. Arithmetic is pure floating-point with no random sampling, no clock reads, and no network calls, so the same inputs always yield the same payload.

What the hypotenuse is and what the response contains

The contract is intentionally strict: missing pairs, zero, negative values, Infinity, NaN, a leg that equals or exceeds the hypotenuse, and inconsistent triples all raise invalid_input with a message that names the failing condition.

How inputs are read and how the sides are computed

You must provide at least two of the three sides. When both legs are present, the engine computes c as the square root of a squared plus b squared. When the check passes, the missing leg is the square root of c squared minus the known leg squared. When all three sides are supplied, the tool verifies that each leg is shorter than c and that c matches the Pythagorean value of a and b within a tight relative tolerance; otherwise it rejects the triple as inconsistent. The preferred fields are a and b for the legs and c for the hypotenuse, accepted as JSON numbers or plain decimal strings after trim so forms, query strings, and spreadsheet cells can share one contract. Aliases leg_a, leg1, and side_a map to a; leg_b, leg2, and side_b map to b; hypotenuse, hyp, and long_side map to c. When the hypotenuse and exactly one leg are present, it first checks that the leg is strictly shorter than the hypotenuse; if the leg equals or exceeds c, the request fails with invalid_input naming that inequality, because a real right triangle cannot have a leg as long as or longer than the hypotenuse. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing square roots and inequality guards yourself.

Where hypotenuse solving fits in study, design, and automation

Developers call the same endpoint from scripts to seed deterministic test vectors for geometry libraries, to illustrate Pythagoras in teaching tools, or to satisfy programming-challenge statements that demand exact right-triangle completions with clear rejection of degenerate cases. On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split—free interactive exploration and a priced, identical API—matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.

Deterministic geometry fixtures

Generate reproducible 3-4-5 and 5-12-13 triples for unit tests, contest validators, and CI assertions, including honest invalid_input on impossible legs.

Read the full KIT documentation →