Calculate the length of one side of a right-angled triangle using the Pythagorean theorem (a² + b² = c²).
Enter values for any two sides. The calculator will determine the third. Leave the field for the side you want to calculate blank.
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 that has one angle equal to 90 degrees. The theorem states that the square of the length of the hypotenuse (the side opposite the right angle, and the longest side) is equal to the sum of the squares of the lengths of the other two sides (often called legs or cathetus).
Mathematically, if the lengths of the two legs of a right-angled triangle are denoted as a and b, and the length of the hypotenuse is denoted as c, the theorem is expressed as:
a² + b² = c²
This formula allows us to find the length of any side of a right-angled triangle if we know the lengths of the other two sides.
How the Calculator Works
This calculator uses the Pythagorean theorem to find an unknown side.
If you provide values for both side a and side b, it calculates the hypotenuse c using:
c = √(a² + b²)
If you provide values for the hypotenuse c and side a, it calculates side b using:
b = √(c² - a²)
If you provide values for the hypotenuse c and side b, it calculates side a using:
a = √(c² - b²)
The calculator handles edge cases by ensuring valid numerical inputs are provided and that the calculations are mathematically possible (e.g., it won't try to calculate the square root of a negative number if c² - a² or c² - b² is negative, which would indicate invalid triangle dimensions).
Use Cases
The Pythagorean theorem and its applications are incredibly versatile:
Construction and Architecture: Ensuring corners are perfectly square (90 degrees) by measuring diagonals.
Navigation: Calculating distances between points on a map or between celestial bodies.
Engineering: Designing structures, calculating forces, and ensuring stability.
Land Surveying: Determining property boundaries and distances.
Computer Graphics: Calculating distances between points in 2D or 3D space for rendering and animation.
Everyday Life: Figuring out if a large item will fit through a doorway or down a hallway.
Understanding and applying the Pythagorean theorem is a cornerstone of geometry and has practical applications across numerous fields.
function calculatePythagorean() {
var sideAInput = document.getElementById("sideA");
var sideBInput = document.getElementById("sideB");
var hypotenuseCInput = document.getElementById("hypotenuseC");
var resultDiv = document.getElementById("result");
var sideA = parseFloat(sideAInput.value);
var sideB = parseFloat(sideBInput.value);
var hypotenuseC = parseFloat(hypotenuseCInput.value);
var resultText = "";
if (!isNaN(sideA) && !isNaN(sideB) && sideA > 0 && sideB > 0) {
// Calculate hypotenuse c
var cSquared = (sideA * sideA) + (sideB * sideB);
var c = Math.sqrt(cSquared);
resultText = "If side a = " + sideA.toFixed(2) + " and side b = " + sideB.toFixed(2) + ", then hypotenuse c = " + c.toFixed(2) + "";
// Optionally update the input field for c
hypotenuseCInput.value = c.toFixed(2);
} else if (!isNaN(hypotenuseC) && !isNaN(sideA) && hypotenuseC > 0 && sideA > 0) {
// Calculate side b
if (hypotenuseC <= sideA) {
resultText = "Error: Hypotenuse (c) must be longer than side (a).";
} else {
var bSquared = (hypotenuseC * hypotenuseC) – (sideA * sideA);
var b = Math.sqrt(bSquared);
resultText = "If hypotenuse c = " + hypotenuseC.toFixed(2) + " and side a = " + sideA.toFixed(2) + ", then side b = " + b.toFixed(2) + "";
// Optionally update the input field for b
sideBInput.value = b.toFixed(2);
}
} else if (!isNaN(hypotenuseC) && !isNaN(sideB) && hypotenuseC > 0 && sideB > 0) {
// Calculate side a
if (hypotenuseC <= sideB) {
resultText = "Error: Hypotenuse (c) must be longer than side (b).";
} else {
var aSquared = (hypotenuseC * hypotenuseC) – (sideB * sideB);
var a = Math.sqrt(aSquared);
resultText = "If hypotenuse c = " + hypotenuseC.toFixed(2) + " and side b = " + sideB.toFixed(2) + ", then side a = " + a.toFixed(2) + "";
// Optionally update the input field for a
sideAInput.value = a.toFixed(2);
}
} else {
resultText = "Please enter valid numbers for any two sides to calculate the third.";
}
resultDiv.innerHTML = resultText;
}