Skip to main content
Skip to calculator
Advertisement

Last updated: July 31, 2026

Law of Cosines Calculator

Helpful
Not helpful
Save as image
Share
Embed
Cite
Write feedback

Formula

c = √(a²+b²-2ab cos(C)), A = arccos((b²+c²-a²)/(2bc)), B = 180°-A-C, Area = 1/2 ab sin(C)

Where:

  • a,b,c=Triangle side lengths
  • A,B,C=Triangle angles(°)
cbaCLaw of cosinesc² = a² + b² - 2ab cos(C)SAS triangle solver

Worked Examples

SAS triangle with 60° angle

Use a = 5, b = 7, C = 60°.

  1. 1c = √(25+49-35) = √39 ≈ 6.244998.
  2. 2A ≈ 43.897886° from the inverse cosine formula.
  3. 3B = 180 - 43.897886 - 60 ≈ 76.102114°.
  4. 4Area = 1/2 × 5 × 7 × sin(60°) ≈ 15.155445.
Final Answer: side c ≈ 6.244998

Right-triangle style case

If C = 90°, the law of cosines reduces to the Pythagorean theorem.

  1. 1cos(90°) = 0, so c = √(3²+4²) = 5.
  2. 2Then solve the remaining angles from the triangle.
  3. 3Area = 6.
Final Answer: side c = 5

Invalid angle input

Angles must be strictly between 0° and 180°.

  1. 1Check the angle range before applying cosine.
  2. 2C = 180° does not define a proper triangle.
  3. 3The calculator returns an error.
Final Answer: Error: invalid included angle

Introduction

Use the law of cosines when you know two sides and the included angle of a triangle. This SAS calculator returns the missing third side, the remaining two angles, and the area from the same input set.

SAS Triangle Setup

The law of cosines is the natural tool for side-angle-side data.

  • You start with side a, side b, and the included angle C.

  • The formula finds the opposite side c first.

  • Once c is known, the remaining angles can be solved.

  • Area comes from the SAS area formula 1/2 ab sin(C).

Why Cosine Appears

The cosine term adjusts the third side for the opening angle between the known sides.

  • If C is small, side c tends to be shorter.

  • If C grows larger, side c increases.

  • At C = 90°, the cosine term vanishes.

  • That special case matches the Pythagorean theorem.

Finding the Remaining Angles

After side c is known, angle A comes from another cosine relationship.

  • The inverse cosine formula uses sides b, c, and a.

  • Angle B then follows from the triangle angle sum.

  • A + B + C must equal 180°.

  • Results are shown in degrees.

Input Validation

The calculator validates the SAS inputs before returning a result.

  • Both sides must be positive.

  • The included angle must be between 0° and 180°.

  • All numeric inputs must be finite.

  • Invalid inputs return an error record instead of throwing.

Worked Example

The sample 5, 7, 60° triangle demonstrates the full pipeline.

  • c ≈ 6.244998.

  • A ≈ 43.897886°.

  • B ≈ 76.102114°.

  • Area ≈ 15.155445.

When to Use It

This formula appears whenever the third side is opposite a known included angle.

  • Surveying and triangulation.

  • Structural and truss calculations.

  • Navigation and physics vector triangles.

  • Classroom geometry and trigonometry problems.

FAQs

What triangle case does this calculator solve?

It solves the SAS case: two sides and the included angle.

Why is side c the primary output?

Because side c is the first missing quantity found from the law of cosines formula.

Does this calculator also return the area?

Yes. It uses 1/2 ab sin(C) once the included angle is known.

What if C equals 90°?

Then the law of cosines reduces to the Pythagorean theorem.

Can angle C be 0° or 180°?

No. Those do not define a valid triangle interior angle.

Are the returned angles in degrees?

Yes. Angle A and angle B are returned in degrees.