Logo

MonoCalc

/

Law of Cosines Calculator

Geometry

Solve Mode

Three sides known → compute all three angles

Side a (cm)

Side b (cm)

Side c (cm)

Angle Unit

Length Unit

Decimal Places (0–10)

Triangle Type:

Obtuse
Angle A33.5573°
Angle B50.7035°
Angle C95.7392°
Side a (opp. A)5.0000 cm
Side b (opp. B)7.0000 cm
Side c (opp. C)9.0000 cm
Perimeter21.0000 cm
Area17.4123 cm²
Angle Sum Check180.0000°

Triangle Diagram

A33.5573°B50.7035°C95.7392°a=5.0000 cmb=7.0000 cmc=9.0000 cm

Formula Applied

cos(A) = (b² + c² − a²) / (2bc)

cos(A) = (7.0000² + 9.0000² − 5.0000²) / (2 × 7.0000 × 9.0000)

A = 33.5573°

About This Tool

Law of Cosines Calculator – Solve SSS and SAS Triangles

The Law of Cosines is one of the two fundamental relationships in triangle trigonometry, alongside the Law of Sines. Where the Pythagorean theorem works only for right triangles, the Law of Cosines applies to any triangle, making it the go-to formula for surveyors, engineers, physicists, and students tackling oblique triangles.

The Core Formula

The Law of Cosines has three symmetric forms, one for each pair of opposite sides and angles:

  • c² = a² + b² − 2ab·cos(C)
  • b² = a² + c² − 2ac·cos(B)
  • a² = b² + c² − 2bc·cos(A)

In each case, the side on the left is the one opposite the angle on the right. Rearranging any form isolates the cosine and lets you compute an unknown angle from three known sides.

Two Solve Modes

SSS (Side–Side–Side)

When all three side lengths are known, rearrange the formula to find each angle:

A = arccos((b² + c² − a²) / (2bc))

This mode is unambiguous — any set of three positive sides satisfying the triangle inequality produces exactly one triangle. The calculator verifies the triangle inequality before computing and flags degenerate inputs immediately.

SAS (Side–Angle–Side)

When two sides and the included angle (the angle between those two sides) are known, the formula computes the missing third side directly:

c = √(a² + b² − 2ab·cos(C))

Once the third side is found, the remaining angles follow by applying the rearranged formula twice more. Like SSS, SAS always yields a unique triangle with no ambiguity — unlike the SSA case handled by the Law of Sines.

Secondary Outputs

After the triangle is fully solved, the calculator provides:

  • Perimeter — the sum of all three sides.
  • Area — computed using Heron's formula: s = (a+b+c)/2; Area = √(s(s−a)(s−b)(s−c))
  • Triangle type — classified as Acute (all angles less than 90°), Right (one angle exactly 90°), or Obtuse (one angle greater than 90°).
  • Angle sum verification — confirms A + B + C = 180° (or π radians) to catch any floating-point drift.

Connection to the Pythagorean Theorem

The Pythagorean theorem is a special case of the Law of Cosines. When angle C is exactly 90°, cos(90°) = 0, so the entire −2ab·cos(C) term vanishes, leaving c² = a² + b². For acute triangles the cosine is positive, so the missing side is shorter than the Pythagorean prediction; for obtuse triangles the cosine is negative, so it is longer.

Angle Units and Precision

All internal calculations run in radians for numerical accuracy. The calculator converts degrees to radians at the input boundary and back to degrees at the output boundary, so you can work in whichever unit is natural for your application. The arccos argument is clamped to [−1, 1] to handle minor floating-point rounding that could otherwise produce a domain error.

Decimal precision is adjustable from 0 to 10 places. For engineering or surveying work, 4–6 places is typical. For classroom exercises, 2–3 places is usually sufficient.

Practical Applications

The Law of Cosines appears across many real-world domains:

  • Land surveying — computing plot dimensions when three boundary markers are measured but the angles between them are unknown.
  • Structural engineering — finding the length of a diagonal brace given two frame members and the angle at their joint.
  • Navigation — calculating the distance between two waypoints when the bearing and distances from a reference point are known.
  • Physics — resolving the magnitude of a resultant force vector when two forces and the angle between them are given.
  • Robotics — kinematics calculations for two-link manipulator arms where joint angles define end-effector position.
  • Pre-calculus education — solving oblique triangles in the standard curriculum when right-triangle methods are insufficient.

Validation and Error Handling

The calculator enforces all geometric constraints before computing. For SSS mode it checks that every side is positive and that the triangle inequality holds. For SAS mode it verifies that both sides are positive and the included angle lies strictly between 0° and 180°. If any constraint is violated, a clear error message describes which input is out of range.

Frequently Asked Questions

Is the Law of Cosines Calculator free?

Yes, Law of Cosines Calculator is totally free :)

Can I use the Law of Cosines Calculator offline?

Yes, you can install the webapp as PWA.

Is it safe to use Law of Cosines Calculator?

Yes, any data related to Law of Cosines Calculator only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

What is the Law of Cosines?

The Law of Cosines relates the lengths of a triangle's three sides to the cosine of one of its angles: c² = a² + b² − 2ab·cos(C). The formula has three symmetric forms — one for each angle — so it can solve for any missing side or angle depending on the given information.

When should I use the Law of Cosines instead of the Law of Sines?

Use the Law of Cosines when you know all three sides (SSS) or two sides and the included angle (SAS). The Law of Sines is more convenient when you know two angles and a side (AAS/ASA) or the non-included angle with two sides (SSA). For SSS and SAS cases, the Law of Cosines is the direct method with no ambiguity.

How do I find an angle using the Law of Cosines?

Rearrange the formula to isolate the cosine: cos(A) = (b² + c² − a²) / (2bc). Compute the right-hand side from the three known sides, then take the inverse cosine (arccos) to get angle A. Repeat the same process with the other two forms to find angles B and C.

Can the Law of Cosines solve any triangle?

The Law of Cosines can solve any triangle given SSS or SAS data. It cannot directly handle AAS, ASA, or SSA cases — those are typically addressed with the Law of Sines first. However, once the triangle is partially solved by any method, you can apply the Law of Cosines to verify or extend the solution.

How is the Law of Cosines related to the Pythagorean theorem?

The Pythagorean theorem (c² = a² + b²) is a special case of the Law of Cosines when angle C equals 90°. Because cos(90°) = 0, the term −2ab·cos(C) drops out entirely, leaving c² = a² + b². For any other angle, the cosine term adjusts the result upward (obtuse) or downward (acute) from the right-triangle baseline.