Method Deck / geometry

Right triangle side by the Pythagorean theorem

Computes the missing side of a right triangle (hypotenuse or a leg) given the other two sides.

Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.

Try it

Inputs

Outputs

Steps

  1. The Pythagorean theorem: for a right triangle with legs a and b and hypotenuse c, a^2 + b^2 = c^2.
  2. If mode is find_hypotenuse: c = sqrt(known_a^2 + known_b^2), where known_a and known_b are the two legs.
  3. If mode is find_leg: known_b is the hypotenuse and known_a is a leg; the missing leg = sqrt(known_b^2 - known_a^2). known_b must be greater than known_a.
  4. Round to 2 decimals.

Constants

None.

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"mode":"find_hypotenuse","known_a":3,"known_b":4}5.00
test vector: find a leg{"mode":"find_leg","known_a":5,"known_b":13}12.00

Published card