Law of Cosines Calculator
Solve any triangle with the law of cosines: enter three sides (SSS) to get all three angles, or two sides plus the included angle (SAS) to get the third side. Every result shows the substitution steps and a labeled diagram.
Calculator
Result
Step-by-step substitution
Diagram
Details
Worked examples (click to load)
The law of cosines
For a triangle with sides a, b, c and angles A, B, C opposite them:
c² = a² + b² − 2ab·cos(C)b² = a² + c² − 2ac·cos(B)a² = b² + c² − 2bc·cos(A)Use it when you know SSS (three sides → angles via
cos(A) = (b² + c² − a²) / (2bc)) or
SAS (two sides and the included angle → third side).
When C = 90°, cos(C) = 0 and the formula collapses to the Pythagorean theorem.
If you know angles plus a side instead (ASA, AAS, or SSA), the law of sines is the right tool for that case.
Frequently asked questions
What is the law of cosines?
The law of cosines relates the three sides of a triangle to one of its angles: c squared equals a squared plus b squared minus 2ab times cos(C), where angle C sits opposite side c. It is a generalization of the Pythagorean theorem that works for any triangle, not just right triangles.
When should I use the law of cosines instead of the law of sines?
Use the law of cosines when you know all three sides (SSS) and want the angles, or when you know two sides and the angle between them (SAS) and want the third side. The law of sines is the better choice when you know angles plus one side, such as ASA, AAS, or SSA configurations.
How do I find all three angles from three sides (SSS)?
Apply the rearranged formula three times: cos(A) equals (b squared plus c squared minus a squared) divided by 2bc, then take the inverse cosine. Repeat for B and C. The three angles always add up to exactly 180 degrees, which is a good sanity check.
What are the angles of a 3-4-5 triangle?
The side of length 3 sits opposite angle A of about 36.8699 degrees, the side of length 4 opposite angle B of about 53.1301 degrees, and the side of length 5 opposite angle C of exactly 90 degrees, confirming it is a right triangle. The angles sum to 180 degrees.
Two sides are 5 and 7 with a 60-degree angle between them. What is the third side?
c squared = 25 + 49 - 70 times cos(60°) = 39, so c = √39 ≈ 6.2450 units. The remaining angles are about 43.8979° and 76.1021°.
What happens if my three sides cannot form a triangle?
The calculator rejects the input and explains why: the triangle inequality requires every side to be shorter than the sum of the other two. For example, sides 1, 2, and 10 are impossible because 1 + 2 is not greater than 10.
Free tool by NRTechStudio