Cosine Calculator — Law of Cosines

Law of Cosines Calculator

Advanced Mathematical Solver for Triangles & Geometry

Enter values on the left to begin.

Cosine Calculator (Law of Cosines) – Solve Any Triangle Online

Introduction

Welcome to the ultimate guide on the Cosine Calculator and the Law of Cosines. If you have ever looked at a triangle and wondered how to find a missing side or a hidden angle, you are in the right place.

The Law of Cosines is one of the most powerful tools in mathematics. While the Pythagorean theorem only works for right-angled triangles (triangles with a 90-degree angle), the Law of Cosines works for any triangle in the universe.

Whether you are a school student trying to finish your math homework, an architect designing a roof, a surveyor measuring a piece of land, or a pilot plotting a flight path, understanding this mathematical rule is incredibly important.

Using a Cosine Calculator makes these complex calculations instant. Instead of spending five minutes writing out long equations and double-checking your arithmetic, a calculator does the heavy lifting for you in a fraction of a second. This guide will teach you exactly how the formula works, when to use it, and how to apply it to real-world problems.

What Is the Law of Cosines?

Definition

The Law of Cosines (sometimes called the Cosine Rule) is a geometric formula that relates the lengths of the sides of a triangle to the cosine of one of its angles. It is an extension of the famous Pythagorean theorem, adapted to work on triangles that do not have a 90-degree angle.

Purpose

The main purpose of the Law of Cosines is to “solve” a triangle. Solving a triangle means finding all of its unknown sides and unknown angles. If you know certain pieces of information about a triangle, the Law of Cosines acts as a key to unlock the rest of the missing data.

Triangle Applications

You can apply this law to any type of triangle:

  • Acute Triangles: All angles are less than 90°.
  • Obtuse Triangles: One angle is greater than 90°.
  • Right Triangles: One angle is exactly 90° (the formula naturally simplifies to the Pythagorean theorem here because the cosine of 90° is 0).

Law of Cosines Formula

To use the Law of Cosines, we label the angles of the triangle with uppercase letters (A, B, C) and the sides opposite those angles with lowercase letters (a, b, c).

The Side Formula

If you want to find an unknown side length, use one of these three variations:

c² = a² + b² – 2ab cos(C)

b² = a² + c² – 2ac cos(B)

a² = b² + c² – 2bc cos(A)

The Angle Formula

If you know all three sides and want to find an unknown angle, you rearrange the formula above to solve for the angle:

cos(C) = (a² + b² – c²) / 2ab

cos(B) = (a² + c² – b²) / 2ac

cos(A) = (b² + c² – a²) / 2bc

Variable Meaning

  • a, b, c: The lengths of the sides of the triangle.
  • A, B, C: The angles opposite to sides a, b, and c respectively.
  • cos: The cosine function from trigonometry.

When Should You Use the Law of Cosines?

You cannot use the Law of Cosines blindly. It only works if you have specific starting information. You should use it in two specific scenarios:

1. SAS Triangles (Side-Angle-Side)

You know the length of two sides and the measure of the angle directly between them (the included angle).

  • Goal: You want to find the length of the third, unknown side.

2. SSS Triangles (Side-Side-Side)

You know the exact lengths of all three sides of the triangle, but you do not know any of the angles.

  • Goal: You want to find the measure of one (or all) of the missing angles.

3. Non-Right Triangles

While it works for right triangles, the Law of Cosines is meant for oblique (non-right) triangles. If you have a right triangle, save time and use a² + b² = c² and basic SOH-CAH-TOA trigonometry instead.

Difference Between Law of Cosines and Law of Sines

Students often confuse the Law of Cosines with the Law of Sines. Here is a clear comparison table to help you know exactly which formula to use.

FeatureLaw of CosinesLaw of Sines
Formulac² = a² + b² – 2ab cos(C)a/sin(A) = b/sin(B) = c/sin(C)
When to UseSAS (Side-Angle-Side) or SSS (Side-Side-Side)AAS, ASA, or SSA (Angle and opposite side known)
Primary ApplicationFinding a third side when two sides and the included angle are known, or finding angles when all sides are known.Finding missing sides or angles when you have a “matching pair” of a side and its opposite angle.
AdvantagesNever produces an ambiguous case. It gives one definitive answer for an angle.Generally faster and easier to calculate by hand.
LimitationsThe formula is longer and more prone to arithmetic mistakes if calculated manually.Can result in the “Ambiguous Case” (SSA), meaning there could be two possible triangles, or none at all.

How to Use the Cosine Calculator

Using an online Law of Cosines Calculator is incredibly easy. Just follow these four simple steps:

Step 1: Enter Known Values

Look at your math problem or real-world measurement. Do you have three sides (SSS)? Or do you have two sides and an angle (SAS)? Enter these exact numbers into the input boxes on the calculator.

Step 2: Choose Units

Select the correct units.

  • For sides, this could be meters, feet, inches, or just a generic “unit.”
  • For angles, you must tell the calculator if your angle is in Degrees or Radians. This is the #1 mistake people make!

Step 3: Click Calculate

Press the “Solve” or “Calculate” button. The calculator’s engine will instantly run your numbers through the correct formula.

Step 4: View Results

The calculator will display the final answer. Premium calculators will also show you the step-by-step math used to get the answer, helping you learn the process.

Triangle Diagrams

To understand the formulas, you must visualize the triangle. Here is a simple text-based diagram showing how sides and angles relate to each other.

Plaintext

       C
      / \
     /   \
  b /     \ a
   /       \
  /         \
 A-----------B
       c

Key Rules of the Diagram:

  1. Triangle Angles: The angles are uppercase letters (A, B, C).
  2. Triangle Sides: The sides are lowercase letters (a, b, c).
  3. Opposite Rule: Side a is always directly across from Angle A. Side b is across from Angle B. Side c is across from Angle C.
  4. Included Angle: If you know side a and side b, the angle trapped between them is Angle C.

Worked Examples

Here are 20 practical examples showing exactly how the Law of Cosines is used in math tests and real-world scenarios.

Finding Missing Side (Math Context)

Example 1:

  • Known: a = 5, b = 7, Angle C = 45°.
  • Formula: c² = a² + b² – 2ab cos(C)
  • Calculation: c² = 5² + 7² – 2(5)(7)cos(45°)
  • Result: c ≈ 4.96

Example 2:

  • Known: b = 10, c = 12, Angle A = 60°.
  • Formula: a² = b² + c² – 2bc cos(A)
  • Calculation: a² = 100 + 144 – 2(10)(12)(0.5)
  • Result: a ≈ 11.14

Example 3:

  • Known: a = 8, c = 15, Angle B = 120°.
  • Calculation: b² = 64 + 225 – 2(8)(15)(-0.5)
  • Result: b = 20.22

Example 4:

  • Known: a = 3, b = 4, Angle C = 90°.
  • Calculation: c² = 9 + 16 – 2(3)(4)(0) (Notice how it becomes the Pythagorean theorem!)
  • Result: c = 5

Example 5:

  • Known: b = 20, c = 25, Angle A = 30°.
  • Result: a ≈ 12.65

Finding Missing Angle (Math Context)

Example 6:

  • Known: a = 5, b = 6, c = 7. Find Angle C.
  • Formula: cos(C) = (a² + b² – c²) / 2ab
  • Calculation: cos(C) = (25 + 36 – 49) / 2(5)(6) = 12 / 60 = 0.2
  • Result: Angle C ≈ 78.46°

Example 7:

  • Known: a = 8, b = 10, c = 15. Find Angle A.
  • Result: Angle A ≈ 25.1°

Example 8:

  • Known: a = 7, b = 7, c = 7 (Equilateral triangle). Find Angle B.
  • Result: Angle B = 60°

Example 9:

  • Known: a = 9, b = 12, c = 15. Find Angle C.
  • Result: Angle C = 90°

Example 10:

  • Known: a = 14, b = 9, c = 8. Find Angle A.
  • Result: Angle A ≈ 119.9°

Navigation Applications

Example 11: Two hikers leave a campsite at the same time. Hiker A walks 4 miles in one direction. Hiker B walks 6 miles in another direction. The angle between their paths is 50°. How far apart are they?

  • Result: They are approximately 4.63 miles apart.

Example 12: A boat leaves a dock and travels 15 km. It then turns and travels 20 km. If the angle created between the two paths relative to the starting point was 110°, how far is the boat from the dock?

  • Result: The boat is approximately 28.8 km from the dock.

Surveying Applications

Example 13: A surveyor needs to measure the distance across a lake. She stands at point C, measures 50 meters to point A on one side of the lake, and 70 meters to point B on the other side. The angle at C is 85°.

  • Result: The distance across the lake (side c) is approximately 82.4 meters.

Example 14: A triangular piece of land has sides of 120m, 150m, and 200m. The surveyor needs to find the largest corner angle to plan a fence.

  • Result: The largest angle (opposite the 200m side) is approximately 97.9°.

Architecture & Construction

Example 15: An architect is designing an A-frame roof. The two sloping sides are 15 feet and 18 feet long, and they meet at the top at an angle of 75°. How wide is the base of the roof?

  • Result: The base is approximately 20.2 feet wide.

Example 16: A construction worker is cutting a triangular piece of glass. The sides must be 30 inches, 40 inches, and 60 inches. He needs to know the smallest angle to set his cutting tool correctly.

  • Result: The smallest angle is approximately 26.38°.

Aviation Applications

Example 17: Airplane 1 flies 300 miles from the airport. Airplane 2 flies 450 miles from the airport. Radar shows the angle between their flight paths is 135°. How far apart are the planes?

  • Result: They are approximately 697 miles apart.

Example 18: A pilot is blown off course. She flies 100 miles north, turns, and flies 150 miles. If she is now 210 miles from her starting point, what was the angle of her turn?

  • Result: The angle inside the triangle is approximately 111°.

Marine Navigation & Robotics

Example 19 (Marine): Two ships leave a port. Ship one travels 25 nautical miles. Ship two travels 35 nautical miles. The angle between their courses is 40°. Distance between them?

  • Result: Approximately 22.5 nautical miles.

Example 20 (Robotics): A robotic arm has two segments, one 40cm and one 60cm. If the joint between them opens to an angle of 145°, how far is the tip of the robot arm from the base?

  • Result: Approximately 95.5 cm.

Real-Life Applications

The Law of Cosines is not just a math class exercise; it powers the modern world.

  • Civil Engineering: Engineers use it to calculate the forces on bridge trusses and to determine the lengths of support cables on irregular structures.
  • Surveying: When physical obstacles (like a mountain or a river) block a direct measurement, surveyors measure angles and clear paths, using the formula to calculate the blocked distance.
  • Architecture: Used to calculate precise dimensions for irregular floor plans, custom roofs, and angular building facades.
  • GPS Mapping: Satellite triangulation relies heavily on trigonometric laws to pinpoint your exact location on Earth.
  • Aviation & Navigation: Pilots and captains use it to calculate true ground speed and course corrections when dealing with strong crosswinds.
  • Robotics: In “inverse kinematics,” computers use this law to calculate exactly what angle a robot’s mechanical joints must bend to place a robotic hand at a specific coordinate.
  • Computer Graphics: 3D rendering engines calculate the lighting and rendering of 3D objects (which are made of thousands of tiny triangles) using these trigonometric principles.

Common Mistakes

When calculating the Law of Cosines manually, people frequently make these errors:

  1. Wrong Angle Selection: When solving for a side, you MUST use the angle directly opposite to that side. If solving for side a, you must use angle A.
  2. Unit Errors (Degrees vs Radians): Your calculator might be set to Radians when you enter Degrees (or vice versa). The cosine of 45 Degrees is very different from the cosine of 45 Radians!
  3. Order of Operations (PEMDAS): Many students add a² + b² and then subtract 2ab BEFORE multiplying by the cosine. You must multiply 2ab × cos(C) first, and then subtract that whole chunk from a² + b².
  4. Forgetting the Square Root: The side formula equals c². Many people forget that the final step is taking the square root (√) to get c.
  5. Rounding Errors: Rounding numbers too early in the middle of the calculation will make your final answer inaccurate. Keep all decimal places until the very last step.

Benefits of Using a Cosine Calculator

Why use a digital Law of Cosines Calculator instead of doing it by hand?

  • Saves Time: What takes 5 minutes on paper takes 0.5 seconds online.
  • Improves Accuracy: It eliminates human error in arithmetic and order of operations.
  • Reduces Manual Errors: It automatically handles the tricky negative signs that occur when dealing with obtuse angles (angles over 90° have a negative cosine).
  • Excellent for Learning: Premium calculators show the step-by-step breakdown, helping students understand how the answer was found, which is perfect for homework verification.

Comparison Tables

Degrees vs Radians Reference

DegreesRadiansCosine Value
01
30°π/60.866
45°π/40.707
60°π/30.5
90°π/20
120°2π/3-0.5
180°π-1

Triangle Types Reference

Triangle TypeAngle PropertiesLaw of Cosines Note
AcuteAll angles < 90°Cosine values are all positive.
RightOne angle = 90°Formula simplifies to c² = a² + b².
ObtuseOne angle > 90°The cosine of the obtuse angle is negative, which means you will actually add the 2ab term to the squares.

Formula Reference Table

To Find…You Must Know…Formula To Use
Side asides b, c, angle Aa = √(b² + c² – 2bc cos(A))
Side bsides a, c, angle Bb = √(a² + c² – 2ac cos(B))
Side csides a, b, angle Cc = √(a² + b² – 2ab cos(C))
Angle Asides a, b, cA = arccos((b² + c² – a²) / 2bc)

Featured Snippet Answers

What is the Law of Cosines?

The Law of Cosines is a geometric formula that relates the lengths of the sides of a triangle to the cosine of one of its angles, allowing you to find missing sides or angles in non-right triangles.

When do you use the Law of Cosines?

You use the Law of Cosines when you know two sides and the included angle (SAS) and want to find the third side, or when you know all three sides (SSS) and want to find an angle.

What is the Cosine Rule?

The Cosine Rule is simply another name for the Law of Cosines. It is the exact same mathematical formula: c² = a² + b² – 2ab cos(C).

How do you calculate a missing side?

Square the two known sides, add them together, subtract twice their product multiplied by the cosine of the included angle, and finally, take the square root of that result.

How do you calculate a missing angle?

Square the two sides adjacent to the angle, subtract the square of the side opposite the angle, divide by twice the product of the adjacent sides, and then take the inverse cosine (arccos) of the result.

FAQ SECTION

Here are 50 detailed frequently asked questions regarding the Law of Cosines, trigonometry, and solving triangles.

1. Can the Law of Cosines be used on any triangle?

Yes, it applies to every type of triangle: acute, obtuse, scalene, isosceles, equilateral, and right triangles.

2. What happens if I use the Law of Cosines on a right triangle?

The cosine of 90 degrees is zero. Therefore, the -2ab cos(90°) part of the equation becomes zero, leaving you with just c² = a² + b² (the Pythagorean theorem).

3. What does SAS mean?

SAS stands for Side-Angle-Side. It means you know the length of two sides and the measure of the angle that is formed exactly between them.

4. What does SSS mean?

SSS stands for Side-Side-Side. It means you know the lengths of all three sides of the triangle, but none of the angles.

5. Can I use the Law of Cosines for SSA (Side-Side-Angle)?

It is difficult and often leads to a quadratic equation. The Law of Sines is generally better for SSA, though SSA can create the “ambiguous case” (two possible triangles).

6. Does the Law of Cosines have an ambiguous case?

No! Unlike the Law of Sines, the Law of Cosines will always yield exactly one unique answer for an angle between 0 and 180 degrees.

7. Why is my calculator giving me a negative number for a side?

You cannot have a negative side length. You likely forgot to take the square root at the very end of the equation, or you calculated the negative cosine incorrectly.

8. Why is the cosine of an obtuse angle negative?

In trigonometry, angles between 90° and 180° fall into the second quadrant of the unit circle, where cosine values are negative.

9. How do I find the largest angle of a triangle?

The largest angle is always directly opposite the longest side.

10. How do I find the smallest angle of a triangle?

The smallest angle is always directly opposite the shortest side.

11. What is inverse cosine (arccos)?

Inverse cosine asks the question backward: “What angle gives me this specific cosine value?” You use it when finding missing angles.

12. On a calculator, what does cos⁻¹ mean?

It is the button for inverse cosine (or arccos). It is used to find angles.

13. Do I need to convert degrees to radians?

It depends on your specific math problem. Just ensure your calculator’s mode (DEG or RAD) matches the units of your inputs.

14. What is the Triangle Inequality Theorem?

It states that the sum of the lengths of any two sides of a triangle must be strictly greater than the length of the third side.

15. What happens if I enter impossible side lengths into the calculator?

If the sides violate the Triangle Inequality Theorem (e.g., sides 2, 2, and 10), the calculator will return an error because a triangle cannot physically exist with those dimensions.

16. Is the Law of Cosines tested on the SAT or ACT?

Yes, primarily on the ACT and in advanced SAT math sections. Knowing it can save you significant time.

17. Who invented the Law of Cosines?

Elements of it trace back to Euclid’s Elements (3rd century BC), though the modern trigonometric form was formalized by mathematicians in the Middle Ages.

18. Why do we need a, b, and c formulas? Aren’t they the same?

They are the exact same logical pattern. We just write out three versions so it is easy to match the letters to whatever side you are trying to find.

19. How do surveyors use this rule?

They measure the distance from their equipment to two different points, measure the angle between those lines of sight, and use the Law of Cosines to calculate the distance between the two points.

20. What is an included angle?

The angle trapped between two known sides. If you know side a and side b, angle C is the included angle.

21. Can I use the Law of Sines and Cosines together?

Yes. Often, you use the Law of Cosines to find one missing piece, and then switch to the Law of Sines to find the rest, because the Law of Sines is quicker to write out.

22. If I have all three sides, which angle should I find first?

It is a best practice to use the Law of Cosines to find the largest angle first. This prevents the ambiguous case if you switch to the Law of Sines later.

23. Can the result of the angle formula be greater than 1?

No. The fraction part of the angle formula must yield a decimal between -1 and 1. If it doesn’t, your side lengths do not form a valid triangle.

24. What is a polygon triangulation?

Breaking a complex polygon into a series of smaller triangles so that rules like the Law of Cosines can be used to calculate its total area and perimeter.

25. How do I memorize the formula?

Think of it as the Pythagorean theorem (c² = a² + b²) with an adjustment factor (- 2ab cos(C)) added to the end to account for the angle not being exactly 90 degrees.

26. Can I calculate area using the Law of Cosines? Not directly. Use Heron’s formula or 1/2(ab)sin(C).

27. Is this used in 3D geometry? Yes, in calculating vectors and 3D distances.

28. What is the spherical Law of Cosines? A variation used for triangles drawn on the surface of a sphere (like Earth navigation).

29. Why did my calculator say “Math Error”? You likely tried to take the arccosine of a number outside of the [-1, 1] range.

30. How is this used in physics? To find the resultant vector when two forces are pushing at an angle.

31. What is an oblique triangle? Any triangle that does not have a 90° right angle.

32. Does it matter which side I label a, b, or c? No, as long as angle A is strictly opposite side a, etc.

33. How precise should my decimals be? In engineering, usually 3 to 4 decimal places are required.

34. Can I use this for a straight line? If the angle is 180°, the triangle flattens into a line segment.

35. How does this help in computer graphics? It calculates camera angles and lighting reflection paths.

36. Do carpenters use this? Yes, particularly for calculating rafter lengths and stair stringers.

37. How is it used in astronomy? To calculate the distances between stellar objects when viewed from Earth.

38. What if my angle is negative? In geometry, triangle angles are strictly positive (between 0° and 180°).

39. Can a triangle have two obtuse angles? No, the sum of all angles must be exactly 180°.

40. What is “solving a triangle”? Finding all 3 side lengths and all 3 angle measurements.

41. Is it better to use decimals or fractions? In advanced math, keep the exact fraction/radical form until the very end.

42. How do I check my work? Add up all your calculated angles; they must equal exactly 180°.

43. What is a “bearing” in navigation? An angle measured clockwise from the North direction, heavily using cosine rules.

44. Can I find the height of a triangle with this? Indirectly. Find an angle first, then use basic sine to find the height.

45. Why is PEMDAS important here? Multiplication (the 2ab cos(C) part) must be done before the subtraction.

46. Can I use this in calculus? Yes, it frequently appears in related rates and optimization problems.

47. What is vector dot product? The algebraic equivalent of the Law of Cosines in linear algebra.

48. Are there free calculators online? Yes, our Cosine Calculator provides instant, free results.

49. How do I enter radians into a calculator? Change the mode button from DEG to RAD.

50. What is the most common student error? Forgetting to take the square root at the very end of the side formula.

References Section

  1. Algebra and Trigonometry – OpenStax Educational Resources.
  2. Engineering Mathematics – K.A. Stroud.
  3. Euclid’s Elements – Historical Geometric Principles.
  4. National Council of Teachers of Mathematics (NCTM) Standards.
  5. Practical Surveying and Mapping – Civil Engineering Standards.

Conclusion

The Law of Cosines is a fundamental pillar of geometry and trigonometry. While the formula might look intimidating at first glance, it is simply a way to connect the lengths of a triangle’s sides with its internal angles.

Whether you are dealing with a Side-Angle-Side (SAS) scenario to find a missing boundary line, or a Side-Side-Side (SSS) scenario to calculate the exact angle of an architectural roof, this math rule will never fail you.

By using an online Cosine Calculator, you remove the risk of manual arithmetic errors, avoid confusing negative cosine values, and get instant, accurate results. Bookmark this page for your homework, exam preparation, or professional engineering calculations, and you will always have the power to solve any triangle with ease!

Scroll to Top