Enter any two sides of a right-angled triangle to find the third using the Pythagorean Theorem.
Result
How to Find the Missing Side of a Triangle
In geometry, finding the length of a missing side is most common in Right-Angled Triangles. This is made possible by the Pythagorean Theorem, a fundamental principle discovered by the Greek mathematician Pythagoras.
The Pythagorean Theorem Formula
The theorem states that in a right triangle, the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. The formula is expressed as:
a² + b² = c²
a and b are the legs of the triangle.
c is the hypotenuse (the longest side).
Common Calculation Scenarios
Depending on which side is missing, you will rearrange the formula:
Finding the Hypotenuse (c): If you know both legs, use c = √(a² + b²).
Finding a Leg (a or b): If you know the hypotenuse and one leg, use a = √(c² - b²) or b = √(c² - a²).
Example Calculation
Imagine you have a triangle where Side A is 6 units and Side B is 8 units. To find the hypotenuse (c):
When using this calculator, keep these geometric constraints in mind:
The hypotenuse (c) must always be the longest side.
If calculating a leg, the hypotenuse you enter must be larger than the known leg.
All side lengths must be positive numbers greater than zero.
function calculateTriangle() {
var a = document.getElementById("sideA").value;
var b = document.getElementById("sideB").value;
var c = document.getElementById("sideC").value;
var resBox = document.getElementById("resultDisplay");
var resText = document.getElementById("resultText");
var resTitle = document.getElementById("resultTitle");
var numA = parseFloat(a);
var numB = parseFloat(b);
var numC = parseFloat(c);
var count = 0;
if (!isNaN(numA) && numA > 0) count++;
if (!isNaN(numB) && numB > 0) count++;
if (!isNaN(numC) && numC > 0) count++;
resBox.style.display = "block";
resBox.style.borderLeftColor = "#3498db";
if (count < 2) {
resTitle.innerText = "Error";
resText.innerHTML = "Please enter at least two side lengths to calculate the third.";
resBox.style.borderLeftColor = "#e74c3c";
return;
}
if (count === 3) {
resTitle.innerText = "Verification";
var isRight = Math.abs((numA * numA + numB * numB) – (numC * numC)) < 0.01;
resText.innerHTML = isRight ? "This is a valid right-angled triangle." : "These sides do not form a perfect right-angled triangle (a² + b² ≠ c²).";
return;
}
var result = 0;
var label = "";
if (isNaN(numC)) {
// Calculate hypotenuse
result = Math.sqrt(Math.pow(numA, 2) + Math.pow(numB, 2));
label = "Hypotenuse (c)";
} else if (isNaN(numA)) {
// Calculate leg a
if (numC <= numB) {
resTitle.innerText = "Invalid Geometry";
resText.innerHTML = "The hypotenuse (c) must be longer than the leg (b).";
resBox.style.borderLeftColor = "#e74c3c";
return;
}
result = Math.sqrt(Math.pow(numC, 2) – Math.pow(numB, 2));
label = "Side (a)";
} else if (isNaN(numB)) {
// Calculate leg b
if (numC <= numA) {
resTitle.innerText = "Invalid Geometry";
resText.innerHTML = "The hypotenuse (c) must be longer than the leg (a).";
resBox.style.borderLeftColor = "#e74c3c";
return;
}
result = Math.sqrt(Math.pow(numC, 2) – Math.pow(numA, 2));
label = "Side (b)";
}
resTitle.innerText = "Calculation Successful";
resText.innerHTML = "The missing " + label + " is: " + result.toFixed(4).replace(/\.?0+$/, "") + "";
}
function resetCalculator() {
document.getElementById("sideA").value = "";
document.getElementById("sideB").value = "";
document.getElementById("sideC").value = "";
document.getElementById("resultDisplay").style.display = "none";
}