📐 Law of Cosines Calculator — Solve a Triangle (SAS & SSS)

Solve a triangle from two sides and the included angle, or from all three known sides.

📐 Enter Your Known Values
Result
📐

Choose a mode, enter your known sides and angle, and click Calculate

Guide

About the Law of Cosines Calculator

Last updated: July 2026 · Reviewed by the NeftCal editorial team

This law of cosines calculator solves a triangle when you know two sides and the angle between them (the SAS case), or all three sides with no angle at all (the SSS case). The Law of Cosines — c² = a² + b² − 2ab·cos(C) — is the direct generalization of the Pythagorean theorem to any triangle, right or not. Unlike the Law of Sines, it never runs into an ambiguous case: SAS and SSS inputs each resolve to exactly one triangle, making it the reliable go-to formula whenever no matching angle-side pair is available.

What This Calculator Measures

In SAS mode, it uses the two known sides and the included angle to solve directly for the third side, then finds one remaining angle and derives the last one by subtracting from 180°. In SSS mode, it rearranges the Law of Cosines to solve for each angle in turn from the three known side lengths, after first checking the triangle inequality to confirm the three sides can actually form a triangle.

Who Should Use This Calculator

Trigonometry and precalculus students working through SAS and SSS problem sets, engineers and architects who have measured all three sides of a structural triangle and need the angles, surveyors who know two distances and the angle between two sighting lines, and machinists or fabricators checking triangular bracket or gusset dimensions against a design.

Why the Law of Cosines Matters

Many real-world triangles are only measurable by their sides — think of a triangular plot of land, a truss, or a fabricated bracket where you can measure every edge but not directly sight an angle. The Law of Cosines is what lets you recover every angle purely from side lengths, and it's also the only reliable route to a third side when two sides and the angle between them are the only things you know.

Real-World Applications

Engineers use it to verify truss and frame geometry from measured side lengths. Surveyors compute an unknown distance from two known distances and the angle between two sighting lines. Machinists confirm bracket and gusset angles purely from side measurements. Navigators use it to solve course and bearing triangles when two legs and their included turn angle are known. Students and teachers use it to check SAS and SSS homework quickly and precisely.

Tips for Accurate Results

  • In SAS mode, make sure the angle you enter is genuinely the included angle — the one directly between sides a and b — not one of the other two angles.
  • In SSS mode, if the calculator flags your three sides as invalid, check the triangle inequality: the two shorter sides must sum to more than the longest side.
  • Because acos and asin can be numerically sensitive near 0° and 180°, treat results extremely close to those values as approximate rather than exact.
Formula

The Law of Cosines Formula, Explained

How two sides and an included angle, or three sides alone, solve the rest of the triangle

The Law of Cosines
c² = a² + b² − 2ab·cos(C)

SAS Case (Given a, b, Included Angle C)
c = √(a² + b² − 2ab·cos(C))
A = asin(a·sin(C)/c)  |  B = 180° − C − A

SSS Case (Given a, b, c)
Triangle inequality check: a + b > c, a + c > b, b + c > a (all must hold)
A = acos((b² + c² − a²)/(2bc))  |  B = acos((a² + c² − b²)/(2ac))  |  C = 180° − A − B

Where:
A, B, C = the three interior angles, opposite sides a, b, c respectively.
a, b, c = the three side lengths of the triangle.
cos(C) = cosine of the included angle — when C = 90°, cos(C) = 0 and the formula reduces to the Pythagorean theorem.
📐

Generalized Pythagorean Theorem

Setting C = 90° makes cos(C) = 0, collapsing c² = a² + b² − 2ab·cos(C) into the familiar c² = a² + b².

No Ambiguous Case

Unlike the Law of Sines' SSA case, both SAS and SSS always resolve to exactly one valid triangle — there's nothing to disambiguate.

📏

Triangle Inequality Gatekeeper

In SSS mode, three side lengths only describe a real triangle if every pair of sides sums to more than the third.

⚙️ Why This Formula Works

The Law of Cosines comes directly from the Pythagorean theorem applied to a right triangle formed by dropping a perpendicular from one vertex, combined with the definition of cosine for the adjacent leg. Working through that construction algebraically produces c² = a² + b² − 2ab·cos(C) for any triangle, not just right ones.

🎯 When to Use Each Mode

  • SAS: you know two sides and the angle directly between them
  • SSS: you know all three sides and no angle
  • Not AAS or ASA: those cases already have a matching angle-side pair — use the Law of Sines instead, it's simpler

📋 Assumptions

  • All side lengths are positive real numbers
  • The included angle in SAS mode is given in degrees and is genuinely between the two entered sides
  • The triangle lies in flat (Euclidean) geometry, where angles sum to 180°

⚠️ Limitations of the Formula

  • SSS inputs that fail the triangle inequality (one side too long relative to the other two) cannot form a triangle and are rejected
  • Requires the correct included angle in SAS mode — using a non-included angle gives an incorrect result with no warning
  • Very thin (near-degenerate) triangles can amplify floating-point rounding error in the angle results
Walkthrough

Step-by-Step: How to Use the Law of Cosines Calculator

From choosing a case to reading the completed triangle

Choose your case

Select the SAS tab if you know two sides and the angle between them, or the SSS tab if you know all three sides.

Enter your known values

Type the known side lengths, and the included angle in degrees if you're using SAS mode.

Click "Calculate"

SSS inputs are first checked against the triangle inequality; then the Law of Cosines solves for every missing side and angle.

Read the results

Review the completed triangle's sides and angles shown together in the results panel.

Example

Worked Examples: SAS and SSS

Solving both cases with verified reference values

SAS Scenario

A surveyor measures two sides of a triangular plot, a = 4 and b = 6, with an included angle of C = 60° between them. What is the length of the third side and the remaining two angles?

Side a4
Side b6
Included Angle C60°
Step 1 — Solve for side c: c = √(4² + 6² − 2×4×6×cos(60°)) = √(16 + 36 − 48×0.5) = √28 ≈ 5.2915.
Step 2 — Solve for Angle A: A = asin(a·sin(C)/c) = asin(4×sin(60°)/5.2915) = asin(0.654654) ≈ 40.8934°.
Step 3 — Solve for Angle B: B = 180 − 60 − 40.8934 ≈ 79.1066°.
Side c
5.2915
Angle A
40.8934°
Angle B
79.1066°

SSS Scenario

A triangular brace has three measured sides: a = 5, b = 6, c = 7. What are its three interior angles?

Side a5
Side b6
Side c7
Step 1 — Check the triangle inequality: 5+6=11 > 7, 5+7=12 > 6, 6+7=13 > 5 — valid triangle.
Step 2 — Solve for Angle A: A = acos((6²+7²−5²)/(2×6×7)) = acos(60/84) ≈ 44.4153°.
Step 3 — Solve for Angle B: B = acos((5²+7²−6²)/(2×5×7)) = acos(38/70) ≈ 57.1217°.
Step 4 — Solve for Angle C: C = 180 − 44.4153 − 57.1217 ≈ 78.4630°.
Angle A
44.4153°
Angle B
57.1217°
Angle C
78.4630°

Explanation: Neither example has an ambiguous case — SAS and SSS each produce exactly one valid triangle. Notice how SSS requires all three angles to be found via the Law of Cosines' rearranged form, since no angle is known at the start.

Interpretation

Understanding Your Law of Cosines Results

What each output means for SAS and SSS triangles

OutputWhat It RepresentsTypical Range / Notes
Side c (SAS)The third side, opposite the included angleAlways positive; grows with a, b, and C
Angle A, Angle B (SAS)The two remaining interior anglesEach strictly between 0° and 180°; sum with C equals 180°
Angle A, B, C (SSS)All three interior angles, solved from the three sidesEach strictly between 0° and 180°; sum to exactly 180°
Triangle inequality check (SSS)Confirms the three sides can physically form a triangleFails if any one side ≥ sum of the other two

Reading the results together: both SAS and SSS always produce exactly one valid triangle (when the inputs are valid) — there is no ambiguous case here, unlike the Law of Sines' SSA scenario.

Typical ranges: all sides must be positive, all angles must fall strictly between 0° and 180°, and the three angles of the resulting triangle must sum to exactly 180°.

Manual verification: once you have all three sides and angles, plug them back into c² = a² + b² − 2ab·cos(C) (using whichever side/angle set you didn't start from) and confirm it holds — a reliable way to sanity-check the calculator's output by hand.

Use Cases

Practical Use Cases for the Law of Cosines Calculator

Where solving a triangle from sides and an included angle, or from three sides alone, is genuinely useful

🎓

Trigonometry & precalculus homework

Check SAS and SSS triangle problems step by step.

🗺️

Land surveying

Find a third boundary length from two measured distances and the angle between them.

🏗️

Structural engineering

Verify truss and frame angles purely from measured side lengths (SSS).

🔧

Machining & fabrication

Confirm triangular bracket or gusset dimensions against a design spec.

🧭

Navigation & course plotting

Solve course-and-bearing triangles from two legs and an included turn angle.

🏛️

Architecture & drafting

Check triangular roof, truss, or facade geometry against design angles.

📡

Antenna & signal triangulation

Compute distances between transmitters and receivers from known geometry.

🎯

Ballistics & artillery geometry

Solve triangles where two ranges and an included angle are known.

🖥️

Computer graphics & game dev

Recover triangle angles from vertex distances for mesh and collision math.

📊

Physics vector problems

Solve force, velocity, or displacement triangles using the Law of Cosines directly.

🏞️

Land & property boundary checks

Confirm triangular plot angles and side lengths from a deed or survey.

🛰️

Robotics & sensor geometry

Solve arm or sensor triangles from measured link lengths and joint angles.

🧪

Testing triangle validity

Quickly confirm whether three measured side lengths can actually form a triangle.

Pros & Cons

Advantages and Limitations

What this Law of Cosines calculator does well, and where it doesn't apply

✅ Advantages

  • Free, instant, and requires no signup or account
  • Runs entirely in your browser — no data ever leaves your device
  • Handles both the SAS and SSS cases in one tool
  • Never produces an ambiguous result — SAS and SSS each give exactly one triangle
  • Automatically checks the triangle inequality in SSS mode
  • Removes manual cosine-rule algebra and rounding errors
  • Useful across surveying, engineering, fabrication, and classroom contexts alike
  • Accepts decimal inputs for precise, real-world measurements
  • Clearly separates the SAS and SSS workflows with dedicated tabs
  • Fast-loading and fully mobile-friendly
  • Consistent, error-free results every time
  • Free to use as many times as needed, with no calculation limit

⚠️ Limitations

  • Cannot solve AAS or ASA triangles directly — use the Law of Sines Calculator for those, it's simpler
  • SSS inputs that fail the triangle inequality are rejected with no partial result
  • Assumes flat (Euclidean) geometry — not valid for spherical or curved-surface triangles
  • Requires the SAS angle to be genuinely the included angle, with no way to detect a mismatched entry
  • Displays decimal results rounded to four places, which can hide tiny precision loss
  • Does not draw or visually plot the resulting triangle
  • Very thin, near-degenerate triangles can show slightly amplified rounding in the angle results
Reference

SAS vs SSS: Comparing the Two Law of Cosines Cases

How the known values differ and what each mode solves for first

CaseKnown ValuesSolves FirstAmbiguous?
SASTwo sides + the included angleThe third side (c)No — always one solution
SSSAll three sidesAny one angle, then the restNo — always one solution

Common Mistakes and Expert Tips

❌ Common Mistakes

  • Entering a non-included angle in SAS mode instead of the one directly between the two known sides
  • Forgetting to check the triangle inequality before assuming three sides form a valid SSS triangle
  • Applying the Law of Cosines to an AAS or ASA triangle where the simpler Law of Sines already applies
  • Mixing degrees and radians when entering the included angle
  • Rounding intermediate results too early, compounding error before the final angle is found
  • Assuming the Law of Cosines has an ambiguous case like SSA does — it does not

💡 Expert Tips & Best Practices

  • If you already have two angles and a side, use the Law of Sines Calculator instead — it's simpler for AAS/ASA
  • Double-check the triangle inequality manually if your SSS input gets rejected: the two shorter sides must sum to more than the longest
  • Use the general Triangle Solver if you're unsure which case (SSS, SAS, ASA/AAS) applies to your triangle
  • For right triangles, remember the Law of Cosines simplifies exactly to the Pythagorean theorem when C = 90°
  • Keep at least four decimal places when verifying results manually, since acos and asin can be sensitive to rounding
📝

Summary: This Law of Cosines calculator solves SAS and SSS triangles instantly with no ambiguous case to worry about. Pair it with the Law of Sines Calculator for AAS/ASA/SSA triangles, or the Triangle Solver for a general-purpose tool covering every case.

FAQ

Frequently Asked Questions

Common questions about the Law of Cosines, SAS, and SSS

What is the Law of Cosines formula?
The Law of Cosines states c² = a² + b² − 2ab·cos(C), where C is the angle opposite side c. It generalizes the Pythagorean theorem to any triangle, not just right triangles, and reduces to it exactly when C = 90° (since cos(90°) = 0).
When should I use the Law of Cosines instead of the Law of Sines?
Use the Law of Cosines when you know two sides and the included angle (SAS) or all three sides (SSS) — neither case gives you a matching angle-side pair to start the Law of Sines ratio. Once the Law of Cosines finds one more piece, the Law of Sines can be used for the rest if you prefer.
What is the SAS case in the Law of Cosines?
SAS means Side-Angle-Side: you know two sides and the angle directly between (included by) them. The Law of Cosines finds the third side first, then the remaining two angles can be found with either the Law of Cosines again or the Law of Sines.
What is the SSS case in the Law of Cosines?
SSS means Side-Side-Side: you know all three side lengths but no angle. The Law of Cosines is rearranged to solve directly for each angle, one at a time, using only the three known sides.
Why does my SSS input get rejected as invalid?
Three side lengths only form a real triangle if they satisfy the triangle inequality: each side must be shorter than the sum of the other two. If a + b ≤ c (or any similar combination), the sides can't close into a triangle, and the calculator rejects the input.
How does the Law of Cosines relate to the Pythagorean theorem?
The Pythagorean theorem is a special case of the Law of Cosines. When the included angle C is exactly 90°, cos(C) = 0, so c² = a² + b² − 2ab·cos(90°) simplifies to c² = a² + b², which is the familiar Pythagorean theorem for right triangles.
Can the Law of Cosines solve an AAS or ASA triangle?
Not directly and not efficiently — AAS and ASA triangles are solved far more simply with the Law of Sines, since you already have a matching angle-side pair. Use our Law of Sines Calculator for those cases instead.
What is the triangle inequality theorem?
The triangle inequality theorem states that the sum of any two sides of a triangle must be strictly greater than the third side. It's the test this calculator applies automatically in SSS mode before attempting to solve for any angles.
Why is the included angle important in the SAS case?
The Law of Cosines formula specifically requires the angle between the two known sides (the "included" angle), because that's the angle whose cosine directly relates the third side's length to the other two. Using a non-included angle in the formula would give an incorrect result.
Can all three angles of an SSS triangle be found with the Law of Cosines?
Yes. You can solve for any two angles directly with the Law of Cosines formula rearranged for each one, then find the third angle by subtracting the first two from 180°, since a triangle's interior angles always sum to 180°.
Does the order I enter the two sides matter in SAS mode?
No — side a and side b are interchangeable in the Law of Cosines formula for finding side c, since the formula is symmetric in a and b. What matters is that the angle you enter is the one actually between those two sides.
Is the Law of Cosines valid for obtuse triangles?
Yes, the Law of Cosines works correctly for acute, right, and obtuse triangles alike. Unlike the Law of Sines' SSA case, the Law of Cosines produces exactly one unambiguous solution for both the SAS and SSS cases, with no ambiguity to check for.
How accurate are the results from this calculator?
Results are computed with full floating-point precision using standard trigonometric functions and displayed rounded to four decimal places. For most practical uses — construction, engineering, or homework — this level of precision is more than sufficient.
Learn More

Authoritative Resources on the Law of Cosines

Trusted educational references to go deeper on solving triangles

Related Calculators

Explore other trigonometry and geometry tools