Law of Cosines Calculator (SAS)

The law of cosines is a² = b² + c² − 2bc cos A. For sides b = 5 and c = 7 with an included angle A = 60°, the third side is a = 6.245, the other angles are B = 43.90° and C = 76.10°, the area is 15.155 and the perimeter is 18.245.

Last updated · By · Runs in your browser, nothing is uploaded

Result

Step-by-Step Solution

Enter your values above to see the full working.

What Is the Law of Cosines?

The law of cosines is a generalisation of the Pythagorean theorem that works for any triangle, not just right-angled ones. It relates the three sides of a triangle to the cosine of one of its angles. When the angle is 90°, cos 90° = 0 and the formula collapses to the familiar a² = b² + c².

It lets you solve triangles in two situations where the simpler right-triangle methods fail: when you know two sides and the angle between them (SAS), you can find the third side; and when you know all three sides (SSS), you can find any angle. Once you have the sides and angles, the area and perimeter follow.

When to Use It

You knowCaseUse the law of cosines to find
Two sides and the included angleSASThe third side, then the other angles
All three sidesSSSAny angle
Two angles and a sideAAS / ASAUse the law of sines instead

Law of Cosines Formulas

a² = b² + c² − 2bc · cos A b² = a² + c² − 2ac · cos B c² = a² + b² − 2ab · cos C cos A = (b² + c² − a²) ÷ (2bc) Area = ½ b c sin A
  • a, b, c are the side lengths, and A, B, C are the angles opposite them.
  • The side a is opposite the angle A, and the angle A is the one included between sides b and c.
  • The angles of any triangle add to 180°.

For triangles where you know angles and a side, use the law of sines calculator. For three known sides, see also the triangle angle calculator and the triangle area calculator.

Worked Example: b = 5, c = 7, A = 60°

  1. Third side: a² = 25 + 49 − 2 × 5 × 7 × cos 60° = 74 − 70 × 0.5 = 39, so a = √39 = 6.245.
  2. Angle B: cos B = (a² + c² − b²) ÷ (2ac) = (39 + 49 − 25) ÷ (2 × 6.245 × 7) = 63 ÷ 87.43 = 0.7206, so B = 43.90°.
  3. Angle C: 180° − 60° − 43.90° = 76.10°.
  4. Area: ½ × 5 × 7 × sin 60° = 15.155.
  5. Perimeter: 5 + 7 + 6.245 = 18.245.

From Three Sides: 7, 8, 9

The angle opposite the side 7 is cos A = (64 + 81 − 49) ÷ (2 × 8 × 9) = 96 ÷ 144 = 0.6667, so A = 48.19°.

Two Ships Leaving a Port

One ship sails 50 km and another 80 km on courses 40° apart. The distance between them is √(2,500 + 6,400 − 8,000 cos 40°) = √2,771.7 = 52.65 km. The angles at the ships are 37.62° and 102.38°.

The Right-Angle Check

With A = 90°, the cosine term vanishes, so b = 3, c = 4 gives a = √(9 + 16) = 5, the Pythagorean theorem.

Combining Two Forces

Two forces of 50 N and 80 N act at an angle of 40° to each other. The resultant has magnitude √(50² + 80² + 2 × 50 × 80 × cos 40°) = √15,028 ≈ 122.6 N. The plus sign appears because the angle between the forces, tail to tail, is the supplement of the interior angle of the vector triangle.

How to Use This Law of Cosines Calculator

  1. Enter two sides, b and c.
  2. Enter the angle A between them, in degrees (between 0 and 180).
  3. Read the third side a, the angles B and C, the area and the perimeter.

Where the Law of Cosines Is Used

  • Surveying and navigation: distances between points that cannot be measured directly.
  • Engineering and structures: forces and member lengths in triangulated frames.
  • Physics: adding vectors that are not at right angles, including resultant forces.
  • Computer graphics and robotics: angles and distances in joints and meshes.
  • Astronomy: distances between stars from angular separations.

What Are the Most Common Mistakes With the Law of Cosines Calculator (SAS)?

  • Using the wrong angle. The angle must be the one between the two known sides, and opposite the side you solve for.
  • Forgetting the minus sign. The term is −2bc cos A, and for angles over 90° the cosine is negative, so the term becomes positive.
  • Calculator in radian mode. Enter the angle in degrees here.
  • Impossible triangles. The angle must be strictly between 0° and 180°.
  • Rounding too early. Small errors in a affect the angles.
  • Ambiguous cases. SAS and SSS give exactly one triangle, unlike SSA.

Where Can You Verify These Formulas?

The definitions and formulas on this page follow standard references. Check them against these sources:

Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.

Frequently Asked Questions

What is the law of cosines?

a² = b² + c² − 2bc cos A. It relates a side of any triangle to the other two sides and the angle between them.

When should I use the law of cosines?

When you know two sides and the included angle (SAS) or all three sides (SSS).

How is it related to the Pythagorean theorem?

When the angle is 90°, cos A = 0 and the law reduces to a² = b² + c².

How do I find an angle from three sides?

Rearrange: cos A = (b² + c² − a²) ÷ (2bc), then take the inverse cosine.

What if the angle is greater than 90°?

Its cosine is negative, so the formula gives a longer third side, which matches an obtuse triangle.

How do I find the area from the sides and angle?

Area = ½bc sin A. For b = 5, c = 7 and A = 60° the area is 15.155.