Law of Cosines: Solve Any Triangle (Not Just Right Triangles)
The Law of Cosines, c² = a² + b² - 2ab·cos(C), solves non-right triangles from SAS or SSS. Worked examples for sides and angles, plus navigation problems.
Solve any triangle with three known values - supports SSS, SAS, ASA, and AAS methods. Calculate all missing sides, angles, area, and perimeter instantly using Law of Sines and Law of Cosines.
When you know all three side lengths (a, b, c)
When you know two sides and the angle between them
When you know two angles and the side between them
When you know two angles and a side not between them
Select a method and enter values to calculate
Sides
Side a
-
Side b
-
Side c
-
Angles
Angle A
-
Angle B
-
Angle C
-
Additional
Area
-
Perimeter
-
A triangle solver calculates all the unknown sides and angles of a triangle from three known values, at least one of which must be a side. Unlike calculators that only work with right triangles, it handles acute, obtuse, and right triangles alike.
Our triangle solver uses two fundamental trigonometric principles: the Law of Sines and the Law of Cosines. These laws allow us to solve triangles in various configurations, commonly abbreviated as SSS (Side-Side-Side), SAS (Side-Angle-Side), ASA (Angle-Side-Angle), and AAS (Angle-Angle-Side). Each case uses a different order of steps, and each ends with every side length, every angle, the area, and the perimeter. For more worked problems, see solving oblique triangles at Mathematics LibreTexts.
SSS (Side-Side-Side): When all three side lengths are known, we use the Law of Cosines to calculate each angle. Three valid sides fix the triangle's shape, so there is exactly one answer. The Law of Cosines formula c² = a² + b² - 2ab·cos(C) can be rearranged to find any angle when all sides are known.
SAS (Side-Angle-Side): When two sides and the angle between them are known, we first use the Law of Cosines to find the third side, then apply the Law of Sines to determine the remaining angles. Two sides and the included angle always give exactly one triangle.
ASA (Angle-Side-Angle): With two angles and the included side known, we can first calculate the third angle (since all triangle angles sum to 180°), then use the Law of Sines to find the remaining sides. This is the usual surveying case: two angles sighted from the ends of a measured baseline.
AAS (Angle-Angle-Side): Similar to ASA but with a non-included side, we calculate the third angle first, then apply the Law of Sines to determine the unknown sides. AAS also gives exactly one triangle. Lumen Learning explains when to use Law of Sines vs Law of Cosines.
The solver uses these formulas:
Law of Cosines:
c² = a² + b² - 2ab · cos(C)
b² = a² + c² - 2ac · cos(B)
a² = b² + c² - 2bc · cos(A)
Law of Sines:
a/sin(A) = b/sin(B) = c/sin(C)
Area Formula (Heron's Formula):
Area = √[s(s-a)(s-b)(s-c)]
where s = (a+b+c)/2 is the semi-perimeter
In surveying and land measurement, triangle solving gives distances that cannot be measured directly. By measuring angles and one baseline distance, surveyors can calculate the lengths of property boundaries, heights of structures, and distances across obstacles like rivers or valleys.
Architecture and construction use triangle calculations for roof design, bracing, and foundation layouts. A triangle cannot change shape once its three sides are fixed, which is why trusses and braces are triangles. Solving the triangle gives roof angles, the lengths of support members, and the cut angles where framing pieces meet.
In navigation and GPS technology, positions come from triangles too. GPS uses trilateration, which works from measured distances to satellites; traditional navigation and surveying use triangulation, which works from angles measured to known points. A related method applies in astronomy, where astronomers use parallax measurements and triangle solving to determine distances to stars and other celestial objects.
In engineering, mechanical engineers solve triangles for forces and angles in linkages and machine parts, and electrical engineers draw impedance and power in AC circuits as right triangles. Computer graphics and game engines also solve triangles to place and render 3D objects.
Here is a complete example of solving a triangle where we know two sides and the angle between them (SAS case). Suppose we have a triangle with side a = 7 units, side b = 10 units, and angle C = 35° between them. Our goal is to find side c and angles A and B.
Step 1: Use the Law of Cosines to find side c:
c² = a² + b² - 2ab·cos(C)
c² = 7² + 10² - 2(7)(10)·cos(35°)
c² = 49 + 100 - 140(0.8192)
c² = 149 - 114.68 = 34.32
c ≈ 5.86 units
Step 2: Use the Law of Sines to find angle A. A is opposite the shorter known side, so it must be acute and the inverse sine is safe; never use the inverse sine for an angle that could be obtuse:
a/sin(A) = c/sin(C)
sin(A) = a·sin(C)/c
sin(A) = 7·sin(35°)/5.86
sin(A) = 7(0.5736)/5.86 ≈ 0.6854
A ≈ 43.26°
Step 3: Calculate angle B using the angle sum property:
A + B + C = 180°
B = 180° - 43.26° - 35°
B ≈ 101.74°
The complete solution gives us all six measurements: sides a = 7, b = 10, c = 5.86, and angles A = 43.26°, B = 101.74°, C = 35°. We can verify our answer by checking that the angles sum to 180° and applying the triangle inequality theorem (the sum of any two sides must be greater than the third side).
The SSA (Side-Side-Angle) case, where two sides and a non-included angle are known, is called "ambiguous" because it can sometimes produce zero, one, or even two valid triangles. When using the Law of Sines with SSA, you might find that sin(θ) equals a value that corresponds to two different angles (since sin(θ) = sin(180° - θ), an acute angle and its obtuse supplement have the same sine).
This solver does not take SSA input. The Law of Sines calculator does, and it reports both triangles when two exist. To work it by hand, use the Law of Sines to find the angle opposite the second known side (if its sine comes out above 1, no triangle exists), check both that angle and its supplement (each is valid only if the angles still sum to less than 180°), then enter each valid triangle here as an AAS problem.
You need at least three pieces of information, and at least one must be a side length. You cannot solve a triangle with only angles, as triangles with the same angles can have different sizes (they're similar but not congruent). Valid combinations include SSS, SAS, ASA, and AAS.
The Law of Sines relates sides to their opposite angles (a/sin(A) = b/sin(B) = c/sin(C)) and is best for ASA and AAS cases. The Law of Cosines relates all three sides to one angle (c² = a² + b² - 2ab·cos(C)) and is ideal for SSS and SAS cases. Both are essential tools, each suited for different scenarios.
Yes. This triangle solver works with all triangle types, including right triangles. While right triangles can also be solved using simpler Pythagorean theorem methods, this calculator will correctly handle them using the same trigonometric laws. For specialized right triangle calculations, you might prefer our dedicated right triangle calculator.
The calculator validates that the given values can actually form a valid triangle. Common reasons for errors include: sides that don't satisfy the triangle inequality (sum of two sides must exceed the third), angles that don't sum to 180°, or contradictory information (like specifying sides and angles that are geometrically impossible together). This validation ensures you only get mathematically correct results.
For sides, use any consistent unit of length (meters, feet, centimeters, etc.) - just make sure all three sides use the same unit. For angles, always enter values in degrees, not radians. The calculator will maintain the same units for output sides, area (in square units), and perimeter that you used for input.
The calculator uses double-precision floating-point arithmetic and displays results to 2 decimal places. For most practical applications, this provides more than sufficient accuracy. However, be aware that extremely small or large values, or triangles with very acute angles, may accumulate minor rounding errors through the multi-step calculations.
The ambiguous case occurs with SSA (Side-Side-Angle) input when two different valid triangles might exist that satisfy the given conditions. This happens because the sine function has two possible angles for most values (θ and 180°-θ). Our calculator detects this situation and provides one valid solution, but be aware that in some cases, an alternative triangle configuration might also be geometrically valid.
Yes. This triangle solver handles all triangle types: acute (all angles less than 90°), right (one 90° angle), and obtuse (one angle greater than 90°). The Law of Sines and Law of Cosines hold for every triangle.
Deepen your understanding of triangles and trigonometry with our guides and tutorials:
The Law of Cosines, c² = a² + b² - 2ab·cos(C), solves non-right triangles from SAS or SSS. Worked examples for sides and angles, plus navigation problems.
How to find missing angles in a right triangle: subtract the known angle from 90°, or apply inverse sin, cos or tan to two sides. Legs 6 and 8 give 36.87°.
The Law of Sines, a/sin A = b/sin B = c/sin C, solves non-right triangles in AAS, ASA and SSA cases. When to use it, worked examples, the ambiguous case.
How to solve a right triangle from any two known values (at least one a side) with the Pythagorean theorem and sin, cos, tan, worked step by step.
Right triangle mistakes students make: wrong hypotenuse, missing square root, mislabeled angles, mixed units, early rounding. Each with an example and fix.
Surveying with trigonometry: measure heights and distances you can't reach using right triangles, angle of elevation, tangent and the two-position method.
Formulas and results last reviewed . How we check accuracy · Corrections log · Report an error