Mathematics RU

Solver

Triangle solver: sides, angles and area, with working and a drawing

Give three elements of a triangle, and the solver finds the rest with the sine and cosine rules, sorts out the case of two solutions and draws the triangle to scale.

Loading the solver…

What you can type

There are six fields above the input line: three sides and three angles. Fill in any three, at least one of them a side, and the solver finds the rest, draws the triangle to scale and computes the area, perimeter, altitudes, medians, angle bisectors and the radii of the inscribed and circumscribed circles. The notation is the usual one: side $a$ is opposite angle $A$, side $b$ opposite $B$, side $c$ opposite $C$. You can also use vertices: $AB = c$, $BC = a$, $AC = b$, and an angle as $\angle B$ or “angle ABC”.

As a line of text, a problem looks like this: “a = 5, b = 7, C = 60°”, “AB = 6; BC = 8; ∠B = 30°”. Three unlabelled numbers are taken as three sides. Angles are in degrees, optionally with minutes (40°30′), or in terms of $\pi$ (π/3); lengths can be integers, decimals, fractions or roots (2√3). For a right-angled triangle, “legs 3 and 4” or “hypotenuse 13, leg 5” works too.

Which three elements determine a triangle

The congruence criteria from school geometry answer exactly this question: if two triangles agree in certain three elements, they agree completely, which means the triangle can be reconstructed from those elements. Three sides (SSS); two sides and the angle between them (SAS); a side and two angles (ASA). Each case has its own route.

  • Three sides. Find the angles with the cosine rule. First check the triangle inequality: the longest side must be shorter than the sum of the other two.
  • Two sides and the angle between them. The cosine rule gives the third side, and the problem reduces to the previous one.
  • A side and two angles. The third angle comes from the sum of $180^\circ$, the sides from the sine rule.
  • Two sides and an angle not between them. There’s no congruence criterion for this case, and not by accident: there may be two triangles, one, or none. This case is treated separately below.
  • Three angles. They fix only the shape: the triangle can be scaled up any number of times without changing its angles. In this case the solver finds the ratio of the sides.

The cosine rule

The square of the side opposite angle $C$. The sum of the squares of the other two sides, what Pythagoras’ theorem would give. The correction for the angle. When $C = 90^\circ$ the cosine is zero, and Pythagoras’ theorem is what’s left. For an acute angle the cosine is positive and side $c$ is shorter than the “Pythagorean” one; for an obtuse angle the cosine is negative and the side is longer. Example: $a = 5$, $b = 7$, $C = 60^\circ$. Then $c^2 = 25 + 49 - 2 \cdot 5 \cdot 7 \cdot \frac12 = 39$, $c = \sqrt{39} \approx 6.245$.

Why it’s true. Put the vertex $C$ at the origin and lay the side $CA$ along the $x$-axis: $A = (b, 0)$. The vertex $B$ is at distance $a$ from $C$, at angle $C$ to the axis: $B = (a\cos C, a\sin C)$. By Pythagoras’ theorem the square of the distance between $A$ and $B$ is $(a\cos C - b)^2 + a^2\sin^2 C = a^2(\cos^2 C + \sin^2 C) - 2ab\cos C + b^2$, and $\cos^2 C + \sin^2 C = 1$. That’s exactly the formula above, for acute and obtuse angles alike.

The same formula gives an angle from three sides: $\cos C = \frac{a^2 + b^2 - c^2}{2ab}$. Between $0^\circ$ and $180^\circ$ the cosine takes each value only once, so the inverse cosine gives the angle unambiguously. That’s why the solver finds angles through cosines rather than sines.

The sine rule

A side of the triangle. The sine of the angle opposite it. The diameter of the circumscribed circle: the same number for all three ratios. Example: $A = 30^\circ$, $B = 45^\circ$, $a = 10$. Then $\frac{a}{\sin A} = \frac{10}{1/2} = 20$, and $b = 20 \sin 45^\circ = 10\sqrt2 \approx 14.14$.

The proof takes one line. The area of a triangle is half the product of two sides times the sine of the angle between them, and it can be computed in three ways: $S = \frac12 ab\sin C = \frac12 bc\sin A = \frac12 ca\sin B$. Divide all three expressions by $\frac12 abc$ and you get $\frac{\sin C}{c} = \frac{\sin A}{a} = \frac{\sin B}{b}$. That the common ratio equals $2R$ follows from the inscribed angle theorem.

Two sides and an angle not between them: none, one or two

Suppose we know an acute angle $A$, the adjacent side $b$ and the side $a$ opposite the angle. Draw the angle $A$ and mark off $AC = b$ along one of its arms. Side $a$ starts at $C$ and has to reach the other arm of the angle, so $B$ lies on a circle of radius $a$ centred at $C$. The shortest distance from $C$ to that line is the height $h = b\sin A$.

  • $a < h$: the circle doesn’t reach the line, and there’s no triangle.
  • $a = h$: it touches at one point, and there’s one triangle, right-angled.
  • $h < a < b$: the circle crosses the ray at two points, and there are two triangles, one with an acute and one with an obtuse angle $B$.
  • $a \ge b$: the second crossing point falls beyond the vertex $A$, and there’s one triangle.

If the angle $A$ is right or obtuse, it’s the largest angle in the triangle, and the side $a$ opposite it must be the longest: when $a > b$ there’s one triangle, otherwise there’s none.

Algebraically this shows up in the sine rule: $\sin B = \frac{b\sin A}{a}$. If the sine is greater than one, there are no solutions. If it’s less, both $B$ and $180^\circ - B$ fit, since they have the same sine; the second option works only if, together with $A$, it’s less than $180^\circ$. A calculator’s inverse sine always returns the acute angle and loses the obtuse option, and that’s the most common mistake in such problems. The solver checks both and draws the construction with the circle.

If one angle is a right angle, everything is simpler: the hypotenuse lies opposite it, and the sine and cosine rules turn into definitions. Pythagoras’ theorem $c^2 = a^2 + b^2$ links the sides; the sine of an acute angle is the opposite leg over the hypotenuse, the cosine is the adjacent leg over the hypotenuse, and the tangent is opposite over adjacent. The acute angles add up to $90^\circ$. The area is half the product of the legs.

Area, altitudes, medians, circles

Once the sides and angles are known, the rest comes from ready-made formulas, and the solver puts them in a table. The area is $S = \frac12 ab\sin C$, or by Heron’s formula $S = \sqrt{p(p-a)(p-b)(p-c)}$, where $p$ is the semi-perimeter. The altitude to side $a$ is $h_a = \frac{2S}{a}$. The median is $m_a = \frac12\sqrt{2b^2 + 2c^2 - a^2}$. The circumradius is $R = \frac{a}{2\sin A}$, the inradius is $r = \frac{S}{p}$. The buttons above the drawing show the altitudes, medians, angle bisectors and both circles.

Worked examples

Example 1. Two sides and the angle between them: $a = 5$, $b = 7$, $C = 60^\circ$

By the cosine rule, $c^2 = 25 + 49 - 2 \cdot 5 \cdot 7 \cdot \frac12 = 39$, $c = \sqrt{39} \approx 6.245$. The angle opposite the smaller side $a$ is acute: $\cos A = \frac{b^2 + c^2 - a^2}{2bc} = \frac{49 + 39 - 25}{14\sqrt{39}} \approx 0.7206$, $A \approx 43.9^\circ$. The third angle: $B = 180^\circ - 60^\circ - 43.9^\circ \approx 76.1^\circ$. The area: $S = \frac12 \cdot 5 \cdot 7 \cdot \frac{\sqrt3}{2} = \frac{35\sqrt3}{4} \approx 15.16$.

Example 2. Three sides: $a = 7$, $b = 8$, $c = 9$

The triangle inequality holds: $9 < 7 + 8$. The largest angle is opposite the longest side: $\cos C = \frac{49 + 64 - 81}{2 \cdot 7 \cdot 8} = \frac{32}{112} = \frac27$, $C \approx 73.40^\circ$, which is acute, so the triangle is acute-angled. Next, $\cos A = \frac{64 + 81 - 49}{2 \cdot 8 \cdot 9} = \frac23$, $A \approx 48.19^\circ$, and $B \approx 58.41^\circ$. By Heron, $p = 12$, $S = \sqrt{12 \cdot 5 \cdot 4 \cdot 3} = \sqrt{720} = 12\sqrt5 \approx 26.83$.

Example 3. Two triangles: $a = 6$, $b = 10$, $A = 30^\circ$

The height is $h = b\sin A = 5$, and $5 < 6 < 10$, so we expect two solutions. By the sine rule, $\sin B = \frac{10 \cdot \frac12}{6} = \frac56$, so $B_1 \approx 56.44^\circ$ or $B_2 = 180^\circ - B_1 \approx 123.56^\circ$. Both work: $30^\circ + 123.56^\circ < 180^\circ$. For the first, $C_1 \approx 93.56^\circ$ and $c_1 = \frac{6 \sin C_1}{\sin 30^\circ} \approx 11.98$; for the second, $C_2 \approx 26.44^\circ$ and $c_2 \approx 5.34$.

Example 4. Right-angled: hypotenuse $c = 10$, acute angle $A = 30^\circ$

The leg opposite the $30^\circ$ angle is half the hypotenuse: $a = c\sin 30^\circ = 5$. The other leg is $b = c\cos 30^\circ = 5\sqrt3 \approx 8.66$, and the other acute angle is $B = 60^\circ$. The area is $S = \frac12 ab = \frac{25\sqrt3}{2} \approx 21.65$.

Common mistakes

  • Mixing up which side is opposite which angle. In the sine and cosine rules, side $a$ always goes with angle $A$, the one opposite it. $BC$ is $a$, not $b$.
  • Losing the second triangle. With two sides and an angle not between them, the inverse sine gives only the acute angle, while the obtuse $180^\circ - B$ may fit too.
  • A calculator in radians. $\cos 60$ in radians is about $-0.95$, not $\frac12$. Check that you’re in DEG mode.
  • Losing the sign of the cosine of an obtuse angle. For $C = 120^\circ$, $\cos C = -\frac12$, and the last term in the cosine rule is added: $c^2 = a^2 + b^2 + ab$.
  • Finding an angle through its sine when it might be obtuse. The sines of $50^\circ$ and $130^\circ$ are equal. It’s safer to find an angle from three sides through its cosine.
  • Not checking the triangle inequality. Sides 1, 2 and 4 don’t make a triangle: $1 + 2 < 4$. Heron’s formula then gives the square root of a negative number.
  • Rounding intermediate results. Round $c \approx 6.2$ and carry on with it, and the angles drift by tenths of a degree. Keep intermediate numbers exact; the solver does, keeping $\sqrt{39}$ right to the end.

See also

Congruence criteria, the triangle inequality, medians, angle bisectors and the notable points with the Euler line are in the chapter on the triangle. Sine, cosine and tangent on the unit circle, the sine and cosine rules, and how they were used to measure the Earth are in the chapter on trigonometry. If a problem leads to an equation like $\sin x = \frac56$ and you need all its solutions, the trigonometric equation solver will help, and the quadratic equation that the cosine rule gives for an unknown side is solved by the quadratic equation solver.

Where this is explained

Other solvers