Understanding the law of sines and cosines solver — concept and principle
When you know two sides of a triangle and the angle between them (the SAS case), the triangle is fixed, and you can find everything else. This solver takes side b, side c and the included angle A, then returns the third side a, the two remaining angles and the area. It is used in surveying, carpentry and navigation whenever there is no right angle to work with.
How it is calculated
- Law of cosines: a² = b² + c² − 2bc cos A, so a = √(b² + c² − 2bc cos A).
- Law of sines: a / sin A = b / sin B, so sin B = b sin A / a and B = arcsin(b sin A / a).
- Angle sum: C = 180° − A − B.
- Area: ½ bc sin A.
Angles are entered in degrees and converted to radians internally (multiply by π/180). Sides can be in any unit; side a comes out in the same unit and the area in that unit squared.
The principle
The law of cosines is the Pythagorean theorem with a correction term. Drop a perpendicular from one vertex and apply Pythagoras to the two right triangles it creates; the leftover piece is −2bc cos A. When A = 90°, cos A = 0 and the formula becomes a² = b² + c². When A is acute the third side is shorter than in the right-angle case, and when A is obtuse (cos A < 0) it is longer. The law of sines follows from the area: ½bc sin A = ½ac sin B = ½ab sin C, and dividing each by ½abc gives sin A / a = sin B / b = sin C / c. Its common value equals 1/(2R), where R is the circumradius.
Worked example
- Inputs: b = 7, c = 9, A = 60°, so cos A = 0.5 and sin A ≈ 0.866025.
- a² = 49 + 81 − 2 × 7 × 9 × 0.5 = 130 − 63 = 67, so a = √67 ≈ 8.185352772.
- sin B = 7 × 0.866025 ÷ 8.185353 ≈ 0.740613, so B ≈ 47.78365116°.
- C = 180 − 60 − 47.78365 = 72.21634884°.
- Area = ½ × 7 × 9 × 0.866025 ≈ 27.27980022.
| Included angle A (°) | Side a (law of cosines) |
|---|---|
| 15 | 2.879816989 |
| 30 | 4.569551304 |
| 45 | 6.395666155 |
| 60 | 8.185352772 |
| 75 | 9.868576408 |
| 90 | 11.40175425 |
| 120 | 13.89244399 |
How to read the result
The largest angle is always opposite the longest side: here c = 9 is longest and C ≈ 72.2° is the largest angle, which is a quick sanity check. The angles must add to 180°. A very small a means a thin triangle, where small errors in A matter a lot.
Common mistakes
- Entering an angle that is not between the two given sides; the SAS formulas need the included angle.
- Using a calculator set to radians when typing degrees by hand.
- Trusting arcsin blindly: arcsin only returns angles up to 90°, so if B is really obtuse the law of sines gives its acute supplement.
Frequently asked questions
When should I use the law of sines instead of the law of cosines?
Use the law of sines when you know two angles and a side (ASA or AAS). Use the law of cosines for SAS or when all three sides are known (SSS).
What is the ambiguous case?
With two sides and a non-included angle (SSA), zero, one or two triangles can fit, because sin B = sin(180° − B). SAS never has this problem for side a; only the arcsin step needs care.
Sources: Euclid, Elements, Book II, Propositions 12 and 13 (geometric form of the law of cosines) · I. M. Gelfand and M. Saul, Trigonometry, Birkhäuser