Quick answer
The law of cosines gives a side from two sides and the included angle: a² = b² + c² − 2bc·cos A. With b = 3, c = 4 and A = 90°, a = 5, the Pythagorean case.
Enter two sides and the angle between them. The calculator returns the third side.
Related tools: Sine Rule Calculator: Apply the sine rule to find a missing side or angle of a triangle from an angle and its opposite side. Trigonometry Calculator: All six trigonometric functions of an angle. Triangle Calculator: Area, perimeter, angles and type of a triangle from its three sides.
How to use the Law of Cosines Calculator
- Enter side b (above 0).
- Enter side c (above 0).
- Enter included angle A (°) (between 0 and 179.999999).
- Press Calculate to see the result, and use Reset to start again.
| Input | What to enter | Allowed values |
|---|---|---|
| Side b | A number | > 0 |
| Side c | A number | > 0 |
| Included angle A | A number, in ° | > 0, ≤ 179.999999 |
Formula and method
Formula
a² = b² + c² − 2bc·cos A
IEEE-754 double precision; shown to at most 6 decimal places.
Law of cosines.
Worked examples
These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.
Example 1
Inputs: Side b = 3; Side c = 4; Included angle A = 90.
| Result | Value |
|---|---|
| Side a | 5 |
Example 2
Inputs: Side b = 1; Side c = 1; Included angle A = 60.
| Result | Value |
|---|---|
| Side a | 1 |
The first line is the headline result (side a). IEEE-754 double precision; shown to at most 6 decimal places.
Generalising Pythagoras
When A = 90°, cos A = 0 and the formula reduces to a² = b² + c². For A = 60° with b = 3 and c = 4: a² = 9 + 16 − 12 = 13, so a = 3.606.
Where this estimate stops applying
The included angle must be between 0° and 180°. Use the formula to find angles too: cos A = (b² + c² − a²) ÷ 2bc. For two sides and a non-included angle use the law of sines, which can have two solutions.
How the result changes with side b
Holding every other input at the first worked example, this table changes only side b. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.
| Side b | Side a |
|---|---|
| 1.5 | 4.272002 |
| 3 | 5 |
| 6 | 7.211103 |
| 12 | 12.649111 |
What happens with invalid input
These messages are produced by the calculator itself, so you know what to fix.
- Included angle A: entering "0" shows "Included angle A must be greater than 0." beside that field and no result.
Choosing between the Law of Cosines Calculator and similar calculators
Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.
| Calculator | You enter | It returns |
|---|---|---|
| [Sine Rule Calculator](/math/sine-rule-calculator/) | angle A, side a and angle B | Side b |
| [Trigonometry Calculator](/math/trigonometry-calculator/) | angle and unit | sin |
| [Triangle Calculator](/math/triangle-calculator/) | side a, side b and side c | Area |
| [Right Triangle Calculator](/math/right-triangle-calculator/) | leg a and leg b | Hypotenuse c |
| [Cosine Rule Calculator](/math/cosine-rule-calculator/) | side b, side c and included angle A | Side a |
Background: trigonometry
In a right triangle, sin θ is the opposite side over the hypotenuse, cos θ the adjacent side over the hypotenuse and tan θ the opposite over the adjacent. Their reciprocals are cosecant, secant and cotangent. At 30° the values are sin = 0.5, cos = 0.866025 and tan = 0.577350.
Check the angle unit before you calculate: degrees convert to radians by multiplying by π/180, so 30° is about 0.5236 rad. Some values are undefined, for example tan 90°, because the cosine is zero there and the ratio would divide by zero.
Assumptions and limitations
- Angle between 0° and 180°
If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for included angle A to confirm this.
Frequently asked questions
When do I use it?
Use it when you know two sides and the included angle (SAS) or all three sides (SSS).
What if A is obtuse?
cos A is negative, so the side is longer.
How is it related to Pythagoras?
It's the general form.
What does the Law of Cosines Calculator calculate?
Third side of a triangle from two sides and the included angle (law of cosines). It returns Side a.
What formula does the Law of Cosines Calculator use?
a² = b² + c² − 2bc·cos A. Law of cosines.
What do I need to enter in the law of Cosines Calculator?
You enter Side b, Side c and Included angle A (°).
How is the result rounded or limited?
IEEE-754 double precision; shown to at most 6 decimal places. Angle between 0° and 180°.
What is an example of a law of Cosines result?
With side b 3, side c 4 and included angle A 90, the side a is 5.
Where does the method come from?
The method follows: OpenStax, Algebra and Trigonometry 2e (Rice University): exponents, radicals, logarithms and inverse trigonometric functions; OpenStax, Precalculus 2e (Rice University): vectors, polar coordinates and trigonometry.
Related calculators
- Sine Rule Calculator — Apply the sine rule to find a missing side or angle of a triangle from an angle and its opposite side.
- Trigonometry Calculator — All six trigonometric functions of an angle.
- Triangle Calculator — Area, perimeter, angles and type of a triangle from its three sides.
- Right Triangle Calculator — Solve a right triangle from its two legs: hypotenuse, angles, area and perimeter.
- Cosine Rule Calculator — Apply the cosine rule to find a missing side or angle of a triangle from the sides and the included angle.
- Law of Sines Calculator — Solve a triangle from two angles and one side (law of sines).
- SOHCAHTOA Calculator — Find the other two sides of a right triangle from one side and an acute angle.
- Reference Angle Calculator — Acute angle between the terminal side and the x-axis.
Sources
- OpenStax, Algebra and Trigonometry 2e (Rice University): exponents, radicals, logarithms and inverse trigonometric functions
- OpenStax, Precalculus 2e (Rice University): vectors, polar coordinates and trigonometry
Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.