The Law of Cosines Calculator may be used to solve a variety of triangle problems. The law of cosines and the law of cosine formula and applications will be addressed. Also, in addition to this calculator, we think that these related calculators can also help you: Triangle Angle Calculator, Cofunction Calculator, and also this 30 60 90 Triangle.

Further, on our site you can find more math calculators to help you, such as Area of a Regular Polygon, Area of Trapezoid and Circle Calculator. Meanwhile, scroll down to see examples of the law of cosines in action and to understand when and how to use it.

Law of Cosines – Definition

You probably ask yourself – What is the law of cosines?

The Law of Cosines explains the connection between the lengths of the sides of a triangle and the cosine of its angles. It may be useful to solve any triangle, not only right triangles. The Pythagorean theorem is generalized by this law, which allows you to compute the length of one of the sides given the lengths of the other sides and the angle between them.

Euclid’s Element, a mathematical treatise encompassing definitions, postulates, and geometry theorems, contained the law. But, because the idea of cosine had not yet been created, Euclid did not formulate it in the manner we know it now:

AB^{2}=CA^{2}+CB^{2}-2\cdot CA\cdot CH 

Euclid’s theorem, on the other hand, may be readily reformulated to the current cosine formula form:

CH=CB\cdot \cos(\gamma)

so we get the

AB^2=CA^2+CB^2-2\cdot CA\cdot CB\cdot \cos(\gamma)

Then, how to do the Law of Cosines?

We get the familiar expression by changing the notation:

c^{2}=a^2+b^2-2 \cdot a \cdot b\cdot \cos(\gamma)

In the 15th century, Persian mathematician d’Al-Kashi gave the first precise equation of the cosine rule. The law was popularized in the 16th century by famed French mathematician Viète before taking its ultimate form in the 19th century.

Law of Cosines Formula

In a right triangle, the angle gamma is the angle between legs a and b, which is 90°. This formula for calculating the cosine is reduced to the well-known equation of the Pythagorean theorem since the cosine of 90° is 0:

a^2=b^2+c^2-2 \cdot a \cdot b\cdot \cos(90^\circ)

Law of Sines vs. Law of Cosines

When to use law of cosines or sine?

If we have a) two angles and one side, or b) two sides and a non-included angle, we utilize the sine rule. When we are provided either a) three sides or b) two sides and the included angle, we utilize the cosine rule. Examine the triangle ABC in the diagram below.

Example B = 21 cm, C = 46 cm, and AB = 9 cm in the triangle ABC.

When given SAS or SSS quantities, apply the law of cosine. This would be SAS if you were given the lengths of sides b and c, as well as the measure of angle A. When we know the lengths of the three sides a, b, and c, we call it SSS. When you have ASA, SSA, or AAS, apply the law of sines.

Law of Cosines Calculator – How to Use?

This math calculator is easy to use:

  • Begin by defining your problem. You may, for example, know two sides of a triangle and the angle between them and are seeking for the third.
  • Fill up the blanks on this triangle calculator using the known values. Remember to double-check whether you used the right symbols to represent the sides and angles in the diagram above.
  • Watch how our law of cosines calculator calculate all of the work for you!

Law of Cosines Calculator – Example

To calculate the angles of a triangle with respect to all three edges, follow the modified law of cosines equation, with the inverse cosine:

\alpha=\arccos\frac{b^2+c^2-a^2}{2\cdot b \cdot c}
\beta=\arccos\frac{a^2+c^2-b^2}{2\cdot a \cdot c}
\gamma=\arccos\frac{a^2+b^2-c^2}{2 \cdot a \cdot b}

Let’s look at one of the angles and see what we can come up with. Assume that a is 4 inches long, b is 5 inches long, and c is 6 inches long. The first equation will help us to determine:

\alpha=\arccos\frac{5^2+6^2-4^2}{2\cdot 5\cdot 6}=41.41^\circ

The second angle may be calculated analogically from the second equation, and the third angle can be found by remembering that the total of the angles in a triangle equals 180°.

If you want to save time, enter the edges lengths into our law of cosines calculator – it’s a sure thing! Simply take these easy steps:

  • Choose an option based on the values provided (The second option – SSS – 3 sides).
  • Fill in the values that you already know. Type the sides as follows: a = 4 in, b = 5 in, and c = 6 in.
  • The calculator displays the result! The angles in our example are equal to 41.41°, 55.77°, and 82.82°.

When to Use Law of Cosines?

You may use this law of cosines formula to solve various triangulation difficulties (solving a triangle). They can be useful in the following situations.

  • Knowing two sides and the angle between them (SAS), find the third side of a triangle:
a=\sqrt{b^2+c^2-2 \cdot b \cdot c\cdot \cos(\alpha)}
b=\sqrt{a^2+c^2-2 \cdot a \cdot c\cdot \cos(\beta)} 
c=\sqrt{a^2+b^2-2 \cdot a \cdot b\cdot \cos(\gamma)}
  • Knowing all three sides we can calculate the triangle’s angles (SSS):
\alpha=\arccos\frac{b^2+c^2-a^2}{2\cdot b\cdot c}
\beta=\arccos\frac{a^2+c^2-b^2}{2\cdot a \cdot c}
\gamma=\arccos\frac{a^2+b^2-c^2}{2 \cdot a \cdot b}
  • Using two sides and an angle oppositie one of them (SSA) we can calculate the third side of a triangle.
a=b\cdot \cos(\gamma) \pm\sqrt{c^2-b^2\cdot \sin^2(\gamma)}
b=c\cdot \cos(\alpha) \pm \sqrt{a^2-c^2\cdot \sin^2(\alpha)}
c=a\cdot \cos(\beta) \pm \sqrt{b^2-a^2\cdot \sin^2(\beta)}

Just keep in mind that knowing two edges and an adjacent angle might result in two different triangles (or one or zero positive solutions, depending on the given data). As a result, we’ve opted to apply SAS and SSS in this tool rather than SSA.


What is the law of cosines?

To determine the remaining cross-section of an oblique (false) triangle when the two-side lengths and the measures of the angle involved (SAS) or the length of three sides (SSS) are known, we apply the law of cosine.

How to find an angle using the law of cosines?

\gamma=\arccos\frac{a^2+b^2-c^2}{2 \cdot a \cdot b}

When to use a law of sines and cosines?

When we are given a) two angles and one side, or b) two edges and a non-included angle, we utilize the law of sine rule. Also, when we are provided either a) three sides or b) two sides and the included angle, we utilize the cosine rule.

Does the cosine rule work with radians?

Absolutely! The outcome will be the same whether you convert degrees to radians and then plug them into a trigonometric function that accepts radians as an input. Law of Cosines has a wide use in math.