Triangle Length Calculator - SAS Law of Cosines
Use this triangle length calculator to find the third side of any triangle from two side lengths and the included angle using the law of cosines.
Triangle Length Calculator
Results
What Is Triangle Length Calculator?
The triangle length calculator finds the missing third side of any triangle when two side lengths and the included angle are known. It applies the law of cosines, converts the included angle from degrees to radians, and returns the closing side in the same length unit as the inputs.
- • Geometry homework: Drop in the two given side lengths and the angle between them, then copy the third side into the next step.
- • Roof and rafter layout: Translate a measured wall plate, a rafter length, and the peak angle into the rafter rise or the diagonal run.
- • Land and survey plots: Compute a missing boundary distance from two tape-measured sides and the angle at the shared corner.
- • Navigation and bearing problems: Estimate the closing leg from two course distances and the bearing change at the turn.
The law of cosines, also called the cosine rule, is the right tool for the SAS case. The Pythagorean theorem is the same formula with the included angle fixed at 90 degrees, so the calculator handles right triangles as a built-in case rather than a separate mode.
Keep every input in the same length system. The angle is read in degrees no matter the length unit, and the returned side is expressed in whatever length unit was used for the inputs.
When the triangle being measured is clearly a right triangle, the Right Triangle Calculator can solve the hypotenuse directly without a separate law of cosines step.
How Triangle Length Calculator Works
The triangle length calculator takes the two side lengths and the included angle, converts the angle to radians, and returns the third side as the square root of a squared plus b squared minus two times a times b times the cosine of the included angle. The cosine of the included angle and the triangle perimeter are shown alongside the third side so each step stays auditable.
- side a: first known length of the triangle, in any length unit
- side b: second known length of the triangle, sharing the included angle with side a
- included angle gamma: angle between sides a and b, entered in degrees and converted to radians for the cosine
- third side c: computed length of the side opposite the included angle, returned in the same length unit as the inputs
The cosine of the included angle carries the geometry. When the angle is acute, the cosine is positive and the third side is shorter than the simple sum of the two inputs. When the angle is obtuse, the cosine is negative and the third side grows longer.
Converting the angle to radians is a small step with real consequences. Skipping it would evaluate the cosine of a degree value and return a meaningless third side, so the calculator performs the conversion before any trigonometry.
3-4-5 right triangle: sides 3 and 4 with included angle 90 degrees
Enter side a = 3, side b = 4, and included angle = 90.
cos(90 deg) = 0, so c = sqrt(9 + 16 - 0) = 5.
Third side = 5.00 length units, triangle perimeter = 12.00 length units.
The cosine of 90 degrees is zero, so the law of cosines reduces to the Pythagorean theorem and the calculator returns the familiar hypotenuse.
Equilateral triangle: sides 6 and 6 at 60 degrees
Enter side a = 6, side b = 6, and included angle = 60.
cos(60 deg) = 0.5, so c = sqrt(36 + 36 - 36) = 6.
Third side = 6.00 length units, triangle perimeter = 18.00 length units.
An equilateral triangle has three matching sides, and the cosine of 60 degrees keeps the closing side equal to the two inputs.
Roof rafter: sides 9 and 16 with included angle 90 degrees
Enter side a = 9, side b = 16, and included angle = 90.
cos(90 deg) = 0, so c = sqrt(81 + 256) = 18.36.
Third side = 18.36 length units, triangle perimeter = 43.36 length units.
The closing leg is the diagonal across a right angle, so the law of cosines again becomes the Pythagorean theorem.
According to Wolfram MathWorld, the law of cosines states that c^2 = a^2 + b^2 - 2ab cos(gamma), and reduces to the Pythagorean theorem when gamma equals 90 degrees.
Once the third side is known, the Triangle Area Calculator turns the same side lengths into the area of the triangle using base-height, Heron's formula, or the SAS area rule.
Key Concepts Explained
These four ideas decide whether the law of cosines is the right tool and how to read the result.
Law of Cosines
The law of cosines relates the three sides of any triangle to one of its angles. The closing side is the square root of a squared plus b squared minus two times a times b times the cosine of the included angle.
Included Angle
The included angle is the angle formed where the two known sides meet. Using an angle to a different vertex returns the wrong closing side, so the SAS pattern is what makes the law of cosines work.
Pythagorean Connection
When the included angle is 90 degrees, the cosine is zero and the law of cosines collapses to the Pythagorean theorem. The calculator handles this as a built-in case.
Radian Conversion
The cosine function in JavaScript takes an angle in radians, so the calculator multiplies the degree input by pi over 180 before evaluating the cosine. Skipping the conversion is the most common source of a wrong answer.
When the job is to recover all three sides and all three angles at once, the Triangle Calculator accepts the same SAS measurements and returns the full triangle solution.
How to Use This Calculator
Read the two side lengths and the angle between them from your problem, drop them into the form, and use the third side as soon as it appears.
- 1 Measure the two known sides: Pick the two sides of the triangle that share a common vertex, then measure each in the same length unit.
- 2 Read the included angle: The included angle sits at the vertex where the two measured sides meet. Read it in degrees.
- 3 Enter the values: Type the first side into side a, the second into side b, and the included angle into the angle field. The result updates as soon as the third value is in place.
- 4 Read the third side: The primary result is side c, returned in the same length unit as the inputs.
- 5 Audit the cosine and the perimeter: The cosine of the included angle and the triangle perimeter keep each step auditable.
- 6 Fix invalid input errors: Check for a zero or negative side, a missing field, or an included angle outside (0, 180) degrees.
A roof gable has a wall plate of 24 feet, a rafter length of 16 feet, and a peak angle of 50 degrees at the plate. Enter side a = 24, side b = 16, and included angle = 50. The calculator returns c = sqrt(24^2 + 16^2 - 2 * 24 * 16 * cos(50 deg)) = 19.15 length units, which is the diagonal run of the rafter across the plate.
After the third side is known, the Perimeter of a Triangle with Fractions Calculator adds the three side lengths into a triangle perimeter that handles fractional measurements cleanly.
Benefits of Using This Calculator
Pulling the law of cosines into a single form keeps the missing side one click away from the SAS measurements.
- • Direct SAS support: Two sides and the included angle are exactly the inputs the law of cosines needs, so the third side comes back without intermediate steps.
- • Real-time updates: Every change to a side length or the included angle updates the third side on the spot.
- • Auditable support values: The cosine of the included angle and the triangle perimeter appear next to the third side.
- • Built-in Pythagorean case: An included angle of 90 degrees reduces the law of cosines to the Pythagorean theorem, so the calculator handles right triangles without a separate mode.
- • Unit-agnostic length output: The same calculator handles inches, feet, centimeters, and meters because the third-side label follows the input length unit.
- • Input validation: Zero or negative sides, missing fields, and angles outside (0, 180) degrees are caught and explained instead of returning a misleading zero or a NaN.
The SAS input pattern is the natural choice for two sides and the angle between them. Right triangles are the boundary case. Setting the included angle to 90 degrees turns the law of cosines into the Pythagorean theorem, which keeps the calculator useful for the most familiar triangle type without a separate mode.
If the larger shape is a polygon that has to be split into triangles before its area can be found, the Polygon Area Calculator uses the same side-and-angle measurements to set up each piece.
Factors That Affect Your Results
The math is exact, but the precision of the inputs and the unit choice decide how trustworthy the third side is.
Side-length precision
Small errors in the two known sides move the third side by a similar share. A 1 percent error in a known side typically changes the third side by less than 1 percent for most triangles.
Included-angle precision
The cosine of the included angle drives the formula, so a 1 degree error in the angle can shift the third side by several percentage points when the angle is near 0 or 180.
Radian conversion
The cosine function in JavaScript takes radians, so the calculator multiplies the degree input by pi over 180 before evaluating the cosine.
Rounding
The displayed third side, perimeter, and cosine are rounded to two or four decimal places. Hand calculations that round after each step may differ by a few hundredths.
- • The law of cosines assumes the included angle sits between the two known sides. An angle to a different vertex produces a wrong closing side.
- • The cosine function in the browser rounds near 0 and 180 degrees, so an angle reported as exactly 180 would return a slightly negative radicand. The calculator clamps that to zero but also rejects the input.
- • The calculator returns a geometric length only. Real measurements may need to add tolerance for tape stretch, plumb bob sag, or surface roughness.
If the third side seems off, the most common cause is that the entered angle is not the included angle. Check that the angle is read at the vertex shared by the two known sides.
According to Khan Academy, the law of cosines generalizes the Pythagorean theorem by relating the three sides of any triangle to one of its angles, with c^2 = a^2 + b^2 - 2ab cos(C).
According to OpenStax, the law of cosines can be used to find the length of a missing side of any triangle when two sides and the included angle are known.
When the layout also includes a rectangular piece that needs its own quick length times width estimate, the Length Width Area Rectangle Calculator keeps the simpler shape on the same workflow.
Frequently Asked Questions
Q: How do I find the third side of a triangle with two sides and an angle?
A: Apply the law of cosines to the two known sides and the included angle. The third side c equals the square root of a squared plus b squared minus two times a times b times the cosine of the included angle, with the angle entered in degrees and converted to radians first.
Q: What is the law of cosines formula for a triangle?
A: The law of cosines for the side opposite the included angle gamma is c^2 = a^2 + b^2 - 2ab cos(gamma). Taking the square root gives the closing side. When gamma is 90 degrees, the cosine term drops out and the formula reduces to the Pythagorean theorem.
Q: When should I use the law of cosines instead of the Pythagorean theorem?
A: Use the law of cosines whenever the included angle is not exactly 90 degrees. The Pythagorean theorem only handles right triangles, so an oblique triangle needs the cosine term.
Q: What is the included angle in the law of cosines?
A: The included angle is the angle at the vertex where the two known sides meet. The SAS (side-angle-side) input pattern is what makes the law of cosines work.
Q: What happens if the included angle is 90 degrees?
A: When the included angle is 90 degrees, the cosine of the angle is zero, so the law of cosines collapses to the Pythagorean theorem and returns the same hypotenuse.
Q: Can the third side be longer than the sum of the other two sides?
A: No. The law of cosines keeps the closing side shorter than the simple sum of the two known sides for any included angle between 0 and 180 degrees, which matches the triangle inequality.