Law of Cosines Calculator: Find Triangle Sides & Angles
Triangle Side & Angle Calculator (Law of Cosines)
Use this calculator to find unknown sides or angles of a triangle when you know certain other values. Select which side or angle you want to find based on the information you have.
Enter the length of a known side or the measure of a known angle (in degrees).
Enter the length of another known side or the measure of another known angle (in degrees).
Enter the length of the third known side or the measure of the third known angle (in degrees).
Select whether your angle inputs are in degrees or radians.
What is the Law of Cosines?
The Law of Cosines is a fundamental principle in trigonometry that establishes a relationship between the lengths of the sides of any triangle and the cosine of one of its angles. Unlike the Pythagorean theorem, which applies only to right-angled triangles, the Law of Cosines is versatile and can be applied to any triangle, regardless of its internal angles.
This powerful law is particularly useful when you have enough information about a triangle to uniquely determine its shape and size, but not enough to directly use simpler trigonometric functions. It’s an essential tool for solving oblique triangles (triangles without a right angle).
Who Should Use It?
The Law of Cosines is a vital concept for:
- Students: Learning trigonometry, geometry, and advanced mathematics.
- Engineers: Surveying, construction, and mechanical design, where precise measurements of non-right angles are common.
- Navigators: Calculating distances and bearings on maps or at sea where spherical trigonometry might be simplified or initial calculations are needed.
- Physicists: Analyzing forces and vectors acting at angles.
- Architects: Designing structures with complex angles.
- Anyone solving geometry problems involving triangles where side-angle-side (SAS) or side-side-side (SSS) information is known.
Common Misconceptions
- It only works for right triangles: This is incorrect; the Pythagorean theorem is a special case of the Law of Cosines for right triangles.
- It requires all sides and angles to be known: This is also incorrect; the law is used precisely when one or more sides or angles are *unknown*.
- It’s overly complex for simple triangles: While it can solve for any triangle, it’s often more computationally intensive than basic sine/cosine rules for simpler cases. However, it’s indispensable when those simpler rules are insufficient.
Law of Cosines Formula and Mathematical Explanation
Consider a triangle ABC, where the sides opposite to angles A, B, and C are denoted by lowercase letters a, b, and c, respectively. The Law of Cosines states:
c² = a² + b² – 2ab cos(C)
This formula can be rearranged to solve for any side if the other two sides and the included angle are known. Similarly, it can be used to find an angle if all three sides are known.
Derivation and Formulas
The derivation typically involves placing the triangle on a coordinate plane or using vector dot products. Using a geometric approach with coordinates:
- Place vertex C at the origin (0,0).
- Place vertex B along the positive x-axis at (a, 0).
- Vertex A will be at coordinates (b cos(C), b sin(C)).
- The distance between A and B is side c. Using the distance formula:
c² = (b cos(C) – a)² + (b sin(C) – 0)²
c² = b² cos²(C) – 2ab cos(C) + a² + b² sin²(C)
c² = b²(cos²(C) + sin²(C)) + a² – 2ab cos(C)
Since cos²(C) + sin²(C) = 1, we get:
c² = a² + b² – 2ab cos(C)
Rearranged Formulas
To find side ‘c’:
c = sqrt(a² + b² - 2ab cos(C))
To find angle ‘C’ (when sides a, b, c are known):
cos(C) = (a² + b² - c²) / (2ab)
C = arccos((a² + b² - c²) / (2ab))
The Law of Cosines can be written cyclically for any side and its opposite angle:
- a² = b² + c² – 2bc cos(A) =>
cos(A) = (b² + c² - a²) / (2bc) - b² = a² + c² – 2ac cos(B) =>
cos(B) = (a² + c² - b²) / (2ac)
Variable Explanations
| Variable | Meaning | Unit | Typical Range |
|---|---|---|---|
| a, b, c | Length of the sides of the triangle | Units of length (e.g., meters, feet, km) | Positive real numbers (> 0) |
| A, B, C | Measure of the angles opposite to sides a, b, c respectively | Degrees or Radians | (0, 180°) or (0, π) radians |
| cos(C), cos(A), cos(B) | The cosine of the angle | Unitless | [-1, 1] |
| sqrt() | Square root function | Unitless | Non-negative real numbers |
| arccos() | Inverse cosine function (arccosine) | Degrees or Radians | [0, 180°] or [0, π] radians |
Practical Examples (Real-World Use Cases)
Example 1: Finding the Length of a Side (SAS Case)
Imagine two hikers starting at the same point. Hiker 1 walks 5 km East. Hiker 2 walks 7 km in a direction 80 degrees North of East. We want to find the distance between the two hikers.
- Let side ‘a’ be the distance Hiker 1 walked = 5 km.
- Let side ‘b’ be the distance Hiker 2 walked = 7 km.
- The angle C between their paths is 80 degrees.
- We want to find the distance ‘c’ between them.
Using the Law of Cosines: c² = a² + b² – 2ab cos(C)
Inputs:
- Known Value 1 (a): 5
- Known Value 2 (b): 7
- Known Value 3 (C): 80
- Units: Degrees
Calculation:
c² = 5² + 7² – 2 * 5 * 7 * cos(80°)
c² = 25 + 49 – 70 * 0.1736
c² = 74 – 12.152
c² = 61.848
c = sqrt(61.848) ≈ 7.86 km
Result Interpretation: The distance between the two hikers is approximately 7.86 km. This calculation helps understand their separation after deviating from a common starting point.
Example 2: Finding an Angle (SSS Case)
A farmer has three fields with straight fences forming a triangle. The lengths of the fences are 100 meters, 120 meters, and 150 meters. The farmer wants to know the angle at the corner where the 100m and 120m fences meet.
- Let side ‘a’ = 120 m.
- Let side ‘b’ = 100 m.
- Let side ‘c’ = 150 m (opposite the angle we want to find).
- We want to find angle C.
Using the Law of Cosines rearranged to find the angle:
cos(C) = (a² + b² – c²) / (2ab)
Inputs:
- Known Value 1 (a): 120
- Known Value 2 (b): 100
- Known Value 3 (c): 150
- Units: Degrees (for the output angle)
Calculation:
cos(C) = (120² + 100² – 150²) / (2 * 120 * 100)
cos(C) = (14400 + 10000 – 22500) / 24000
cos(C) = (24400 – 22500) / 24000
cos(C) = 1900 / 24000
cos(C) = 0.079167
C = arccos(0.079167) ≈ 85.46°
Result Interpretation: The angle at the corner where the 100m and 120m fences meet is approximately 85.46 degrees. This information is crucial for land surveying, property division, or planning agricultural activities within these fields.
How to Use This Law of Cosines Calculator
Our Law of Cosines calculator is designed for simplicity and accuracy. Follow these steps to find unknown sides or angles of your triangle:
- Identify Your Knowns: Determine which three values of your triangle you know. You’ll typically have either two sides and the included angle (SAS), or all three sides (SSS).
- Input Values:
- Enter the lengths of the known sides or the measures of the known angles into the “Known Value 1”, “Known Value 2”, and “Known Value 3” fields.
- Ensure you enter them in the correct context (e.g., if you have SAS, enter the two sides and the angle *between* them).
- Select Units: If your known values include angles, choose whether they are in “Degrees” or “Radians” using the dropdown menu. The calculator will output the angle in the same unit.
- Click Calculate: Press the “Calculate” button.
- Read the Results:
- The “Main Result” will display the calculated unknown side length or angle.
- Intermediate values show key steps in the calculation, such as squared side lengths or cosine values, which can be helpful for verification.
- The “Formula Explanation” briefly describes the Law of Cosines.
Decision-Making Guidance
For SAS (Side-Angle-Side): Enter the lengths of the two sides and the measure of the angle *included* between them. The calculator will find the length of the side opposite the known angle.
For SSS (Side-Side-Side): Enter the lengths of all three sides. The calculator will find the measure of one of the angles. You can input the sides in any order for the first three inputs, but the calculator will output one of the angles. To find all three angles, you may need to run the calculator multiple times, calculating one angle at a time.
Important Note: Ensure your inputs form a valid triangle. The sum of any two sides must be greater than the third side (triangle inequality theorem), and angles must be positive and less than 180 degrees (or π radians).
Use the “Reset” button to clear all fields and start over. Use “Copy Results” to save or share the computed values.
Key Factors That Affect Law of Cosines Results
While the Law of Cosines itself is a direct mathematical formula, the accuracy and applicability of its results in real-world scenarios depend on several factors:
- Accuracy of Input Measurements: The most critical factor. If the lengths of sides or the measures of angles are entered incorrectly or are imprecise, the calculated results will be inaccurate. For example, in surveying, slight errors in angle measurement can lead to significant discrepancies in calculated distances over long ranges.
- Units Consistency (Degrees vs. Radians): Mismatching units is a common error. If your angle is in degrees but you calculate using radians (or vice-versa), the cosine value will be drastically wrong, leading to an incorrect side length or angle. Always ensure your calculator setting matches your input data.
- Triangle Inequality Theorem: Not all combinations of three lengths can form a triangle. The sum of the lengths of any two sides of a triangle must be greater than the length of the third side (a + b > c, a + c > b, b + c > a). If this condition isn’t met, the calculation might yield mathematically impossible results (e.g., trying to find the arccosine of a value outside [-1, 1]).
- Angle Measurement Precision: For angle calculations (SSS case), the precision of the input side lengths directly impacts the precision of the output angle. Small variations in side lengths, especially for nearly degenerate triangles (where sides are almost collinear), can lead to large swings in the calculated angle.
- Included Angle Correctness (SAS Case): When using the SAS case, it’s crucial that the angle entered is the one *between* the two known sides. Entering an angle at one of the opposite vertices will lead to an incorrect calculation for the third side.
- Floating-Point Arithmetic Limitations: Computers and calculators use finite precision for calculations. While generally negligible for typical use, extremely large or small numbers, or complex chains of operations, can introduce tiny rounding errors. Our calculator aims to minimize this but it’s a theoretical consideration in advanced computation.
- Real-World Constraints: In practical applications like construction or navigation, physical limitations, environmental factors (wind, terrain), and human error in measurement or operation are always present and can affect the actual outcome compared to the theoretical calculation.
Frequently Asked Questions (FAQ) About the Law of Cosines
Yes, it can. In fact, the Pythagorean theorem (a² + b² = c²) is a special case of the Law of Cosines. If angle C is 90 degrees, then cos(C) = cos(90°) = 0. The formula c² = a² + b² – 2ab cos(C) becomes c² = a² + b² – 2ab(0), simplifying to c² = a² + b².
You need enough information to uniquely define a triangle. This means either:
- Two sides and the included angle (SAS)
- All three sides (SSS)
You cannot solve a triangle with only two sides and a non-included angle (SSA), as this can lead to ambiguous solutions (the Law of Sines is used here, with caution).
If the inputs violate the triangle inequality theorem (sum of any two sides must be greater than the third), or if you try to calculate an angle where the input values lead to a cosine value outside the range of -1 to 1, the calculator might show an error or an invalid result (like NaN – Not a Number). Always check your inputs.
No, this calculator is designed for planar (2D) triangles. The Law of Cosines applies to triangles drawn on a flat surface.
The accuracy depends entirely on the precision of your input values and the computational precision of the device running the calculator. For most practical purposes, the results are highly accurate.
Cosine (cos) takes an angle and returns a ratio (between -1 and 1). Arccosine (acos or cos⁻¹) is the inverse function; it takes a ratio (between -1 and 1) and returns the angle that produces that ratio.
Use the Law of Cosines when you have SAS (Side-Angle-Side) or SSS (Side-Side-Side) information. Use the Law of Sines when you have ASA (Angle-Side-Angle), AAS (Angle-Angle-Side), or SSA (Side-Side-Angle – but be aware of potential ambiguities).
Yes. The arccosine function naturally returns angles between 0° and 180° (or 0 and π radians), which covers all possible angles in a triangle. If the calculated cosine value is negative, the resulting angle will be obtuse (greater than 90 degrees).
Related Tools and Resources
-
Law of Sines Calculator
Complementary to the Law of Cosines, find unknown sides and angles using the Law of Sines when you have different sets of known information.
-
Triangle Area Calculator
Calculate the area of any triangle using various formulas, including Heron’s formula and base-height methods.
-
Pythagorean Theorem Calculator
Specifically for right-angled triangles, this tool helps find the length of a missing side when two sides are known.
-
Trigonometry Basics Explained
A guide to fundamental trigonometric concepts like sine, cosine, tangent, and their applications.
-
Essential Geometry Formulas
A comprehensive list of formulas for shapes, angles, and measurements in geometry.
-
Angle Unit Converter
Easily convert angles between degrees and radians for your calculations.
Visualizing Triangle Properties
This chart visualizes the relationship between angles and their opposite sides for a triangle, based on the Law of Cosines calculation.
Calculation Summary
This section provides a summary of the last successful calculation.