Law of Cosines Calculator Formula Steps and Examples 2026

law of cosines calculator

A law of cosines calculator finds an unknown side or angle in a triangle that is not necessarily right-angled. Enter two sides and the included angle to find the third side, or enter all three sides to find an angle. The key is matching each side with its opposite angle before using the formula.

The law of cosines extends the Pythagorean theorem to any triangle. It is especially useful for SAS (side-angle-side) and SSS (side-side-side) problems, where the simpler right-triangle relationships do not apply.

Law of cosines calculator formula

Law of Cosines Calculator, For a triangle with sides a, b, and c, opposite angles A, B, and C, the standard form is:

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

Use the version whose known angle is paired with its opposite unknown side. The three equivalent forms are:

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

To calculate an angle from three known sides, rearrange the formula. For angle C:

C = cos⁻¹[(a² + b² − c²) / (2ab)]

Here, cos⁻¹ means inverse cosine, also shown as arccos on many calculators. It does not mean 1 divided by cosine.

What values to enter

Law of Cosines Calculator, A triangle calculator needs enough information to determine a unique triangle. The most common valid input sets for the law of cosines are SAS and SSS.

Known informationWhat you can calculateFormula approach
Two sides and the included angle (SAS)The third sideUse c² = a² + b² − 2ab cos(C), with the angle between the two known sides
All three sides (SSS)Any angleUse an inverse-cosine form
Two angles and one side (ASA or AAS)Remaining sidesFind the third angle, then use the law of sines
Two sides and a non-included angle (SSA)Sometimes one, two, or no trianglesUsually begin with the law of sines and check for the ambiguous case

For SAS, the angle must be the angle between the two known sides. If it is opposite one of them instead, it is an SSA problem, not a direct law-of-cosines side calculation.

How to calculate a missing side

Law of Cosines Calculator, Use this method when you know two sides and the angle formed where those sides meet.

  1. Label the known angle and identify the side directly opposite it.
  2. Choose the matching law of cosines form.
  3. Square the two known side lengths.
  4. Calculate the product 2ab cos(C).
  5. Subtract that product from the sum of the squared sides.
  6. Take the positive square root to get the missing side length.

Example: two sides and an included angle

Law of Cosines Calculator, Suppose a = 7, b = 10, and C = 60°. Find c.

c² = 7² + 10² − 2(7)(10) cos(60°)

Since 7² = 49, 10² = 100, and cos(60°) = 0.5:

c² = 49 + 100 − 140(0.5) = 79

c = √79 ≈ 8.89

Law of Cosines Calculator, The missing side is approximately 8.89 units. Keep more decimal places during the calculation and round only at the end if the situation allows it.

How to calculate a missing angle

Law of Cosines Calculator, When all three side lengths are known, rearrange the law of cosines and use inverse cosine. Make sure the numerator subtracts the square of the side opposite the angle you want.

  1. Choose the angle to find. For example, find C, opposite side c.
  2. Use C = cos⁻¹[(a² + b² − c²) / (2ab)].
  3. Calculate the fraction inside the brackets first.
  4. Apply inverse cosine and report the result in degrees or radians as required.

Example: three known sides

Law of Cosines Calculator, Suppose a = 5, b = 8, and c = 10. Find angle C.

C = cos⁻¹[(5² + 8² − 10²) / (2 × 5 × 8)]

C = cos⁻¹[(25 + 64 − 100) / 80]

C = cos⁻¹(−11/80) ≈ 97.9°

Angle C is obtuse because its opposite side, c = 10, is the longest. This is a helpful reasonableness check.

Degrees, radians, and calculator settings

Law of Cosines Calculator, Most school geometry problems state angles in degrees, so the calculator must be in degree mode. A calculator set to radians will produce a different result if you enter an angle such as 60 without converting it.

Use radian mode only when the angle is given in radians, or the problem specifically calls for it. A full circle is 360° or 2π radians. In standard geometry, the three interior angles of a triangle add to 180°.

How to check whether the answer makes sense

Law of Cosines Calculator, A numerical answer is not automatically a valid triangle. These quick checks catch many entry and labeling errors.

  • Triangle inequality: the sum of any two side lengths must be greater than the third side.
  • Side-angle order: the longest side is opposite the largest angle, and the shortest side is opposite the smallest angle.
  • Angle sum: all interior angles must total 180°.
  • Right-angle check: if the included angle is 90°, cosine is zero. The law of cosines becomes c² = a² + b².
  • Obtuse-angle check: if the included angle is greater than 90°, its cosine is negative. The side opposite that angle should be relatively long.

For an angle calculation, the expression inside arccos must fall from −1 to 1. A value outside that range usually means the three lengths cannot form a triangle, or a number was entered incorrectly.

Common law of cosines mistakes

Using the wrong opposite side: The c² term must represent the side across from angle C. The labels are not fixed; consistency is what matters.

Forgetting the square root: The formula first gives c². Take the square root to get c.

Leaving out the factor of 2: The middle term is 2ab cos(C), not ab cos(C).

Using cosine instead of inverse cosine for an angle: To find an angle from side lengths, use cos⁻¹ or arccos after isolating the cosine expression.

Rounding too early: Premature rounding can change later angle or side results. Retain calculator precision until the final step.

Assuming every two-side-and-one-angle problem is SAS: If the known angle is not included between the two known sides, there may be no triangle or more than one possible triangle.

When to use the law of cosines instead of the law of sines

Use the Law of Cosines Calculator when you have two sides and their included angle or all three sides. It directly produces the missing side or angle in those cases.

The law of sines is often more convenient when you know an angle and its opposite side, plus another angle or side. In an SSA problem, the law of sines is usually the starting point, but the data can create an ambiguous case. The law of cosines may still help verify any resulting triangle.

Practical uses of the formula

The law of cosines calculates straight-line distances when two measured distances meet at a known angle. It appears in surveying, navigation, construction layouts, engineering drawings, computer graphics, and physics problems involving vectors. In each case, units should stay consistent: do not combine meters with feet, for example, unless one has been converted first.

Frequently asked questions

Can the Law of Cosines Calculator be used for a right triangle?

Yes. With a 90° included angle, the cosine term is zero, and the formula reduces to the Pythagorean theorem.

What is the difference between the law of cosines and the Pythagorean theorem?

The Pythagorean theorem applies only to right triangles. The law of cosines applies to any triangle and includes an angle term that becomes zero in a right triangle.

Why does a law of cosines calculator show an error?

Common causes include entering an impossible set of side lengths, using an angle in the wrong calculator mode, or placing the side opposite the target angle in the wrong position in the formula.

Can the law of cosines find all angles of a triangle?

Yes, if all three side lengths are known and they satisfy the triangle inequality. Apply an inverse-cosine version of the formula for each angle, or find one or two angles and use the 180° angle sum.

Do side lengths need units?

They may be in any consistent unit, such as centimeters, meters, or miles. The calculated side will be in that same unit; angles are unitless and are normally reported in degrees.

Using the result correctly

A law of cosines calculator is most reliable when the triangle is labeled carefully, the correct input set is selected, and the result is checked against basic triangle rules. For SAS, calculate the side opposite the included angle. For SSS, use inverse cosine to calculate the angle opposite the side being subtracted. Those two patterns solve most law-of-cosines problems accurately.

Similar Posts