[Intermediate] — solving triangles that have no right angle, and the one case where the data does not determine the answer.
Before you start
- You know the ratios and can drop a perpendicular to create right triangles — trigonometric ratios.
- You know that — graphs and identities. This identity is the entire source of the ambiguous case.
- You met SSA as the criterion that fails — triangles and polygons.
What you will be able to do after this lesson:
- Derive both rules — the sine rule by dropping a perpendicular, the cosine rule by coordinates.
- Choose the correct rule from which parts of the triangle are known.
- Detect and resolve the ambiguous case, returning both triangles when both exist.
- Compute a triangle’s area from two sides and the included angle, and from three sides.
Study route: read 1–5, attempt the prediction in section 5, then run the lab. Block 4 is the one that matters.
1. Why this exists
SOH-CAH-TOA requires a right angle. Most triangles do not have one.
A surveyor measuring across a river cannot choose the triangle’s shape — the landmarks are where they are. Triangulation, the technique that mapped entire countries before satellites, works by measuring one baseline accurately and then measuring only angles to distant points, chaining triangle to triangle. None of those triangles is right-angled.
The two rules below extend trigonometry to every triangle. Both are proved by the same trick: drop a perpendicular to manufacture right triangles, then eliminate it.
2. The sine rule
Claim:
where is the side opposite angle , and so on.
Proof. Drop a perpendicular of length from vertex to side .
C
/|\
/ | \
b / |h \ a
/ | \
/____|____\
A B
c
In the left right triangle, . In the right one, . The same :
Repeat with a perpendicular from to get the third ratio.
The common value has a meaning. All three ratios equal , where is the radius of the circumcircle — the circle through all three vertices, met in the circle theorems practice task:
This follows from the central angle theorem: the chord subtends angle at the circumference and at the centre, and the chord of a circle subtending at the centre has length .
Use it when you know: two angles and any side (ASA, AAS), or two sides and a non-included angle (SSA — with care).
3. The cosine rule
Claim:
Proof by coordinates. Place the triangle so that is at the origin and lies on the positive -axis:
The placement of is exactly the unit circle definition scaled by . Now compute with the distance formula:
And , so:
Pythagoras is the special case. Put . Then and the correction term vanishes:
So the cosine rule is Pythagoras plus a correction that measures how far the triangle is from right-angled. Acute angle ⇒ ⇒ the opposite side is shorter than Pythagoras would give. Obtuse ⇒ longer.
Use it when you know: three sides (SSS — rearrange for the angle), or two sides and the included angle (SAS).
Rearranged for an angle
The sign of the numerator alone classifies the angle — positive means acute, zero right, negative obtuse. That is the classification test from the triangles practice task, and it needs no inverse cosine at all.
4. Which rule, and area
| You know | Use | Notes |
|---|---|---|
| SSS | Cosine rule, rearranged | Start with the angle opposite the longest side |
| SAS | Cosine rule | Gives the third side directly |
| ASA / AAS | Sine rule | Find the third angle first by the angle sum |
| SSA | Sine rule | Ambiguous — may give two triangles, one, or none |
Area from two sides and the included angle. The perpendicular from the sine-rule proof has height , and area is half base times height:
Area from three sides — Heron’s formula. With the semi-perimeter:
Heron’s formula follows from the previous one by substituting and the cosine rule, then simplifying — long, but nothing beyond algebra.
TIP
Predict before section 5. You are given , , . The sine rule gives , so . Is that the answer? What else satisfies , and does it produce a valid triangle? Decide before opening the answers.
5. The ambiguous case, resolved
Given SSA — angle , opposite side , adjacent side — the sine rule gives:
Because , two angles satisfy this whenever . Both may be legitimate. The full case analysis:
| Condition | Triangles | Why |
|---|---|---|
| 0 | Side is too short to reach the far arm | |
| 1 | Exactly one right-angled triangle; is the perpendicular distance | |
| and | 1 | The obtuse branch gives , so it is rejected |
| and | 2 | Both branches give a valid third angle — genuinely ambiguous |
The deciding comparison is against : the side opposite the known angle against the side adjacent to it. When the opposite side is the shorter one, the swinging arm crosses twice.
This is not a defect of the sine rule. It is the data being genuinely insufficient, which is exactly why SSA is absent from the congruence criteria.
Worked example — runnable
Runnable example: save as triangle_rules.py in any empty directory and run python3 triangle_rules.py. Standard library only; writes no files.
"""Sine and cosine rules, with the full ambiguous-case analysis."""
import math
EPS = 1e-9
def dist(p, q):
return math.hypot(q[0] - p[0], q[1] - p[1])
def sides_and_angles(A_pt, B_pt, C_pt):
"""Return (a, b, c, A, B, C) in degrees, from three vertices."""
a, b, c = dist(B_pt, C_pt), dist(A_pt, C_pt), dist(A_pt, B_pt)
A = math.degrees(math.acos(max(-1, min(1, (b*b + c*c - a*a) / (2*b*c)))))
B = math.degrees(math.acos(max(-1, min(1, (a*a + c*c - b*b) / (2*a*c)))))
C = math.degrees(math.acos(max(-1, min(1, (a*a + b*b - c*c) / (2*a*b)))))
return a, b, c, A, B, C
def circumradius(a, b, c):
"""From the extended sine rule: R = abc / (4 * area)."""
s = (a + b + c) / 2
area = math.sqrt(s * (s - a) * (s - b) * (s - c))
return a * b * c / (4 * area)
def solve_ssa(A_deg, a, b):
"""All triangles with angle A, opposite side a, adjacent side b."""
sin_B = b * math.sin(math.radians(A_deg)) / a
if sin_B > 1 + EPS:
return []
sin_B = min(1.0, sin_B)
B1 = math.degrees(math.asin(sin_B))
out = []
for B in ({B1} if abs(sin_B - 1) < EPS else {B1, 180 - B1}):
C = 180 - A_deg - B
if C > EPS:
c = a * math.sin(math.radians(C)) / math.sin(math.radians(A_deg))
out.append({"B": B, "C": C, "c": c})
return sorted(out, key=lambda s: s["B"])
if __name__ == "__main__":
print("Block 1 - both rules agree with coordinates")
for tri in [((0, 0), (7, 0), (2, 5)),
((0, 0), (6, 0), (6, 8)),
((-3, 1), (4, -2), (1, 6))]:
a, b, c, A, B, C = sides_and_angles(*tri)
# sine rule: all three ratios equal
ratios = [a / math.sin(math.radians(A)),
b / math.sin(math.radians(B)),
c / math.sin(math.radians(C))]
# cosine rule: reconstruct side c from a, b and C
c_from_cos = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(C)))
print(f" sides {a:.4f} {b:.4f} {c:.4f} angles {A:.2f} {B:.2f} {C:.2f}")
print(f" sine-rule ratios: {ratios[0]:.6f} {ratios[1]:.6f} {ratios[2]:.6f}")
print(f" cosine rule gives c = {c_from_cos:.6f} (measured {c:.6f})")
assert max(ratios) - min(ratios) < 1e-9
assert abs(c_from_cos - c) < 1e-9
print()
print("Block 2 - the common ratio is the circumcircle diameter")
a, b, c, A, B, C = sides_and_angles((0, 0), (7, 0), (2, 5))
R = circumradius(a, b, c)
print(f" a/sin A = {a / math.sin(math.radians(A)):.6f}")
print(f" 2R = {2 * R:.6f}")
assert abs(a / math.sin(math.radians(A)) - 2 * R) < 1e-9
print()
print("Block 3 - area two ways, and Pythagoras as a special case")
for tri in [((0, 0), (7, 0), (2, 5)), ((0, 0), (6, 0), (6, 8))]:
a, b, c, A, B, C = sides_and_angles(*tri)
by_sine = 0.5 * a * b * math.sin(math.radians(C))
s = (a + b + c) / 2
by_heron = math.sqrt(s * (s - a) * (s - b) * (s - c))
print(f" 1/2 ab sin C = {by_sine:.6f}, Heron = {by_heron:.6f}")
assert abs(by_sine - by_heron) < 1e-9
# the right-angled triangle: the cosine correction term vanishes
a, b, c, A, B, C = sides_and_angles((0, 0), (6, 0), (6, 8))
print(f" right-angled triangle: largest angle = {max(A, B, C):.6f}")
print(f" 6^2 + 8^2 = {6**2 + 8**2}, 10^2 = {10**2}")
assert abs(max(A, B, C) - 90) < 1e-9
print()
print("Block 4 - the ambiguous case, all four outcomes")
cases = [
("A=30, a=5, b=8 (a < b, sin B < 1)", 30, 5, 8),
("A=30, a=4, b=8 (a is exactly half b)", 30, 4, 8),
("A=30, a=3, b=8 (a too short to reach)", 30, 3, 8),
("A=30, a=10, b=8 (a >= b)", 30, 10, 8),
]
for label, A_deg, a_len, b_len in cases:
sols = solve_ssa(A_deg, a_len, b_len)
print(f" {label:40} -> {len(sols)} triangle(s)")
for s in sols:
print(f" B={s['B']:9.4f} C={s['C']:9.4f} c={s['c']:9.4f}")
# every returned triangle must satisfy the sine rule it came from
for s in sols:
assert abs(a_len / math.sin(math.radians(A_deg))
- b_len / math.sin(math.radians(s["B"]))) < 1e-9
assert len(solve_ssa(30, 5, 8)) == 2 # ambiguous
assert len(solve_ssa(30, 4, 8)) == 1 # right-angled, sin B = 1
assert len(solve_ssa(30, 3, 8)) == 0 # impossible
assert len(solve_ssa(30, 10, 8)) == 1 # a >= b, obtuse branch rejected
print()
print("triangle_rules: passed")Expected output:
Block 1 - both rules agree with coordinates
sides 7.0711 5.3852 7.0000 angles 68.20 45.00 66.80
sine-rule ratios: 7.615773 7.615773 7.615773
cosine rule gives c = 7.000000 (measured 7.000000)
sides 8.0000 10.0000 6.0000 angles 53.13 90.00 36.87
sine-rule ratios: 10.000000 10.000000 10.000000
cosine rule gives c = 6.000000 (measured 6.000000)
sides 8.5440 6.4031 7.6158 angles 74.54 46.25 59.22
sine-rule ratios: 8.864811 8.864811 8.864811
cosine rule gives c = 7.615773 (measured 7.615773)
Block 2 - the common ratio is the circumcircle diameter
a/sin A = 7.615773
2R = 7.615773
Block 3 - area two ways, and Pythagoras as a special case
1/2 ab sin C = 17.500000, Heron = 17.500000
1/2 ab sin C = 24.000000, Heron = 24.000000
right-angled triangle: largest angle = 90.000000
6^2 + 8^2 = 100, 10^2 = 100
Block 4 - the ambiguous case, all four outcomes
A=30, a=5, b=8 (a < b, sin B < 1) -> 2 triangle(s)
B= 53.1301 C= 96.8699 c= 9.9282
B= 126.8699 C= 23.1301 c= 3.9282
A=30, a=4, b=8 (a is exactly half b) -> 1 triangle(s)
B= 90.0000 C= 60.0000 c= 6.9282
A=30, a=3, b=8 (a too short to reach) -> 0 triangle(s)
A=30, a=10, b=8 (a >= b) -> 1 triangle(s)
B= 23.5782 C= 126.4218 c= 16.0934
triangle_rules: passed
Block 4 walks the whole table in section 5. Note the third case returns an empty list rather than raising or returning a nonsense triangle — “no triangle exists” is a correct answer, and a solver that hides it is worse than one that says so.
Common pitfalls and traps
- Taking the calculator’s as the only answer. This is the ambiguous case, and it is the single biggest source of lost marks in this topic. Always ask whether also works.
- Using the sine rule when the cosine rule is needed. With SAS, the sine rule has two unknowns in one equation and cannot start. Check what you know before choosing.
- Mislabelling. is the side opposite . Getting this wrong produces a plausible number from a wrong equation.
- Finding the largest angle with the sine rule. Because cannot distinguish an angle from its supplement, resolve the largest angle with the cosine rule — is negative for obtuse angles, so it is unambiguous — then use the sine rule for the rest.
- Heron’s formula on near-degenerate triangles. When a triangle is very thin, is a small difference of large numbers and loses precision catastrophically. A numerically stable variant exists and should be used in production code.
- Forgetting to check . A candidate angle from the sine rule is only a triangle if a positive third angle remains.
Check your understanding
- In triangle , , and . Find .
- In triangle , , and . Find .
- A triangle has sides , , . Find its largest angle, and say why you chose the rule you did.
- Given , , : how many triangles exist? Justify from the table in section 5.
- Find the area of a triangle with sides , , .
Answers — open only after an attempt
- Sine rule: , so .
- Cosine rule (SAS): , so .
- The largest angle is opposite the longest side, . Use the cosine rule: , so . The cosine rule is chosen because the negative cosine identifies the obtuse angle unambiguously — the sine rule could not distinguish from .
- , and . So the fourth row applies: two triangles, with or .
- . Area .
And the prediction from section 4: is an answer, not the answer. Since , also satisfies . With that leaves , so it is a valid triangle. Here , so the table predicts two — and the lab confirms it.
Practice — independent task
Implement solve_triangle(**known) accepting any three of and returning every consistent triangle.
- Dispatch on which three are known: SSS and SAS to the cosine rule; ASA and AAS to the sine rule; SSA to your ambiguous-case handler.
- Return a list, so SSA can return zero, one or two triangles and every other case returns exactly one. A uniform return type avoids a caller forgetting the ambiguous case.
- Reject inconsistent input: angles summing to more than ; sides violating the triangle inequality; AAA (shape without scale — infinitely many similar triangles).
- For every triangle returned, assert both rules hold and the angles sum to .
- Cross-check against coordinates: reconstruct the vertices from your solution, recompute all six quantities from the coordinates, and confirm they match the input to within
1e-9.
Edge cases: the exact-right-angle SSA case where — make sure you return one triangle, not two identical ones; a nearly degenerate triangle with angles like , , — report what precision you actually get; AAA input.
Done when: all five SSA rows from section 5’s table return the predicted count, your coordinate cross-check passes for at least ten triangles, and you can state what your function does with AAA and why that is the right behaviour.
Tradeoffs, limits and extensions
Numerical stability is a real concern here. acos is ill-conditioned near : its derivative is unbounded, so a tiny error in the cosine becomes a large error in the angle for angles near or . For thin triangles, an implementation based on atan2 is considerably more accurate. The lab clamps to before calling acos, which prevents a domain error from rounding, but clamping hides the underlying loss of precision rather than fixing it.
Heron’s formula has a stable variant. Sorting and computing
avoids the cancellation that the textbook form suffers on thin triangles. Kahan’s analysis of this is the standard reference.
Beyond the plane. On a sphere both rules have analogues — the spherical sine and cosine rules — with the sides measured as angles rather than lengths. The spherical cosine rule is what latitude and longitude uses to compute great-circle distances.
Before moving on
You are done with this lesson when you can:
- Derive the sine rule by dropping one perpendicular, and the cosine rule from coordinates.
- Pick the right rule from the known parts without hesitating.
- Work through the ambiguous case and say how many triangles exist before computing them.
- Explain why the largest angle should be found with the cosine rule.
Recap for later lookup: ; , with Pythagoras the case ; ; area . SSA is ambiguous exactly when and the side opposite the known angle is shorter than the adjacent one.
Next: Bearings — these rules applied to navigation, where the angles are measured from north and the triangles are journeys.
Related
- Triangles and Polygons — where SSA was first rejected as a congruence criterion
- Graphs and Identities — the supplement identity that causes the ambiguity
- Circle Theorems — the circumcircle the common ratio measures
- Latitude and Longitude — the spherical versions of both rules
Software engineering
Infrastructure & security
Computer science
Hardware & engineering