Introduction: The Law of Cosines – A Cornerstone of Trigonometry

The Law of Cosines stands as one of the most essential theorems in trigonometry, functioning as a powerful bridge between basic triangle geometry and real-world measurement. While the Pythagorean theorem provides a perfect solution for right triangles, the Law of Cosines extends that capability to any triangle—whether acute, obtuse, or right. For centuries, mariners, surveyors, and pilots have relied on this formula to determine distances and bearings when direct measurements are impossible. Even in the age of satellite navigation, the Law of Cosines remains a critical fallback when GPS signals are weak or unavailable, and it underpins many algorithms in dead reckoning and triangulation systems.

The standard form of the Law of Cosines states: for a triangle with sides a, b, and c and corresponding opposite angles A, B, and C, we have:

  • c² = a² + b² − 2ab cos(C)
  • a² = b² + c² − 2bc cos(A)
  • b² = a² + c² − 2ac cos(B)

In this expanded article, we will derive the law step by step using coordinate geometry, explore its historical development, examine its practical applications in navigation with worked examples, and discuss its limitations and modern alternatives.

Deriving the Law of Cosines – A Step‑by‑Step Approach

Setting Up the Triangle on a Coordinate Plane

To derive the formula from first principles, we place a general triangle with vertices A, B, and C in a Cartesian coordinate system. For convenience, let angle C be positioned at the origin, and let side b lie along the positive x‑axis. This means:

  • Point C = (0, 0)
  • Point A = (b, 0) — because side b is the length from C to A.
  • Point B = (x, y) — we will express these coordinates in terms of side a and angle C.

Since side a runs from C to B, and the angle at C is between sides b (CA) and a (CB), the coordinates of point B can be written using polar coordinates:

B = (a cos C, a sin C)

Notice that we use the convention that the angle C is measured from the x‑axis (side b) upward, consistent with standard polar representation. Now side c connects points A (b, 0) and B (a cos C, a sin C).

Applying the Distance Formula

The length of side c is simply the Euclidean distance between these two points. Using the distance formula:

= (x₁ − x₂)² + (y₁ − y₂)²

Substituting the coordinates:

= (b − a cos C)² + (0 − a sin C)²

Now expand the squares:

= b² − 2ab cos C + a² cos² C + a² sin² C

Factor from the last two terms and recall the Pythagorean identity cos²θ + sin²θ = 1:

= b² − 2ab cos C + a² (cos² C + sin² C)

= b² − 2ab cos C + a²

Rearranging the terms gives the familiar form:

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

This derivation reveals that the Law of Cosines is essentially the Pythagorean theorem with a correction term that accounts for the angle between the two known sides. If angle C is 90°, cos(C) = 0 and the formula reduces to c² = a² + b² — the Pythagorean theorem. If angle C is obtuse (greater than 90°), cos(C) becomes negative, so the correction term adds to a² + b², reflecting the fact that side c becomes longer than the hypotenuse of a right triangle with the same legs.

Historical Context and Early Applications

The Law of Cosines was known in geometric form to ancient Greek mathematicians, particularly Euclid in his Elements (Book II, Propositions 12 and 13), which handled obtuse and acute triangles separately using squared lengths and rectangles. The trigonometric form as we know it today was developed by Islamic scholars such as Al‑Battānī and later formalized by European mathematicians like François Viète in the 16th century. Viète was the first to state the law in modern algebraic notation, enabling its widespread use in navigation and astronomy. By the age of exploration, the Law of Cosines had become a standard tool for determining longitude via lunar distances and for plotting courses across uncharted oceans.

Practical Uses of the Law of Cosines in Navigation

Classic Triangulation and Coastal Navigation

Before the advent of GPS, navigators determined their position by measuring bearings to two or more known landmarks — lighthouses, headlands, radio beacons, or charted points. The angle between those lines of sight and the distances to the landmarks (obtained from charts or radar) formed a triangle. Using the Law of Cosines, the navigator could compute the exact distance between the landmarks and, with additional application of the Law of Sines, resolve their own position relative to those landmarks.

Worked Example: Two Lighthouses

A ship’s navigator takes bearings on two lighthouses with known positions. The radar indicates the ship is 10 nautical miles from Lighthouse A (a) and 12 nautical miles from Lighthouse B (b). The angle between the two bearing lines, measured at the ship, is 35° (this is the included angle between the two sides, angle C). The navigator wants to verify the distance between the lighthouses (side c) as shown on the chart.

  1. Identify knowns: a = 10, b = 12, C = 35°.
  2. Apply the Law of Cosines: = 10² + 12² − 2 × 10 × 12 × cos(35°).
  3. Compute cos(35°): ≈ 0.8192.
  4. So = 100 + 144 − 240 × 0.8192 = 244 − 196.608 = 47.392.
  5. Take square root: c ≈ 6.88 nautical miles.

This calculated distance can be cross‑checked against the chart. A significant discrepancy might indicate a radar error or a mistaken landmark identification. This procedure, known as sextant triangulation, was standard practice well into the 20th century and is still taught as a fundamental backup skill in maritime academies.

Great Circle Sailing and Spherical Trigonometry

For long‑distance ocean voyages, navigators must account for the Earth’s curvature. The shortest path between two points on a sphere is the great circle — a plane through the Earth’s center that intersects the surface. Solving great circle problems involves the Spherical Law of Cosines, which is a direct adaptation of the planar version:

cos(c) = cos(a) · cos(b) + sin(a) · sin(b) · cos(C)

In this equation, a, b, and c represent side lengths expressed as central angles (in degrees or radians), and C is the angle at the vertex opposite side c — usually the difference in longitude between two points when the other two sides are co‑latitudes. The formula allows navigators to compute the great‑circle distance between any two points on Earth given their latitudes and longitudes.

Worked Example: Great‑Circle Distance

A navigator wants to find the great‑circle distance from New York (40.7128° N, 74.0060° W) to London (51.5074° N, 0.1278° W).

  1. Convert latitudes and longitudes to radians:
    lat₁ = 40.7128° × π/180 = 0.7105 rad,
    lat₂ = 51.5074° × π/180 = 0.8990 rad,
    Δλ = (0.1278° − (−74.0060°)) = 74.1338° × π/180 = 1.2939 rad.
  2. Apply the spherical law of cosines:
    cos(c) = sin(lat₁) sin(lat₂) + cos(lat₁) cos(lat₂) cos(Δλ)
    = sin(0.7105) sin(0.8990) + cos(0.7105) cos(0.8990) cos(1.2939).
  3. Compute: sin(0.7105) ≈ 0.652, sin(0.8990) ≈ 0.783, cos(0.7105) ≈ 0.758, cos(0.8990) ≈ 0.622, cos(1.2939) ≈ 0.270.
  4. Thus cos(c) = (0.652 × 0.783) + (0.758 × 0.622 × 0.270) ≈ 0.510 + 0.127 = 0.637.
  5. c = arccos(0.637) ≈ 0.882 rad.
  6. Multiply by Earth’s mean radius (3440 nautical miles) to get distance: 0.882 × 3440 ≈ 3034 nautical miles.

This calculation matches standard great‑circle distances published in nautical almanacs. While the haversine formula is often used today for better numerical stability over short distances, the spherical law of cosines remains a valuable conceptual tool and appears in many online distance calculators.

Position Fixing with the Law of Cosines in Modern Systems

Even with GPS, the Law of Cosines plays a role in error correction and in calculating elevation angles. A GPS receiver determines its position by solving a system of equations that include distances (pseudoranges) to satellites. The geometry of the satellite constellation — specifically the angles between the receiver’s lines of sight to different satellites — is quantified by a metric called Dilution of Precision (DOP). DOP calculations rely on the cosines of angles between satellite vectors. Poor geometry (small angles between satellites) leads to higher DOP and less accurate fixes. Understanding this connection allows engineers to design better receivers and helps navigators interpret GPS quality.

Inertial navigation systems (INS) also use the Law of Cosines when fusing data from accelerometers and gyroscopes. As the INS estimates position over time, it solves triangles between the estimated vehicle location and known waypoints or beacon signals. This process, called dead reckoning with periodic updates, relies on the same trigonometric principles that guided sailors centuries ago.

Step‑by‑Step Practical Workflow for Solving Navigation Problems

Here is a general workflow for using the Law of Cosines in a real navigation problem — specifically the side‑angle‑side (SAS) case:

  1. Identify the known values – two side lengths (for example, distances from your vessel to two landmarks) and the included angle (the bearing difference between them, or the angle at the observer’s position).
  2. Convert all measurements to consistent units – nautical miles, kilometers, or statute miles. Ensure the angle is in degrees or radians as required by your calculator or software.
  3. Apply the formula:
    = + − 2ab cos(C).
    Compute c by taking the positive square root.
  4. If the full position is needed, use the Law of Sines to find the other angles, then plot the result on a chart or convert distances and bearings to latitude/longitude offsets using the Vincenty formulas for more accuracy over distance.
  5. Cross‑check with a second set of landmarks or with a GPS reading if available. Discrepancies greater than 5% of the distance often indicate a measurement error or chart inaccuracy.

Real‑World Example: VOR Navigation for Aircraft

A pilot flying under instrument flight rules (IFR) may need to verify position using two VOR stations. Suppose the aircraft’s distance to VOR Alpha is 45 nautical miles (radial 270°), and the distance to VOR Bravo is 60 nautical miles (radial 330°). The angle between the two radials as seen from the aircraft is 60° (the difference in bearings). The pilot can compute the distance between the two VOR stations using the Law of Cosines:

c = √(45² + 60² − 2 × 45 × 60 × cos(60°)) = √(2025 + 3600 − 5400 × 0.5) = √(5625 − 2700) = √2925 ≈ 54.1 nautical miles.

This distance should match the known charted distance between the two VORs. If it does, the aircraft’s estimated position relative to both stations is consistent. This technique provides a robust backup if GPS fails or if the pilot wants to confirm navigation database accuracy.

Limitations and Alternatives

Numerical and Geometric Limitations

The planar Law of Cosines is not suitable for all navigation contexts:

  • Small angles – When the included angle is very small (approaching 0°), the term 2ab cos(C) is nearly equal to 2ab, and the formula becomes subject to subtractive cancellation, leading to rounding errors. For angles below 1°, it is better to use the Law of Sines directly or, for spherical problems, the haversine formula, which avoids cosines near 0° and 180°.
  • Large distances on Earth – The planar version assumes a flat surface, which becomes inaccurate over distances greater than about 100 nautical miles. For oceanic voyages or intercontinental flights, spherical trigonometry is essential. The spherical law of cosines works well for distances up to about 20,000 km, but even that can suffer from rounding errors when the distance is very small — hence the preference for the haversine formula in many algorithms.
  • GPS dependency – Modern navigation heavily relies on GPS, but the Law of Cosines remains a critical backup skill. The U.S. Coast Guard and international maritime organizations still test navigation officers on trigonometric methods as part of licensing examinations.

Alternative Trigonometric Methods

The Law of Sines often complements the Law of Cosines, especially in ASA or AAS cases. For example, after using the Law of Cosines to find the third side, you can apply the Law of Sines to find the remaining angles. For spherical navigation, the haversine formula is numerically preferable for small distances because it computes haversine of half the distance, avoiding cosine values near the extremes of the arccosine function. An excellent resource with clear implementations of both planar and spherical formulas is the Movable Type Scripts page on distance and bearing.

Additionally, the Vincenty formulas provide even higher accuracy for ellipsoidal Earth models and are used in modern GIS systems. However, the Law of Cosines remains the conceptual foundation upon which these more complex algorithms are built.

Conclusion

The Law of Cosines is far more than a textbook identity — it is a practical, field‑tested tool that has guided explorers, sailors, and aviators for centuries. By understanding its derivation from the distance formula and its application in real navigation scenarios, you gain the ability to solve triangles quickly and accurately, whether you are plotting a course by hand on a paper chart or writing code for an autopilot system. Mastery of this law, together with its spherical counterpart, ensures that you can navigate with confidence, even when modern electronics fail. For further reading, explore Britannica’s entry on the law of cosines or the classic navigation text Dutton’s Nautical Navigation, which devotes an entire chapter to trigonometric solutions.