Example 1
- a = 3, b = 4, γ = 90°
5
What is c for a=3, b=4, γ=90°? 5 (Pythagoras).
Enter sides a and b and the included angle γ (SAS). The calculator finds the third side c = √(a² + b² − 2ab·cos γ). With 3, 4 and 90° you get 5 — the same 3-4-5 as Pythagoras. With 7, 8 and 120° you get 13. Degrees or radians. This is not an angle from three sides (SSS), and not the ambiguous SSA case.
Enter sides a, b and angle γ.
γ is the included angle between a and b (SAS), not an angle opposite c under SSS labeling. You need a > 0, b > 0. Area from three sides is on Heron’s formula.
The law of cosines generalizes the Pythagorean theorem to an arbitrary included angle. When you know sides a and b and the included angle γ (SAS), the third side opposite γ is c = √(a² + b² − 2ab·cos(γ)). The calculator uses the numbers you enter and the angle-unit switch. In degrees the calculator computes cos(γ·π/180); in radians it uses cos(γ) with no conversion.
At γ = 90° the cosine vanishes and the formula recovers Pythagoras: c² = a² + b². So 3, 4 and 90° give c = 5. An acute angle (e.g. 60°) shortens c versus √(a² + b²); an obtuse angle (e.g. 120°) lengthens c because cosine is negative. With 5, 5 and 60° you get an equilateral triangle, and the calculator shows c = 5.
Domain: a > 0, b > 0, and γ ∈ (0, π) — any other angle gives an error message. The radicand must be non-negative. Period and comma in the fields are equivalent. An empty field leaves the result blank.
A standard derivation places a along an axis, puts the tip of b at (b cos γ, b sin γ), and reads c from the distance formula. Equivalently, the dot product a·b = |a||b|cos γ. Euclid’s Elements II.12–13 treat obtuse and acute cases; the modern trigonometric statement is textbook standard (often called Al-Kashi’s theorem).
The result panel also shows c², cos γ, sin γ, area (½)ab|sin γ|, perimeter, and angle kind. The diagram draws the SAS triangle with side c highlighted. This calculator does not solve SSA or find an angle from three sides — only c from a, b, and γ.
Mathematical model: the law of cosines (Al-Kashi / Euclid II.12–13 in trigonometric form). Not a custom index — just side c from SAS.
c² = a² + b² − 2ab · cos(γ), then c = √(a² + b² − 2ab · cos(γ)).
Symbols: a, b — sides adjacent to the angle; γ — included angle; c — side opposite γ. In degrees: cos(γ°·π/180). In radians: cos(γ) with no conversion.
Model: law of cosines (Al-Kashi; Euclid II.12–13 in trigonometric form). At γ = 90° you recover the Pythagorean theorem.
The law of cosines relates the three sides of a triangle to the cosine of one angle. With sides a, b and included angle γ (opposite side c), c² = a² + b² − 2ab cos γ, hence c = √(a² + b² − 2ab cos γ) when the radicand is nonnegative. This calculator computes side c from SAS data: fields a, b and angle γ (degrees or radians), matching calculator-twierdzenie-cosinusow-bok.js: radicand = a·a + b·b − 2·a·b·cos(rad).
When γ = 90°, cos γ = 0 and the formula reduces to Pythagoras: c² = a² + b². When γ < 90°, cos γ > 0 and c² < a² + b²; when γ > 90°, cos γ < 0 and c² > a² + b². The panel also shows cos γ, sin γ, and area (1/2)ab|sin γ|.
Practical domain: a > 0, b > 0, γ ∈ (0, π). A negative radicand means no real side c for those inputs.
The law of cosines generalizes Pythagoras to an arbitrary angle. Euclidean precursors appear in Elements II.12–13 (acute and obtuse cases separately); the modern cosine form is standard trigonometry (MathWorld — Law of Cosines; Wikipedia — Law of cosines; CRC / Zwillinger).
Conceptually it is the Euclidean metric identity in a triangle: the dot product of sides yields a·b cos γ. This page solves the “side opposite the angle” variant (SAS → third side), not the inverse “angle from three sides” (SSS → arccos).
In navigation and surveying the law links lengths to bearings; in school it bridges geometry and trigonometry.
Domain: a > 0, b > 0, γ ∈ (0, π); a real result needs a² + b² − 2ab cos γ ≥ 0. Codomain: c ≥ 0.
Identities: c² = a² + b² − 2ab cos γ; and cyclic permutations. At γ = π/2: c² = a² + b². SAS area: Δ = (1/2)ab|sin γ|.
Continuity: c(γ) is continuous on (0, π) for fixed a, b > 0. Symmetry: a and b enter symmetrically.
Vector form: if the side vectors from the γ-vertex are u and v, then |u − v|² = |u|² + |v|² − 2 u·v = a² + b² − 2ab cos γ with a = |u|, b = |v|. That matches the coordinate derivation.
Area Δ = (1/2)ab|sin γ| links SAS to altitude; as γ → 0 or γ → π the area vanishes and c tends to |a−b| or a+b respectively. The calculator shows sin and cos beside c so the sign of cosine (acuteness) is visible.
Degree/radian conversion happens before cos. Comma and period parse identically in a, b, and γ fields.
Step 1. Place angle γ at the origin; side a along the x-axis, side b at angle γ. Endpoint of b: (b cos γ, b sin γ); endpoint of a: (a, 0).
Step 2. Distance between endpoints: c² = (b cos γ − a)² + (b sin γ)² = a² + b² − 2ab cos γ.
Step 3. Take c = √(radicand) when radicand ≥ 0. In the calculator: √ after a sign check.
Step 4. Case γ = π/2: cos = 0 ⇒ Pythagoras. Case a = b, γ = π/3: c = a (equilateral).
Worked checks: a = 3, b = 4, γ = 90° → c = 5 (Pythagoras); a = b = 5, γ = 60° → c = 5 (equilateral); a = 7, b = 8, γ = 120° → c = 13. Together they probe cos γ = 0, cos γ > 0, and cos γ < 0 inside c = √(a²+b²−2ab cos γ).
a = 3, b = 4, γ = 90°: c = 5 (3-4-5). a = b = 5, γ = 60°: c = 5 (equilateral). a = 7, b = 8, γ = 60°: c = √57 ≈ 7.549834.
a = 7, b = 8, γ = 120°: cos 120° = −1/2, c = 13. a = 9, b = 12, γ = 90°: c = 15.
When the radicand is negative, the page reports that no real c exists instead of treating NaN as a valid OK result.
The angle is converted to radians before cos. Float64 is enough for school sides; near γ ≈ 0, cancellation toward |a−b| can be sensitive, but typical examples (45°–120°) are stable.
Examples cover 3-4-5, equilateral, and obtuse cases. The SVG scales sides; drawing scale does not change c. A comma and a period are equivalent.
The inverse law cos γ = (a² + b² − c²)/(2ab) recovers an angle from SSS; this page does not take that as the primary result, but the identity is algebraically equivalent after squaring c. If |cos γ| > 1, SSS data do not form a real triangle — analogous to a negative SAS radicand.
Examples 3-4-5 and c = 13 at 120° illustrate opposite cosine signs. An angle γ outside (0, π) is rejected with an error message, even when the radicand would stay non-negative (for example γ = 270° or −60°).
Sides a and b must use a common length unit; c inherits that unit. Degrees and radians apply only to γ. The SVG scales the drawing independently of the numeric result.
Related: law of sines a/sin A = 2R, Pythagoras, third angle γ = 180° − α − β when angles are known.
Authorities: MathWorld — Law of Cosines; Wikipedia — Law of cosines; Euclid II.12–13; CRC / Zwillinger. The calculator computes c = √(a²+b²−2ab cos γ).
c = √(a² + b² − 2ab cos γ). With 3, 4 and 90° side c is 5. With 5, 5 and 60° it is also 5.
5
What is c for a=3, b=4, γ=90°? 5 (Pythagoras).
5
What is c for a=5, b=5, γ=60°? 5 (equilateral).
7.549834
What is c for a=7, b=8, γ=60°? ≈ 7.549834.
13
What is c for a=7, b=8, γ=120°? 13.
5
What do a=5, b=5, γ≈π/3 rad give? 5 (same as 60°).
6
What is c for a=6, b=6, γ=60°? 6 (equilateral).
≈ 7.70918
What is c for a=10, b=4, γ=45°? ≈ 7.70918.
15
What is c for a=9, b=12, γ=90°? 15 (9-12-15).
The missing side c opposite angle γ when you know sides a and b and the included angle γ between them (SAS). Formula: c = √(a² + b² − 2ab·cos(γ)). For a = 3, b = 4 and γ = 90° the result is 5. This page does not solve SSA or find an angle from three sides.
In “Angle in”, choose Degrees (°) or Radians. Degrees: the calculator multiplies γ by π/180 before cosine. Radians: cosine uses γ with no conversion. Example 5: a = 5, b = 5, γ ≈ π/3 rad gives the same c as 60°.
When γ = 90° (π/2 rad), cos γ = 0, so the −2ab·cos(γ) term vanishes and you are left with c² = a² + b². For 3, 4 and 90° the calculator returns c = 5 — the same 3-4-5 triangle.
The included angle γ between sides a and b (the third field). That is the angle at the common vertex of those sides, not an “opposite c” angle under another SSS labeling. The field is labeled “Angle γ”.
You need a > 0 and b > 0. The angle γ must lie in (0, π). At γ = 0 or π the figure collapses to a segment, and an angle outside that range is not a triangle angle — the calculator then reports an error. The expression under the square root must be non-negative — otherwise a real side c does not exist.
An empty a, b, or angle leaves the result blank. A side ≤ 0 is rejected with a message — side length in this model must be positive.
Yes. For γ > 90° cosine is negative, so −2ab·cos(γ) adds to a² + b² and c is longer than for an acute angle with the same a, b. For 7, 8 and 120° the result is 13; for 7, 8 and 60° ≈ 7.549834.
No. This page uses two sides and the included angle (SAS). SSA, where two sides and a non-included angle can yield two triangles, is not here. The ratio a/sin α = b/sin β is on the law of sines page.
No. The result depends only on a, b, the angle, and the degrees/radians switch in the form. The currency and unit settings in the page header do not affect this result.
Area from three sides is on Heron’s formula. A side from one side and two angles is on the law of sines. Pythagoras is nearby when the angle is right and you know the two legs.
On paper cos 60° = 1/2 exactly, so c = 5. In floating-point arithmetic cos(60·π/180) returns 0.5000000000000001, so the raw square root is 4.999999999999999. The calculator rounds the result to six decimal places and drops trailing zeros, so you see 5.
From projecting one side onto the other and applying Pythagoras in right triangles, or from the distance formula / dot product in coordinates. Euclid II.12–13 covers obtuse and acute cases; the modern trigonometric form is Al-Kashi’s theorem in standard trig texts.
With two sides a, b and included angle γ: c = √(a² + b² − 2ab·cos γ). For 3, 4 and 90°, c = 5; for 7, 8 and 120°, c = 13.
√39 ≈ 6.244998. Formula: c = √(25 + 49 − 2·5·7·cos 60°) = √(74 − 35) = √39.
No. Here you only get side c from SAS. The SSS angle is γ = arccos((a² + b² − c²)/(2ab)) — a separate rearrange, not on this page.
Here two sides and the included angle give the third side. The law of sines links a side to the sine of the opposite angle (a/sin α = b/sin β) and covers AAS/ASA cases.
13. That is the fourth example on this page: an obtuse angle lengthens c versus the 60° version.
The formula, derivation, and history below come from recognized sources.
Page updated November 3, 2026.