Law of Cosines Calculator
Solve any triangle when you know two sides and the included angle (SAS) or all three sides (SSS). Get every angle, area, perimeter, circumradius, and altitude with step-by-step work.
Given: a = 7, b = 10, C = 60°
c² = a² + b² - 2ab·cos(C)
c = √(7² + 10² - 2·7·10·cos(60°))
c = 8.8882
A = arccos((b² + c² - a²)/(2bc)) = 43.0039°
B = 180° - A - C = 76.9961°
Area = √(s(s-a)(s-b)(s-c)) = 30.3109
Perimeter = a + b + c = 25.8882
Triangle Solution
Triangle AcuteAngles
A
43\u00b0
B
77\u00b0
C
60\u00b0
Sides
a
7
b
10
c
8.8882
Properties
Heights
Law of Cosines Formula
c\u00b2 = a\u00b2 + b\u00b2 - 2ab\u00b7cos(C)
Works for any triangle. When C = 90\u00b0, it reduces to the Pythagorean theorem.
How to Use the Law of Cosines Calculator
Pick Your Setup
Choose SAS if you know two sides and the angle between them. Choose SSS if you know all three side lengths. Choose SSA if you have two sides and a non-included angle. Each tab adjusts the input fields to match.
Type Your Measurements
Enter side lengths in any consistent unit and angles in degrees. The calculator checks your numbers on the fly and warns you if the values cannot form a valid triangle, like three sides that violate the triangle inequality.
Read the Full Solution
All three sides, all three angles, area, perimeter, circumradius, inradius, and altitudes appear instantly. Expand the step-by-step panel to see exactly how each value was calculated, formula by formula.
Why Use Our Law of Cosines Calculator
SAS, SSS, and SSA
Three input modes cover every scenario. SAS and SSS always produce one solution; SSA checks for the ambiguous case automatically.
Full Triangle Data
Every measurement you could need: sides, angles, area, perimeter, circumradius, inradius, semi-perimeter, and all three altitudes.
Step-by-Step Work
See each formula applied in order so you can follow the logic or check your own work. Ideal for homework and exam prep.
6 Quick Presets
Load classic triangles like 3-4-5 right, equilateral, and obtuse to see how the calculator handles different shapes.
Instant Results
Solutions update as you type. No submit button, no page reload. Change one number and everything recalculates in real time.
Handles Edge Cases
Invalid inputs, degenerate triangles, and obtuse angles are all caught and explained instead of producing confusing errors.
Complete Guide to the Law of Cosines
What the Law of Cosines Actually Says
Think of the law of cosines as a generalized version of the Pythagorean theorem. In any triangle with sides a, b, and c, where C is the angle sitting between sides a and b, the relationship is c squared equals a squared plus b squared minus 2ab times the cosine of C. When that angle happens to be 90 degrees, cosine of 90 is zero, the subtracted term vanishes, and you are left with the classic a squared plus b squared equals c squared.
The beauty of this formula is that it connects all three sides and one angle in a single equation. Give it any three of those four values and it hands back the fourth. That makes it the go-to tool whenever you know two sides and the included angle, or all three sides and need to find angles.
Finding a Missing Side (SAS)
Suppose you know sides a and b and the angle C between them. Plug directly into c squared equals a squared plus b squared minus 2ab cos(C), then take the square root. For example, if a is 7, b is 10, and C is 60 degrees, you get c squared equals 49 plus 100 minus 140 times 0.5, which is 79, so c is about 8.888. The remaining angles follow from rearranging the same formula or using the law of sines once you have all three sides.
Finding a Missing Angle (SSS)
When you know all three sides, rearrange the formula to isolate the cosine: cos(C) equals (a squared plus b squared minus c squared) divided by 2ab. Compute the fraction, then hit the inverse cosine button on your calculator. For a 3-4-5 triangle, cos(C) equals (9 plus 16 minus 25) divided by 24, which is 0, so C is 90 degrees, confirming it is a right triangle.
You can find each angle the same way by cycling which side you label c. Or find two angles and subtract from 180 to get the third. Either method gives exact results; subtracting from 180 is faster but rounding errors can accumulate if your input values are approximate.
Where People Actually Use This
Land surveyors face the SAS scenario every day. They stand at one point, measure the distance to two other points, and read the angle between their two lines of sight. The law of cosines immediately gives the distance between those two remote points without anyone having to walk there. The same idea powers radar ranging, artillery targeting, and robotic path planning.
In construction, carpenters often know three beam lengths and need the angle at a joint. In physics, adding two force vectors that are not perpendicular creates a triangle whose resultant side length comes straight from the law of cosines. And in computer graphics, it is used to calculate angles between mesh normals, which determines how light bounces off a 3D surface.
Law of Cosines vs Law of Sines: Picking the Right Tool
The law of sines relates a side to the sine of its opposite angle: a over sin A equals b over sin B. It is simpler to compute but it needs at least one side-angle pair to start. The law of cosines does not need an opposite pair, it works with adjacent values. If you are given SAS or SSS, start with cosines. If you are given AAS or ASA, start with sines. For SSA (the ambiguous case), either law works, but cosines avoids the supplementary angle trap that sines can introduce.
A common strategy in more complex problems is to use the law of cosines for the first unknown, then switch to the law of sines for the rest since it involves less arithmetic. Our calculator does exactly this behind the scenes to give you the most efficient step-by-step solution.
Law of Cosines Calculator FAQ
Common questions about the law of cosines, triangle solving, and when to use which formula.
Disclaimer: This Law of Cosines Calculator provides solutions based on standard trigonometric formulas. Results are computed using floating-point arithmetic and may have minor rounding differences compared to exact symbolic solutions. Always verify critical calculations independently.