Law of Cosines Calculator

Solve triangles using the law of cosines

The calculator will solve the given triangle using the law of cosines (wherever possible), with steps shown.

Related calculator: Law of Sines Calculator

If the calculator did not compute something or you have identified an error, or you have a suggestion/feedback, please write it in the comments below.

The Law of Cosines Calculator is an online tool for solving triangles using the cosine law. Use our free online calculator to determine the unknown side lengths or angles of a triangle.

How to Use the Law of Cosines Calculator?

  • Input

    Find out which sides and/or angles of your triangle you already know. You must have at least one side and either two other sides or a side and an angle. For scenarios with two known sides and one angle, enter the given side lengths and the known angle in the input fields. To find angles with three available side lengths, input them in the corresponding fields.

  • Calculation

    After entering all the given values, click the "Calculate" button.

  • Result

    The calculator will instantly display the missing side lengths or angles using the law of cosines.

What Is the Law of Cosines?

The Law of Cosines, also known as the Cosine Rule or Cosine Formula, is an important geometry formula that relates the sides and angle of any triangle, be it acute, obtuse, or right-angled. It extends the Pythagorean theorem, a particular case for right triangles.

Formulae

For any triangle with sides $$$a$$$, $$$b$$$, and $$$c$$$ and angles $$$A$$$, $$$B$$$, and $$$C$$$ opposite these sides, the Law of Cosines is given by the following formulae:

$$c^2=a^2+b^2-2ab\cos\left(C\right)$$$$b^2=a^2+c^2-2ac\cos\left(B\right)$$$$a^2=b^2+c^2-2bc\cos\left(A\right)$$

Understanding the Formulae

We will consider only the first equation. All others are similar.

In a right triangle, when $$$C=90^0$$$, $$$\cos\left(C\right)=0$$$, and the formula transforms into the Pythagorean theorem:

$$c^2=a^2+b^2$$

Example

Suppose you have a triangle with the following measurements: side $$$a=4$$$ units, side $$$b=6$$$ units, and $$$C=120^0$$$.

Using the Law of Cosines, let's find the length of the side $$$c$$$:

$$c^2=a^2+b^2-2ab\cos\left(C\right)$$$$c^2=4^2+6^2-2\cdot4\cdot6\cdot\cos\left(120^0\right)$$

Since $$$\cos\left(120^0\right)=-\frac{1}{2}$$$,

$$c^2=16+36+24=76$$

Thus, $$$c=\sqrt{76}=2\sqrt{19}$$$ units.

Law of Cosines Proofs

The Law of Cosines is a fundamental equation in geometry that relates the lengths of the sides of a triangle with the cosine of one of its angles. There are various ways to prove the Law of Cosines, but one of the most straightforward methods is through vector geometry. Another approach is by using the Pythagorean theorem for an oblique triangle. Below are two proofs of the Law of Cosines:

  1. Proof Using Vector Geometry

    Let's consider a triangle $$$ABC$$$.

    • Treat the sides $$$a$$$, $$$b$$$, and $$$c$$$ as vectors $$$\mathbf{\vec{CB}}$$$, $$$\mathbf{\vec{CA}}$$$, and $$$\mathbf{\vec{AB}}$$$, respectively.
    • The square of the length of the side $$$c$$$ (opposite the angle $$$A$$$) is $$$\mathbf{\left\lvert\vec{AB}\right\rvert}^2=\mathbf{\vec{AB}}\cdot\mathbf{\vec{AB}}$$$.
    • Use the property of dot product: $$$\mathbf{\vec{CB}}\cdot\mathbf{\vec{CA}}=\mathbf{\left\lvert\vec{CB}\right\rvert}\mathbf{\left\lvert\vec{CA}\right\rvert}\cos\left(C\right).$$$
    • Use the formula for the difference of vectors: $$$\mathbf{\vec{AB}}=\mathbf{\vec{CB}}-\mathbf{\vec{CA}}$$$.
    • Finally, we have $$$\mathbf{\left\lvert\vec{AB}\right\rvert}^2=\mathbf{\vec{AB}}\cdot\mathbf{\vec{AB}}=\left(\mathbf{\vec{CB}}-\mathbf{\vec{CA}}\right)\cdot\left(\mathbf{\vec{CB}}-\mathbf{\vec{CA}}\right)=\mathbf{\vec{CB}}\cdot\mathbf{\vec{CB}}-\mathbf{\vec{CB}}\cdot\mathbf{\vec{CA}}-\mathbf{\vec{CA}}\cdot\mathbf{\vec{CB}}+\mathbf{\vec{CA}}\cdot\mathbf{\vec{CA}}=\mathbf{\left\lvert\vec{CB}\right\rvert}^2-2\mathbf{\vec{CB}}\cdot\mathbf{\vec{CA}}+\mathbf{\left\lvert\vec{CA}\right\rvert}^2=\mathbf{\left\lvert\vec{CB}\right\rvert}^2-2\mathbf{\left\lvert\vec{CB}\right\rvert}\mathbf{\left\lvert\vec{CA}\right\rvert}\cos\left(C\right)+\mathbf{\left\lvert\vec{CA}\right\rvert}^2$$$.

    This proves the Law of Cosines: $$$c^2=a^2+b^2-2ab\cos\left(C\right)$$$.

  2. Proof Using the Pythagorean Theorem

    • Drop a perpendicular from the vertex $$$B$$$ to the side $$$b$$$, dividing $$$b$$$ into two segments. Let $$$D$$$ be the point where the perpendicular meets $$$b$$$. Suppose that the length of the perpendicular is $$$h$$$. Also, let $$$\left\lvert DC\right\rvert=x$$$, then $$$\left\lvert AD\right\rvert=b-x$$$.
    • Now, we have two right triangles: $$$ABD$$$ and $$$CBD$$$.
    • Applying the Pythagorean theorem to the triangle $$$CBD$$$ gives the following equation:

      $$h^2=a^2-x^2$$
    • Similarly, from the triangle $$$ABD$$$ we have

      $$h^2=c^2-(b-x)^2$$
    • Equating the two values of $$$h^2$$$ gives the following:

      $$a^2-x^2=c^2-(b-x)^2$$$$a^2-x^2=c^2-b^2+2bx-x^2$$$$c^2=a^2+b^2-2bx$$
    • From the triangle $$$CBD$$$, according to the definition of cosine, $$$\cos\left(C\right)=\frac{x}{a}$$$ or $$$x=a\cos\left(C\right)$$$.
    • Plugging in our value for $$$x$$$ will give that

      $$c^2=a^2+b^2-2ab\cos\left(C\right)$$

    This completes the proof using the Pythagorean theorem.

These proofs, among other things, emphasize the importance of the Law of Cosines and its fundamental role in geometry.

Why Choose Our Law of Cosines Calculator?

  • High Accuracy

    Precision matters in mathematical calculations. Our calculator provides accurate results, taking the guesswork out of solving triangle problems and reducing the chance of errors.

  • Fast Calculations

    Time is invaluable. Our tool provides instant results, making it perfect for assignments or just quick checks.

  • User-Friendly Interface

    Our calculator is designed with users in mind. With its intuitive layout and straightforward instructions, anyone, from students to professionals, can navigate and use the tool with ease.

  • Versatility

    Whether you're dealing with an acute, obtuse, or right triangle, our calculator handles all of them. It can determine side lengths or angles based on the data you provide.

  • Educational Value

    Beyond just providing answers, our calculator helps in understanding the Law of Cosines better. The breakdown of the calculation process makes it an excellent tool for learners.

FAQ

Is the law of cosines valid only for right triangles?

No, the law of cosines is valid for all types of triangles, whether they are acute, obtuse, or right-angled. In fact, when applied to a right triangle, the law of cosines simplifies to the Pythagorean theorem.

How can we prove the Law of Cosines?

There are multiple ways to prove the Law of Cosines, ranging from using vector geometry to applying the Pythagorean theorem to oblique triangles. Each method provides a unique perspective and proves the validity of the formula.

When can you use the Law of Cosines?

The Law of Cosines can be used in various scenarios, especially when you're given:

  • Two side lengths and the angle between them (SAS).
  • All three side lengths (SSS) to determine the angles of the triangle.

It's particularly useful for solving triangles where the Law of Sines cannot be applied.

What is the Law of Cosines?

The Law of Cosines is a fundamental formula in geometry that relates the lengths of the sides of a triangle to the cosine of one of its angles.