embed
X

Law of Cosines Calculator

+
Table of contents:
If you have any problems that involve triangles, a law of cosines calculator can help. This tool utilizes the law of cosines formula for almost any triangle-related question. Do you want to understand all there is to know about the law of cosines? Read on to discover more.

What is the Law of Cosines Formula?

Many different formulas relate to triangles. How they differ can depend on the angles and sides of that triangle. 

a2 = b2 + c2 – 2bc x cos (α) 
b² = a² + c² - 2ac x cos (β)
c² = a² + b² - 2ab x cos (γ)

The formula can also differ if you have a right triangle. Its angle between the a and b leg is 90 degrees – with a cosine of 0. In this instance, you reduce the formula to a Pythagorean theorem.

a² = b² + c² - 2bc x cos (90°)
a² = b² + c²

The Definition of the Law of Cosines

The law of cosines is the relationship of a triangle’s sides, angles, and cosine. The cosine formula applies to all triangles, which includes right triangles. With the law of cosine, you can use the Pythagorean theorem to calculate triangle sides and angles. 

The cosine law first appeared in Euclid’s Element, but it looked far different than how it does today. Euclid’s formula consisted of AB² = CA² + CB² - 2 * CA * CH for acute angles. Obtuse angles used the same formula, but with + instead of -. 

Even though it’s not the same as our cosine formula, you can adapt it. 

CH = CB x cos (γ)

Becomes:

AB² = CA² + CB² - 2 x CA x (CB x cos(γ))

If you change the notion, you get:

c² = a² + b² - 2ab x cos (γ)

The cosine law from the 15th and 16th century didn’t become what we know it as today until the 19th century. Until then, the Persian mathematician d’Al-Kashi had invented and used a different method.

When Do You Use the Law of Cosines?

Whenever you need to solve any problems with triangles, you can use a cosine formula. For example, let’s say you know two sides of a triangle and the middle angle. You want to know the third side measurements. Use this formula:

a = √ [ b² + c² - 2bc x cos(α)]
b = √ [a² + c² - 2ac x cos(β)]
c = √ [a² + b² - 2ab x cos(γ)]

What if you know all three sides of a triangle, but not the angle? 

α = arccos [(b² + c² - a²) / (2bc)]
β = arccos [(a² + c² - b²) / (2ac)]
γ = arccos [(a² + b² - c²) / (2ab)]

You can use a cosine formula if you know a triangle’s two sides and one angle opposite them. 

a = b x cos(γ) ± √ [c² - b² x sin²(γ)]
b = c x cos(α) ± √ [a² - c² x sin²(α)]
c = a x cos(β) ± √ [b² - a² x sin²(β)]

Having two sides and an angle will not always be enough. You can face the problem of two different triangle outcomes. Because of that possibility, we include SSS and SAS in this tool but leave out SSA.

Proving the Law of Cosines

There are several ways to determine the Law of cosines, such as trigonometry, Ptolemy’s theorem, distance formula, and the law of sines. Find more about these methods below.

Trigonometry



Divide the opposite side of the triangle into two parts. 
b = b1 + b2

From a cosine perspective, you might express b1 as a x cos (γ) and b2 as c x cos (α). 

From there, b = a x cos (γ) + bc x cos (α) (1)

You can use analogical equations for the two sides that remain:

a² = ac x cos (β) + ab x cos (γ) (2)
c² = bc x cos (α) + ac x cos (β) (3)

You may wonder why the bolded numbers appear after the equations. You have to add the first equation to the second, then subtract the third. 

The equation ends up looking like this:

a² + b² - c² = ac x cos(β) + ab X cos(γ) + bc x cos(α) + ab x cos(γ) - bc x cos(α) - ac x cos(β)

Simplify it to display the cosine rule:

a² + b² - c² = 2ab x cos (γ)
c² = a² + b² - 2ab x cos (γ)

The Distance Formula



In the image, you will see that C = (0,0), and A = (b,0). If you want the coordinates of b, you can use sine and cosine. 

B = (a x cos (γ), a x sin(γ))

When you use the distance formula, you learn that:

c = √ [(x₂ - x₁)² + (y₂ - y₁)²] = √[(a x cos (γ) - b)² + (a x sin (γ) - 0)²]

Which creates:

c² = a² x cos (γ)² - 2ab x cos (γ) + b² + a² x sin (γ)²
c² = b² + a² (sin (γ)² + cos (γ)²) - 2ab x cos (γ)

The sine and cosine sum of squares equal one, which helps us get the final formula.
 
c² = a² + b² - 2ab x cos (γ)

Ptolemy's Theorem



If you want a more straightforward method to find the law of cosines, then Ptolemy’s theorem is it. 

Take the picture with its triangle, for example. You build the congruent triangle with ADC. In that case, AD = BC, and DC = BA. The circumcircle with ABC already exists. 

From point D to B, the altitudes split the base of AC. CE is equal to FA. With the cosine definition, we know that CE is a x cos (γ). We can then write the equation as: 

BD = EF = AC - 2 x CE = b - 2 x a x cos (γ)

The next thing to focus on is ADBC, the quadrilateral. For this, we use Ptolemy’s theorem. This theorem explains the relationship between the two diagonals and four sides. When you have cyclic quadrilaterals, the sum of the opposite sides is equal to the two diagonals. 

BC x DA + CA x BD = AB x CD

Which means:

a² + b x (b - 2 x a x cos (γ)) + a² = c²

After simplifying the equation, the formula is:

c² = a² + b² - 2ab x cos (γ))

When you solve problems with acute, right, and obtuse triangles, all three formulas apply. With other triangles, you may want to try a combination of the law of sines and dot products.

How Do You Use a Law of Cosines Calculator?

If you use a law of cosines calculator, you can save yourself a lot of hard work. There are still a few steps involved, but not as many as if you solved the problem on your own.

The first step is to formulate your problem. If you know your triangle’s side measurements and angle, then find the final side. 

Put those values into the law of cosines calculator data boxes. The calculator will immediately provide you with an answer.

An SSS Example of Law of Cosines

Let’s say you have all triangle sides in a problem, but no angles. What are you going to do? This problem is an example of SSS, and you use the cosine rule formulas below.

α = arccos [(b² + c² - a²) / (2bc)]
β = arccos [(a² + c² - b²) / (2ac)]
γ = arccos [(a² + b² - c²) / (2ab)]

We will calculate the first angle with the data we have. Let’s say side a = 4 inches, b = 5 inches, and c = 6 inches. Below, we find a. 

α = arccos [(b² + c² - a²) / (2bc)] = arccos [(5² + 6² - 4²) / (2 x 5 x 6)] = arccos [(25 + 36 - 16) / 60] = arccos [(45/60)] = arccos [0.75]
α = 41.41°

You can calculate the second angle (b) similarly. With the third, you know all angles in a triangle equal 180°. The third angle is the value leftover to get 180°. 

If you’re in a hurry and want to save time, enter the side lengths into the law of sines calculator. Follow these steps below. 

1. Choose the option that suits your values. In our example, it would be SSS (three sides).  
2. Enter the values you know. We know a = 4, b = 5, and c = 6. 
3. Let the calculator produce the results.

Practice makes perfect, so why not play around with a few formulas? You can learn a lot about triangles by practicing!

Law of Cosines Calculator

+
Trigonometry Calculator
Percentage Increase Calculator
Percentage Difference Calculator
... more