코사인 법칙 계산기
결과
코사인 법칙 계산기에서 사용된 공식
In-Depth Tutorial: 코사인 법칙 계산기
코사인 법칙은 삼각형을 푸는 두 가지 보편적인 도구 중 두 번째로, 사인 법칙과 함께 사용됩니다. 사인 법칙이 AAS, ASA, SSA 경우(일치하는 변과 각의 쌍을 가짐)에 적용되는 반면, 코사인 법칙은 일치하는 변과 각의 쌍이 없는 경우에 적용됩니다: SSS(세 변)와 SAS(두 변과 그 사이각). 또한 사이각이 90°일 때 피타고라스 정리로 축소되므로, 모든 삼각형에 대한 피타고라스 정리의 자연스러운 일반화입니다. 이 튜토리얼에서는 코사인 법칙의 진술, 증명, 사인 법칙과의 사용 시기 비교, 그리고 SSS 및 SAS 사례에 대한 풀이 예제를 다룹니다.
코사인 법칙의 진술
변이 a, b, c이고 변 c의 대각이 C인 모든 삼각형에 대해 다음이 성립합니다:
c² = a² + b² − 2ab · cos(C)
대칭성에 의해 다른 두 각에 대해서도 변수명을 바꾸면 동일한 관계가 성립합니다:
- a² = b² + c² − 2bc · cos(A)
- b² = a² + c² − 2ac · cos(B)
- c² = a² + b² − 2ab · cos(C)
세 변의 길이로부터 각을 구하려면 cos(C)에 대해 식을 정리합니다:
cos(C) = (a² + b² − c²) / (2ab)
피타고라스 정리와의 연관성
C = 90°일 때, cos(C) = 0이 되며 공식은 다음과 같이 축소됩니다:
c² = a² + b² − 2ab · 0 = a² + b²
이는 바로 피타고라스 정리입니다. 따라서 코사인 법칙은 엄밀한 일반화로, 어떤 삼각형에도 적용되며, −2ab·cos(C) 항은 직각삼각형이 될 때 소멸되는 '보정' 역할을 합니다.
이 보정항의 부호는 삼각형의 형태에 대한 정보도 제공합니다:
- cos(C) > 0 (C는 예각, < 90°): 보정항이 양수이므로 c² < a² + b² (c는 피타고라스 정리가 예측하는 길이보다 짧음). 삼각형은 C에서 예각입니다.
- cos(C) = 0 (C는 정확히 90°): 보정항이 소멸함. C에서 직각삼각형.
- cos(C) < 0 (C는 둔각, > 90°): 보정항이 음수이므로 c² > a² + b² (c는 피타고라스 정리가 예측하는 길이보다 김). C에서 둔각임.
이는 위장된 피타고라스 정리의 역정리 테스트입니다.
좌표계를 이용한 증명
좌표 평면에 삼각형을 놓습니다: 꼭짓점 A를 원점에 두고, 변 AB를 양의 x축 위에 길이 c로 놓으며, 꼭짓점 B를 (c, 0)으로 둡니다. 꼭짓점 C는 x축 위에 어딘가에 위치시킵니다.
각 A와 변 b(A에서 C까지의 길이)로부터, C의 좌표는 다음과 같습니다:
C = (b · cos(A), b · sin(A))
세 번째 변 a는 B = (c, 0)에서 C = (b·cos(A), b·sin(A))로 이어집니다. 거리 공식을 적용합니다:
a² = (b·cos(A) − c)² + (b·sin(A))²
= b²cos²(A) − 2bc·cos(A) + c² + b²sin²(A)
= b²(cos²(A) + sin²(A)) − 2bc·cos(A) + c²
= b² + c² − 2bc·cos(A)
중간 단계에서 피타고라스 항등식 cos² + sin² = 1을 사용했습니다. 결과가 코사인 법칙입니다.
코사인 법칙과 사인 법칙 중 언제 사용할까?
| 알고 있는 것 | 사용할 법칙 |
|---|---|
| SSS (세 변) | 코사인 법칙 (어떤 각이든 구하기 위해) |
| SAS (두 변과 사이각) | 코사인 법칙 (세 번째 변 구하기 위해) |
| ASA (두 각과 사이변) | 사인 법칙 (세 번째 각 계산 후) |
| AAS (두 각과 비사이변) | 사인 법칙 (세 번째 각 계산 후) |
| SSA (두 변과 비사이각) | 사인 법칙 — 모호한 경우 주의 |
기억법: 아직 일치하는 변과 각의 쌍이 알려지지 않았을 때는 코사인 법칙을 사용하십시오. 그런 다음 필요시 한 쌍이 생기면 사인 법칙으로 전환합니다.
풀이 예제 — SSS
변 a = 5, b = 7, c = 9인 삼각형. 세 각을 모두 구하시오.
먼저 C를 구합니다 (가장 긴 변의 대각이며, 일반적으로 가장 안전함):
cos(C) = (5² + 7² − 9²) / (2 · 5 · 7) = (25 + 49 − 81) / 70 = −7/70 = −0.1
C = arccos(−0.1) ≈ 95.74° (c² > a² + b²이므로 예상대로 둔각).
다음으로 A를 구합니다:
cos(A) = (7² + 9² − 5²) / (2 · 7 · 9) = (49 + 81 − 25) / 126 = 105/126 ≈ 0.8333
A = arccos(0.8333) ≈ 33.56°.
세 번째 각: B = 180° − 95.74° − 33.56° = 50.70°. (B에 대해 코사인 법칙으로 검증할 수 있지만, 합이 180°가 되는지 확인하는 것이 더 빠릅니다.)
풀이 예제 — SAS
변 a = 8, b = 10, 그리고 사이각 C = 60°인 삼각형. 변 c를 구하시오.
c² = 8² + 10² − 2(8)(10)cos(60°) = 64 + 100 − 160(0.5) = 164 − 80 = 84
c = √84 ≈ 9.17.
그런 다음 다른 각들을 구하기 위해 사인 법칙으로 전환합니다:
sin(A) / 8 = sin(60°) / 9.17
sin(A) = 8 · sin(60°) / 9.17 ≈ 8 · 0.866 / 9.17 ≈ 0.755
A = arcsin(0.755) ≈ 49.11°.
B = 180° − 60° − 49.11° = 70.89°.
왜 코사인 법칙에는 '모호한 경우'가 없는가?
SSS의 경우, 세 변은 삼각형을 유일하게 결정합니다 (합동까지 고려하면). 코사인 법칙은 cos(C)를 직접 계산하며, arccos는 (0°, 180°) 범위에서 유일한 각을 반환합니다. 모호함이 없습니다.
SAS의 경우, 각이 주어졌으므로 세 번째 변은 유일하게 결정됩니다. 역시 모호함이 없습니다.
반면 SSA(사인 법칙으로 처리됨)의 경우: arcsin은 두 보각 중 하나를 반환하므로, 유효한 것을 수동으로 선택해야 합니다. 코사인 법칙은 관련 범위에서 단일 값을 갖는 arccos를 사용하므로 이를 피합니다.
벡터 형태의 일반화
코사인 법칙은 내적의 기하학적 진술이기도 합니다. 두 벡터 u와 v 사이의 각이 θ일 때:
u · v = |u| · |v| · cos(θ)
전개하고 정리하면: u와 v가 각 θ에서 만나는 삼각형의 두 변이라면, 세 번째 변 w = v − u는 |w|² = |v|² + |u|² − 2|u||v|cos(θ)를 만족합니다. 이는 정확히 코사인 법칙입니다.
이것이 코사인 법칙이 고차원 기하학으로 자연스럽게 확장되는 이유입니다: 그것은 위장된 내적 공식이기 때문입니다.
흔한 실수
- −2ab·cos(C) 항의 부호 오류. 일부 학생들은 +2ab·cos(C)로 씁니다. 공식에는 2ab·cos(C) 앞에 마이너스 부호가 있습니다. 이는 피타고라스 정리로의 축소 과정에서 확인됩니다 (C = 90°일 때 cos(C) = 0이므로 항이 소멸하며, 만약 부호가 +였다면 공식이 올바르게 축소되지 않을 것입니다).
- 예각에만 sin/cos 표를 사용하는 것. 코사인 법칙은 둔각 삼각형을 포함한 모든 삼각형에 적용됩니다. 둔각의 cos 값은 음수이며, 음수의 arccos는 (90°, 180°) 범위의 각을 반환합니다. 공식은 이를 자동으로 처리합니다.
- 어떤 변이 c인지 혼동하는 것. 공식 c² = a² + b² − 2ab·cos(C)는 C가 c의 대각이어야 하며, a와 b가 C에 인접한 두 변이어야 함을 요구합니다. 이 매칭을 잘못하면 공식은 무의미한 결과를 줍니다.
- c에 대한 제곱근을 잊는 것. 공식은 c²을 제공합니다. c가 아닙니다. 마지막에 √를 적용해야 합니다.
자주 묻는 질문 – 코사인 법칙 계산기
SSS(3변의 길이를 알고 각을 구하는 경우)와 SAS(2변과 그 사이각을 알고 나머지 한 변을 구하는 경우)에 사용하십시오. 사인 법칙이 모호한 경우에도 처리할 수 있습니다.
c² = a² + b² − 2ab·cos(C). 각을 구하려면: cos(C) = (a² + b² − c²) / (2ab).
C = 90°일 때, cos(C) = 0이 되어 공식은 c² = a² + b²로 단순화되며, 이는 고전적인 피타고라스 정리에 해당합니다.
네 — 무료이며 무제한입니다.
The Law of Cosines is also the triangle inequality and the type test
The formula c² = a² + b² − 2ab·cos(C) isn't only a tool for solving triangles. It encodes two of the most important existence facts about triangles, both of which fall out by inspecting the cosine term.
Triangle type from three sides alone. Once you have a, b, c, the sign of a² + b² − c² tells you what kind of triangle you have without computing any angle. If a² + b² > c², the triangle is acute at C. If a² + b² = c², the triangle is right-angled at C (the Pythagorean theorem case). If a² + b² < c², the triangle is obtuse at C. Apply the same test to the other two vertices to fully classify the triangle in three quick arithmetic checks — much faster than computing all three angles via arccos.
The triangle inequality is a corollary. The cosine of any real angle satisfies −1 ≤ cos(C) ≤ 1. Substituting both extremes into the Law of Cosines:
If cos(C) = 1 (C approaches 0°): c² = a² + b² − 2ab = (a − b)², so c = |a − b|.
If cos(C) = −1 (C approaches 180°): c² = a² + b² + 2ab = (a + b)², so c = a + b.
A "real" triangle has C strictly between 0° and 180°, so |a − b| < c < a + b. That's the triangle inequality, and it's a direct consequence of the cosine of any real angle living in [−1, 1]. The calculator returns an error for inputs violating these bounds because no triangle with those side lengths exists.
Where this law shows up in working engineering
The Law of Cosines is the workhorse of any system that measures distances from known reference points and back-solves for an unknown location.
GPS trilateration. A GPS receiver doesn't measure angles to satellites — it measures the time radio signals take to arrive. Multiplying time by the speed of light gives the receiver's distance to each satellite. From at least four satellites at known positions, the receiver computes its own position by solving a system of equations whose individual two-satellite cases are Law-of-Cosines statements: the receiver, one satellite, and another satellite form a triangle whose three sides are the inter-satellite distance (known from orbital data) and the two satellite-to-receiver distances (measured). Solving gives the angle the receiver subtends, which combined across multiple pairs fixes its 3D position.
Surveyor's resection. If you're at an unknown point and can sight three landmarks whose positions are known (e.g., three church spires on a topographic map), you can compute your own coordinates by measuring the bearings to each landmark and applying the Law of Cosines to the triangles formed. This is how 19th-century surveyors located themselves before GPS and how modern surveyors still verify GPS results in places where satellite reception is poor (urban canyons, dense forest, mining tunnels).
Crystallography. X-ray diffraction patterns from crystals encode the lattice spacings, but the formulas that convert observed diffraction angles to unit-cell parameters reduce to the Law of Cosines applied to vectors in the reciprocal lattice. The 14 Bravais lattice types are classified largely by what the cosine relations between the three lattice vectors look like — equality, perpendicularity, or general parallelepiped.
Practical questions about applying the formula
Why is the Law of Cosines numerically better-behaved than Law of Sines for SSS problems?
Because arccos is single-valued on its natural domain [−1, 1], returning an angle in [0°, 180°] uniquely. Arcsin has the same return range only after you decide whether the angle is acute or obtuse — both produce the same sine. For SSS, arccos directly gives the correct angle in one step; arcsin would require a sign-check afterward. The arithmetic precision is also more forgiving: the operation (a² + b² − c²)/(2ab) stays well-conditioned unless the angle is extremely close to 0° or 180° (a "degenerate" near-straight triangle), in which case both a² + b² and c² are nearly equal and their difference loses precision. For typical inputs this is invisible.
What happens if I enter three sides that can't form a triangle?
The expression (a² + b² − c²)/(2ab) falls outside [−1, 1], so arccos returns NaN (not a number) and the calculator returns an error. Geometrically, this means the longest side is longer than the sum of the other two (or equal to it), which would require the triangle to be degenerate — flattened into a line segment with no enclosed area. Always run the triangle inequality check first as a sanity test: each side must be strictly less than the sum of the other two.
Is there a version of the Law of Cosines for higher-dimensional shapes?
Yes. The polarization identity for inner-product spaces — 2(u · v) = |u + v|² − |u|² − |v|² — is the Law of Cosines in vector form. It works in any number of dimensions and in any inner-product space (function spaces, Hilbert spaces). For an n-dimensional simplex (the higher-dim analog of a triangle), there's a generalized Law of Cosines that relates the squared lengths of edges and the squared volumes of faces. These come up in computational geometry and theoretical physics rather than everyday geometry, but the planar Law of Cosines is their direct ancestor.
The formula has Pythagoras as a special case — what's the deeper relationship?
Both are statements about the dot product, but at different specificity. The Pythagorean theorem says |u + v|² = |u|² + |v|² exactly when u · v = 0 (perpendicular vectors). The Law of Cosines drops the perpendicularity requirement and adds back the −2(u · v) = −2|u||v|cos(θ) term to account for non-orthogonality. So Pythagoras is the Law of Cosines restricted to right triangles, and the Law of Cosines is Pythagoras plus a correction for the angle. Once you internalize the dot product, both formulas are the same statement.