Cosine Rule Calculator

Cosine Rule Calculator

The Cosine Rule, also known as the Law of Cosines, is a fundamental formula in trigonometry that relates the lengths of the sides of a triangle to the cosine of one of its angles. It is a generalization of the Pythagorean theorem, which only applies to right-angled triangles.

This calculator can help you solve for an unknown side or an unknown angle in any triangle, given sufficient information.

When to Use the Cosine Rule:

  • To find an unknown side (SAS – Side-Angle-Side): If you know the lengths of two sides of a triangle and the measure of the included angle (the angle between those two sides), you can use the Cosine Rule to find the length of the third side.
  • To find an unknown angle (SSS – Side-Side-Side): If you know the lengths of all three sides of a triangle, you can use the Cosine Rule to find the measure of any of the triangle's angles.

Formulas:

Let a, b, and c be the lengths of the sides of a triangle, and let A, B, and C be the angles opposite those sides, respectively.

To find a side (e.g., side c):

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

This can be rearranged to find 'a' or 'b' similarly:

  • a² = b² + c² - 2bc cos(A)
  • b² = a² + c² - 2ac cos(B)

To find an angle (e.g., angle C):

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

This can be rearranged to find 'A' or 'B' similarly:

  • cos(A) = (b² + c² - a²) / (2bc)
  • cos(B) = (a² + c² - b²) / (2ac)

Calculate a Side (SAS)

Enter the lengths of two sides and the included angle to find the third side.








Calculate an Angle (SSS)

Enter the lengths of all three sides to find the angle opposite side 'c'.







function calculateSideC() { var a = parseFloat(document.getElementById('sideA_sas').value); var b = parseFloat(document.getElementById('sideB_sas').value); var angleC_deg = parseFloat(document.getElementById('angleC_sas').value); var resultDiv = document.getElementById('resultSideC'); if (isNaN(a) || isNaN(b) || isNaN(angleC_deg) || a <= 0 || b <= 0 || angleC_deg = 180) { resultDiv.innerHTML = 'Please enter valid positive numbers for side lengths and an angle between 0 and 180 degrees.'; return; } var angleC_rad = angleC_deg * Math.PI / 180; var c_squared = (a * a) + (b * b) – (2 * a * b * Math.cos(angleC_rad)); if (c_squared < 0) { // Should not happen with valid inputs, but good for robustness resultDiv.innerHTML = 'Calculation error: Resulting side squared is negative. Check inputs.'; return; } var c = Math.sqrt(c_squared); resultDiv.innerHTML = '

Calculated Side \'c\':

' + c.toFixed(4) + "; } function calculateAngleC() { var a = parseFloat(document.getElementById('sideA_sss').value); var b = parseFloat(document.getElementById('sideB_sss').value); var c = parseFloat(document.getElementById('sideC_sss').value); var resultDiv = document.getElementById('resultAngleC'); if (isNaN(a) || isNaN(b) || isNaN(c) || a <= 0 || b <= 0 || c c) && (a + c > b) && (b + c > a))) { resultDiv.innerHTML = 'These side lengths do not form a valid triangle (Triangle Inequality Theorem).'; return; } var cosC = ((a * a) + (b * b) – (c * c)) / (2 * a * b); // Ensure cosC is within valid range [-1, 1] due to floating point inaccuracies if (cosC > 1) cosC = 1; if (cosC < -1) cosC = -1; var angleC_rad = Math.acos(cosC); var angleC_deg = angleC_rad * 180 / Math.PI; resultDiv.innerHTML = '

Calculated Angle \'C\':

' + angleC_deg.toFixed(4) + ' degrees'; }

Understanding the Results:

The calculator provides the length of the unknown side or the measure of the unknown angle based on your inputs. The units for the side lengths will be the same as the units you entered (e.g., if you enter meters, the result will be in meters). Angles are always given in degrees.

Example Scenarios:

Example 1: Finding a Side (SAS)

Imagine you have a triangle where:

  • Side 'a' = 10 units
  • Side 'b' = 12 units
  • Included Angle 'C' = 60 degrees

Using the formula c² = a² + b² - 2ab cos(C):

c² = 10² + 12² - 2 * 10 * 12 * cos(60°)

c² = 100 + 144 - 240 * 0.5

c² = 244 - 120

c² = 124

c = √124 ≈ 11.1355 units

You can verify this by entering these values into the "Calculate a Side (SAS)" section above.

Example 2: Finding an Angle (SSS)

Consider a triangle with the following side lengths:

  • Side 'a' = 7 units
  • Side 'b' = 8 units
  • Side 'c' = 13 units

To find Angle 'C' (opposite side 'c'), use the formula cos(C) = (a² + b² - c²) / (2ab):

cos(C) = (7² + 8² - 13²) / (2 * 7 * 8)

cos(C) = (49 + 64 - 169) / (112)

cos(C) = (113 - 169) / 112

cos(C) = -56 / 112

cos(C) = -0.5

C = arccos(-0.5) = 120 degrees

You can verify this by entering these values into the "Calculate an Angle (SSS)" section above.

The Cosine Rule is an indispensable tool in various fields, including engineering, architecture, surveying, and even computer graphics, for solving problems involving non-right-angled triangles.

.calculator-container { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f9f9f9; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); max-width: 700px; margin: 20px auto; color: #333; } .calculator-container h2, .calculator-container h3 { color: #0056b3; text-align: center; margin-bottom: 15px; } .calculator-container p { line-height: 1.6; margin-bottom: 10px; } .calculator-container ul { list-style-type: disc; margin-left: 20px; margin-bottom: 15px; } .calculator-container ul li { margin-bottom: 5px; } .calculator-form { background-color: #ffffff; padding: 20px; border-radius: 5px; border: 1px solid #e0e0e0; margin-top: 20px; margin-bottom: 20px; } .calculator-form label { display: block; margin-bottom: 8px; font-weight: bold; color: #555; } .calculator-form input[type="number"] { width: calc(100% – 22px); padding: 10px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 16px; } .calculator-form button { background-color: #007bff; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; width: 100%; transition: background-color 0.3s ease; } .calculator-form button:hover { background-color: #0056b3; } .calculator-result { margin-top: 20px; padding: 15px; background-color: #e9f7ef; border: 1px solid #d4edda; border-radius: 4px; color: #155724; font-size: 1.1em; font-weight: bold; text-align: center; } .calculator-result h3 { color: #155724; margin-top: 0; margin-bottom: 10px; } .calculator-result p { margin: 0; color: #155724; } hr { border: 0; height: 1px; background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0)); margin: 30px 0; }

Leave a Reply

Your email address will not be published. Required fields are marked *