Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Pythagorean Theorem Calculator (Hypotenuse and Legs of a Right Triangle)

Of the three sides a, b and c of a right triangle (c is the hypotenuse), enter only the two you know. The Pythagorean theorem gives the missing side, and the two acute angles, the area, the perimeter and the altitude to the hypotenuse are shown too.

Enter only two sides (leave the missing one blank). Lengths must be numbers greater than 0 (decimals are OK), all in the same unit (for example, all in inches).
Result and figure
Enter the two side lengths you know in the fields on the left and press "Calculate". The result will appear here.

What you can do on this page

  • Enter any two of the three sides of a right triangle, and the Pythagorean theorem \(a^2 + b^2 = c^2\) gives you the third side on the spot
  • Questions like "I only know it is 3 ft one way and 4 ft the other. How long is the diagonal?" are answered in one step
  • Along with the missing side, it also finds the two acute angles, the area, the perimeter and the altitude to the hypotenuse, with the steps shown
  • A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
This works only for right triangles (triangles with one angle of exactly 90°). The hypotenuse c is the longest side, opposite the right angle. It cannot be used for the sides of a triangle without a right angle.

What is this calculation used for?

Estimating how high a ladder reaches (DIY and construction)

If you lean a 16-foot ladder against a wall with its feet 4 feet from the wall, it reaches \(\sqrt{16^2 - 4^2} = \sqrt{240} \approx 15.49\) feet up the wall (about 15.5 ft).
A ladder is set with its feet away from the wall so it does not tip over (a common safety rule is 1 foot out for every 4 feet of height), so it never reaches as high as its full length. Estimating the reach this way before the job is a basic habit in construction and electrical work.

Squaring a corner with 3-4-5 (carpentry and foundations)

Measure 3 feet along one side and 4 feet along the other. If the distance between those two marks is exactly 5 feet, the corner is square (since \(3^2 + 4^2 = 5^2\), the converse of the Pythagorean theorem says it is a right angle). For bigger layouts, carpenters use 6-8-10 or 9-12-15.
This "3-4-5 method" has been used for thousands of years, from rope stretchers in ancient Egypt to today's foundation and deck layouts. It is the most practical everyday use of the Pythagorean theorem.

Straight-line distance on a map (and in programming)

A place 3 miles east and 4 miles north of you is \(\sqrt{3^2 + 4^2} = 5\) miles away in a straight line.
Finding the distance between two points from the east-west difference and the north-south difference (the distance formula) is the Pythagorean theorem itself. It runs inside almost every program that works with locations, such as GPS navigation, map apps and video games.

Finding the sloped length of stairs and ramps (design and remodeling)

A staircase that runs 12 feet horizontally and rises 9 feet has a sloped length of \(\sqrt{12^2 + 9^2} = \sqrt{225} = 15\) feet.
The length of any sloped part, such as a stair handrail or a ramp board, comes from the horizontal and vertical dimensions on the plan with the Pythagorean theorem. You can use it directly to estimate materials before going to the store.

Formulas and figures

The Pythagorean theorem (how the three sides are related)
Figure
Standard notation (the usual math form)
\(a^2\) \(+\) \(b^2\) \(=\) \(c^2\)
In words (symbols replaced with words)
① \(a^2\): leg \(a\) squared \(+\) ② \(b^2\): leg \(b\) squared \(=\) ③ \(c^2\): hypotenuse \(c\) squared
The formula in words
① Add \(a^2\): leg \(a\) squared
② and \(b^2\): leg \(b\) squared
③ and the sum is exactly equal to \(c^2\): hypotenuse \(c\) squared
Quick example
Checking it with a right triangle whose sides are 3, 4 and 5
leg a squared (3² = 9) \(+\) leg b squared (4² = 16) \(=\) hypotenuse c squared (5² = 25)
\(3^2 + 4^2 = 9 + 16 = 25 = 5^2\)
Key idea
The hypotenuse \(c\) is the side opposite the right angle and the longest side of a right triangle. This relationship holds only for right triangles. It also works the other way: any triangle whose three sides fit this equation is always a right triangle (the converse of the Pythagorean theorem). This is what builders use to check that a corner is square.
Formula for the hypotenuse \(c\)
Figure
Standard notation (the usual math form)
\(c\) \(=\) \(\sqrt{a^2 + b^2}\)
In words (symbols replaced with words)
② \(c\): hypotenuse \(=\) ① square root of the sum of squares \(a^2 + b^2\)
The formula in words
① Find the square root of the sum of squares \(a^2 + b^2\) (square each leg, add them, then take the square root)
② and you get the \(c\): hypotenuse
Quick example
When the two legs are 3 and 4, the hypotenuse is
\(c\): hypotenuse \(=\) square root of the sum of squares (3² + 4² = 25)
\(c = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5\)
Key idea
This is \(a^2 + b^2 = c^2\) solved for \(c\). A common mistake is to write \(\sqrt{a^2} + \sqrt{b^2}\) (which is just \(a + b\)). First do all of the addition inside the square root, then take the square root only once at the end. The correct answer is \(\sqrt{9 + 16} = 5\), not \(\sqrt{9} + \sqrt{16} = 7\).
Formula for a missing leg
Figure
Standard notation (the usual math form)
\(b\) \(=\) \(\sqrt{c^2 - a^2}\)
In words (symbols replaced with words)
② \(b\): missing leg \(=\) ① square root of the difference of squares \(c^2 - a^2\)
The formula in words
① Find the square root of the difference of squares \(c^2 - a^2\) (subtract the square of the known leg from the square of the hypotenuse, then take the square root)
② and you get the \(b\): missing leg
Quick example
When the hypotenuse is 13 and one leg is 5, the other leg is
\(b\): missing leg \(=\) square root of the difference of squares (13² − 5² = 144)
\(b = \sqrt{13^2 - 5^2} = \sqrt{169 - 25} = \sqrt{144} = 12\)
Key idea
Watch the order of the subtraction. Always subtract the square of the known leg from the square of the hypotenuse, the longest side. To find leg \(a\) instead, use the same form: \(a = \sqrt{c^2 - b^2}\). If the subtraction gives 0 or less, the side you called the hypotenuse is not the hypotenuse (the hypotenuse is always longer than either leg).
Altitude to the hypotenuse
Figure
Standard notation (the usual math form)
\(h\) \(=\) \(a\) \(\times\) \(b\) \(\div\) \(c\)
In words (symbols replaced with words)
④ \(h\): altitude to the hypotenuse \(=\) ① \(a\): leg \(\times\) ② \(b\): leg \(\div\) ③ \(c\): hypotenuse
The formula in words
① Multiply \(a\): leg
② by \(b\): leg
③ divide by the \(c\): hypotenuse
④ and you get the \(h\): altitude to the hypotenuse
Quick example
In a right triangle with sides 3, 4 and 5, the height measured from the hypotenuse (the side of length 5) as the base is
altitude \(h\) \(=\) leg a (3) \(\times\) leg b (4) \(\div\) hypotenuse c (5)
\(h = 3 \times 4 \div 5 = 12 \div 5 = 2.4\)
Key idea
This formula comes from writing the area in two ways. Using the two legs, the area of a right triangle is \(a \times b \div 2\). Using the hypotenuse as the base, it is \(c \times h \div 2\). The area is the same, so \(a \times b = c \times h\). Solve this for \(h\) and you get \(h = a \times b \div c\).
The Pythagorean theorem says that the sum of the squares of the two legs equals the square of the hypotenuse, and it holds only for right triangles. If you know two sides, you find the third in two steps - square and add (for the hypotenuse) or square and subtract (for a leg), then take the square root.

Symbols and terms

Symbols

\(a\), \(b\) a, b The lengths of the two legs, the sides that form the right angle. It does not matter which one you call a; the result is the same.
\(c\) c The length of the hypotenuse, the longest side of a right triangle, opposite the right angle.
\(a^2\) a squared A number multiplied by itself (\(a^2 = a \times a\)). The small raised 2 is an exponent that says "use it as a factor twice". (Example - \(3^2 = 3 \times 3 = 9\))
\(\sqrt{\phantom{x}}\) square root (radical sign) The symbol for a square root. \(\sqrt{25}\) is the positive number that gives 25 when squared, which is 5. It can also be a number that never ends as a decimal, like \(\sqrt{2}\) (about 1.414).
\(\alpha\), \(\beta\) alpha, beta Greek letters often used to name angles. On this page, \(\alpha\) is the angle opposite leg a and \(\beta\) is the angle opposite leg b, and \(\alpha + \beta = 90°\).
\(\arcsin\) arcsine The inverse of the sine ratio \(\sin\) (opposite side ÷ hypotenuse). It works back from the ratio to the angle. This calculator finds the angles with it. On a scientific calculator it is the sin⁻¹ key.
\(h\) h The altitude to the hypotenuse - the height from the right-angle vertex to the hypotenuse, with the hypotenuse as the base. It is the first letter of "height".

Terms

Pythagorean theorem The theorem that the three sides of a right triangle satisfy \(a^2 + b^2 = c^2\) (c is the hypotenuse). It is named after the ancient Greek mathematician Pythagoras (around the 6th century BC). It is taught in Grade 8 math.
leg One of the two sides of a right triangle that form the right angle. The two legs are usually called a and b, and they are always shorter than the hypotenuse.
right triangle A triangle in which one of the three angles is exactly 90° (a right angle). The Pythagorean theorem works only for this shape.
hypotenuse The side of a right triangle opposite the right angle. It is the longest of the three sides, and in the Pythagorean theorem its square always stands alone on one side of the equation.
square root A number that gives the original number when squared. The positive square root of 25 is 5, and the square root of 2 is \(\sqrt{2} \approx 1.414\). Square roots are taught in Grade 8.
Pythagorean triple A set of three whole numbers that satisfy the Pythagorean theorem. (3, 4, 5), (5, 12, 13) and (8, 15, 17) are well known. They show up often in practice problems and when builders lay out square corners.
converse of the Pythagorean theorem The theorem that a triangle whose three sides satisfy \(a^2 + b^2 = c^2\) is a right triangle. By measuring only the sides, you can check whether an angle is a right angle, so it is used on real construction sites.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.

Squares and exponents (Grade 6)
  • Knowing that squaring a number means multiplying it by itself, as in \(3^2 = 3 \times 3 = 9\)
  • Being able to square a decimal too (for example, \(1.5^2 = 2.25\))
Square roots (Grade 8)
  • Being able to restate "the positive number that gives 25 when squared" as \(\sqrt{25} = 5\)
  • Knowing that a square root can be a number that never ends as a decimal, like \(\sqrt{2}\)
Triangle basics (Grades 4–6)
  • Being able to find the right angle (90°) in a figure
  • Knowing that the area of a triangle is "base × height ÷ 2"
The Pythagorean theorem (Grade 8)
  • Being able to tell which side of a right triangle is the hypotenuse (opposite the right angle, the longest side)
  • Keeping in mind that \(c\) in \(a^2 + b^2 = c^2\) is always the hypotenuse

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to check for a right triangle
Leg a 3
Leg b 4
Hypotenuse c 5
Value of a²+b² =B1^2+B2^2
Value of c² =B3^2
Table to find the hypotenuse c
Leg a 3
Leg b 4
Hypotenuse c =SQRT(B1^2+B2^2)
Table to find the missing leg b
Hypotenuse c 13
Known leg a 5
Missing leg b =SQRT(B1^2-B2^2)
Table to find the altitude to the hypotenuse h
Leg a 3
Leg b 4
Hypotenuse c 5
Altitude h =B1*B2/B3
After pasting, the upper rows are your inputs and the formula in the last row is calculated automatically.
"^2" squares a number, and "SQRT(…)" is the Excel function for the square root.
In the first table, if the value of a²+b² (B4) and the value of c² (B5) are equal, the triangle is a right triangle (for the example 3, 4, 5, both are 25).
In the second table, B3 shows the hypotenuse, 5. Just replace the input numbers with your own side lengths.

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to check for a right triangle
Leg a 3
Leg b 4
Hypotenuse c 5
Value of a²+b² =B1^2+B2^2
Value of c² =B3^2
Table to find the hypotenuse c
Leg a 3
Leg b 4
Hypotenuse c =SQRT(B1^2+B2^2)
Table to find the missing leg b
Hypotenuse c 13
Known leg a 5
Missing leg b =SQRT(B1^2-B2^2)
Table to find the altitude to the hypotenuse h
Leg a 3
Leg b 4
Hypotenuse c 5
Altitude h =B1*B2/B3
The same formulas as in Excel (the SQRT function and ^2) work as is. Copy the whole table, paste it into cell A1, and replace the input numbers with your own side lengths.

How to calculate it in Python

import math

side_a = 3.0   # leg a
side_b = 4.0   # leg b

hypotenuse = math.sqrt(side_a ** 2 + side_b ** 2)   # hypotenuse c (math.hypot(side_a, side_b) gives the same)
area = side_a * side_b / 2                          # area
perimeter = side_a + side_b + hypotenuse            # perimeter
height = side_a * side_b / hypotenuse               # altitude to the hypotenuse
angle_alpha = math.degrees(math.asin(side_a / hypotenuse))   # angle opposite leg a (degrees)

print(f"Hypotenuse c: {hypotenuse}")
print(f"Area: {area}")
print(f"Perimeter: {perimeter}")
print(f"Altitude to the hypotenuse: {height}")
print(f"Angle alpha: {angle_alpha}")

# If you know the hypotenuse c and leg a, find the missing leg b with
# side_b = math.sqrt(hypotenuse ** 2 - side_a ** 2)
Runs with only the standard math library. "**" raises to a power (here, squaring) and "math.sqrt" is the square root. Change the two side lengths at the top and run it.

How to write it in LaTeX and other math languages (copy and paste)

The Pythagorean theorem (how the three sides are related)
a² + b² = c²
a^2 + b^2 = c^2
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msup><mi>a</mi><mn>2</mn></msup>
    <mo>+</mo>
    <msup><mi>b</mi><mn>2</mn></msup>
    <mo>=</mo>
    <msup><mi>c</mi><mn>2</mn></msup>
  </mrow>
</math>
a^2 + b^2 = c^2
a^2 + b^2 == c^2
a^2 + b^2 = c^2;
a^2 + b^2 == c^2
a^2 + b^2 = c^2
Formula for the hypotenuse \(c\)
c = √(a² + b²)
c = \sqrt{a^2 + b^2}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>c</mi>
    <mo>=</mo>
    <msqrt>
      <mrow>
        <msup><mi>a</mi><mn>2</mn></msup>
        <mo>+</mo>
        <msup><mi>b</mi><mn>2</mn></msup>
      </mrow>
    </msqrt>
  </mrow>
</math>
c = sqrt(a^2 + b^2)
Sqrt[a^2 + b^2]
c := sqrt(a^2 + b^2);
c = sqrt(a^2 + b^2);
c = √(a^2 + b^2)
Formula for a missing leg
b = √(c² − a²)
b = \sqrt{c^2 - a^2}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>b</mi>
    <mo>=</mo>
    <msqrt>
      <mrow>
        <msup><mi>c</mi><mn>2</mn></msup>
        <mo>&#x2212;</mo>
        <msup><mi>a</mi><mn>2</mn></msup>
      </mrow>
    </msqrt>
  </mrow>
</math>
b = sqrt(c^2 - a^2)
Sqrt[c^2 - a^2]
b := sqrt(c^2 - a^2);
b = sqrt(c^2 - a^2);
b = √(c^2 - a^2)
Altitude to the hypotenuse
h = a × b ÷ c
h = \frac{ab}{c}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>h</mi>
    <mo>=</mo>
    <mfrac>
      <mrow><mi>a</mi><mi>b</mi></mrow>
      <mi>c</mi>
    </mfrac>
  </mrow>
</math>
h = (a b)/c
a*b/c
h := a*b/c;
h = a*b/c;
h = ab/c

How to have ChatGPT  do the calculation

You are a geometry calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing).

In a right triangle, the two legs are a = 3 and b = 4.
Find each of the following:
1. The length of the hypotenuse c (Pythagorean theorem c = √(a² + b²))
2. Angle α (opposite leg a) and angle β (opposite leg b) in degrees
3. The area and the perimeter
4. The altitude to the hypotenuse h = ab ÷ c

Show the formulas you used and the numbers from the execution result.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.