Boneyard Tools

Law of Cosines Calculator

The law of cosines solves any triangle from either two sides plus the angle between them or all three side lengths. Choose SAS to enter sides a and b with the included angle C, or SSS to enter all three sides, and the calculator returns every side, all three angles in degrees and the area. Angles always add up to 180 degrees, and each result is rounded to four decimal places.

How to use the law of cosines

  1. Pick a mode: Two sides + angle (SAS) or Three sides (SSS).
  2. Enter Side a and Side b, the two known sides.
  3. For SAS, enter the Included angle C in degrees; for SSS, enter Side c.
  4. Read Side c or the three angles A, B and C plus the triangle area.
  5. Use Copy result to save every side, angle and the area as text.

Examples

SAS: two sides and the included angle

Mode SAS, Side a = 5, Side b = 7, angle C = 37 degrees
Side c 4.2539, Angle A 45.0215, Angle B 97.9785, Angle C 37, Area 10.5318

SSS: the 3-4-5 right triangle

Mode SSS, Side a = 3, Side b = 4, Side c = 5
Angle A 36.8699, Angle B 53.1301, Angle C 90, Area 6

SSS: a scalene 7-8-9 triangle

Mode SSS, Side a = 7, Side b = 8, Side c = 9
Angle A 48.1897, Angle B 58.4119, Angle C 73.3985, Area 26.8328

Frequently asked questions

What is the law of cosines?

The law of cosines states that c squared equals a squared plus b squared minus 2ab times the cosine of the included angle C. It generalizes the Pythagorean theorem, which is just the special case where angle C is 90 degrees and the cosine term vanishes.

When should I use SAS versus SSS?

Use SAS when you know two sides and the angle wedged between them, and the tool finds the third side first. Use SSS when you know all three side lengths and want the angles. The calculator switches its input fields to match the mode you pick.

In SAS mode, which angle is C?

Angle C is the included angle, the one formed where sides a and b meet. It must be entered strictly between 0 and 180 degrees. The tool uses it to compute side c, then derives the remaining two angles from the completed triangle.

How are angles A and B found after side c is known?

Once all three sides are known, each angle comes from rearranging the law of cosines, for example angle A equals the inverse cosine of (b squared plus c squared minus a squared) divided by 2bc. This is why both SAS and SSS report the full set of angles.

How is the area calculated?

The area is computed with Heron's formula from the three side lengths, using the semi-perimeter s to evaluate the square root of s(s-a)(s-b)(s-c). This gives the same result as the one half times a times b times sine C formula for SAS inputs.

Why are some three-side inputs rejected?

Three lengths only form a real triangle when each pair of sides sums to more than the third, the triangle inequality. If you enter sides like 1, 2 and 5, no triangle closes, so the tool shows a warning rather than an impossible answer.

Are angles in degrees or radians?

You enter and read every angle in degrees. Internally the included angle is converted to radians before the cosine and sine are taken, then all output angles are converted back to degrees, so you never deal with radians directly.

Do the three angles always add to 180?

Yes. Because the angles are derived from a single consistent set of side lengths, they sum to 180 degrees. Small rounding at the fourth decimal place can appear, and the tool clamps cosine values into the valid range to avoid errors on near-degenerate triangles.

Does anything I enter leave my device?

No. The solver runs entirely in your browser with local JavaScript. Your side lengths and angle stay on your machine and nothing is uploaded, so the tool keeps working even without an internet connection.

Learn more

Related tools