Use this calculator to find the length of a side of a right-angled triangle using the Pythagorean theorem (a² + b² = c²).
Hypotenuse (c)
Side A (a)
Side B (b)
Result will appear here
Understanding the Pythagorean Theorem
The Pythagorean theorem is a fundamental principle in Euclidean geometry that describes the relationship between the three sides of a right-angled triangle. A right-angled triangle is a triangle in which one of the angles is a right angle (90 degrees).
The theorem states that the square of the length of the hypotenuse (the side opposite the right angle, usually denoted as 'c') is equal to the sum of the squares of the lengths of the other two sides (often called legs or cathetus, denoted as 'a' and 'b').
The Formula
Mathematically, the Pythagorean theorem is expressed as:
a² + b² = c²
How the Calculator Works
This calculator utilizes the Pythagorean theorem to find the length of any one side of a right-angled triangle, given the lengths of the other two sides.
If you provide the lengths of sides A and B and choose to calculate the Hypotenuse (c), it calculates c = √(a² + b²).
If you provide the lengths of the Hypotenuse (c) and side B and choose to calculate Side A (a), it calculates a = √(c² - b²).
If you provide the lengths of the Hypotenuse (c) and side A and choose to calculate Side B (b), it calculates b = √(c² - a²).
Use Cases
The Pythagorean theorem has numerous applications in:
Construction and Architecture: Ensuring corners are perfectly square, calculating diagonal braces, and determining roof pitches.
Navigation: Calculating distances between points on a map or in real-world scenarios.
Engineering: Designing structures, calculating forces, and determining lengths in mechanical systems.
Physics: Analyzing vectors, calculating displacement, and understanding wave phenomena.
Computer Graphics: Determining distances and collision detection in 2D and 3D environments.
Everyday Life: Figuring out if a large object will fit through a doorway diagonally, or calculating the shortest path across a rectangular field.
Example:
Consider a right-angled triangle where Side A is 3 units and Side B is 4 units. We want to find the Hypotenuse (c).
Using the formula: a² + b² = c²
3² + 4² = c²
9 + 16 = c²
25 = c²
c = √25
c = 5
Therefore, the hypotenuse is 5 units long.
function calculatePythagorean() {
var sideA = parseFloat(document.getElementById("sideA").value);
var sideB = parseFloat(document.getElementById("sideB").value);
var unknownSide = document.getElementById("unknownSide").value;
var resultDiv = document.getElementById("result");
var resultText = "";
if (isNaN(sideA) || isNaN(sideB)) {
resultDiv.innerHTML = "Please enter valid numbers for the known sides.";
resultDiv.style.backgroundColor = "#dc3545"; /* Red for error */
return;
}
if (unknownSide === "c") {
// Calculate hypotenuse c
var cSquared = (sideA * sideA) + (sideB * sideB);
var c = Math.sqrt(cSquared);
resultText = "Hypotenuse (c) = " + c.toFixed(4);
resultDiv.style.backgroundColor = "var(–success-green)"; /* Green for success */
} else if (unknownSide === "a") {
// Calculate side a
if (sideB >= sideA) { // Hypotenuse (c) must be greater than side B (a) if a is unknown
resultDiv.innerHTML = "For Side A to be the unknown, Side B must be less than the hypotenuse (which would be side A in this calculation). Re-evaluate which sides are known.";
resultDiv.style.backgroundColor = "#dc3545"; /* Red for error */
return;
}
var aSquared = (sideB * sideB) – (sideA * sideA); // Assuming sideA here is hypotenuse c
if (aSquared = sideB) { // Hypotenuse (c) must be greater than side A (b) if b is unknown
resultDiv.innerHTML = "For Side B to be the unknown, Side A must be less than the hypotenuse (which would be side B in this calculation). Re-evaluate which sides are known.";
resultDiv.style.backgroundColor = "#dc3545"; /* Red for error */
return;
}
var bSquared = (sideA * sideA) – (sideB * sideB); // Assuming sideB here is hypotenuse c
if (bSquared < 0) {
resultDiv.innerHTML = "Error: Hypotenuse must be longer than the known leg.";
resultDiv.style.backgroundColor = "#dc3545"; /* Red for error */
return;
}
var b = Math.sqrt(bSquared);
resultText = "Side B (b) = " + b.toFixed(4);
resultDiv.style.backgroundColor = "var(–success-green)"; /* Green for success */
}
resultDiv.innerHTML = resultText;
}