Free Law of Cosines Calculator
Use the law of cosines to solve any triangle. Choose SAS to find a missing side, or SSS to find all angles.
Enter values above to solve the triangle using the law of cosines.
The Cosine Rule in Action
The law of cosines (also known as the cosine rule) is a cornerstone of triangle geometry. It connects the three sides of any triangle to the cosine of one of its angles, making it possible to solve a triangle using the law of cosines in two common situations: when you know two sides and the included angle (SAS triangle) or when you know all three sides (SSS triangle). A dedicated triangle side calculator automates the computations, saving time and eliminating manual mistakes. This article explains everything you need to know about the formula, its origins, how to apply it, and how to get the most out of an online law of cosines calculator.
The Core Formula
For a triangle with sides labeled , , and corresponding angles , , (where faces , faces , faces ), the law of cosines gives three equivalent equations:
Each formula follows the same pattern: the square of one side equals the sum of the squares of the other two sides minus twice their product times the cosine of the angle between them. When that angle is , its cosine is zero and the rule collapses to the Pythagorean theorem. For instance, if , then . This shows that the cosine rule is a true generalization of Pythagoras’ theorem, extending it to all triangles.
A Brief History
The concept behind the law of cosines dates back to Euclid’s Elements (approximately 300 BC), where it was presented in geometric form without the use of trigonometric functions. The first explicit algebraic statement appeared in the 15th century in the work of Persian mathematician Jamshīd al‑Kāshī. François Viète, a French mathematician, later introduced the rule to European mathematics in the 16th century. The modern notation using the cosine function solidified in the 19th century.
Solving Triangles with the Law of Cosines
The law of cosines is essential for solving triangles when the given information fits the SAS or SSS patterns. An online triangle side calculator that implements these cases can handle most real‑world triangle problems.
SAS (Side‑Angle‑Side)
If you know two side lengths, say and , and the angle between them, you can find the third side with:
Analogous formulas work for the other sides. The SAS configuration always yields one unique triangle (provided the given angle is between and ). Once you have the third side, you can apply the law of cosines again or switch to the law of sines to find the remaining angles.
SSS (Side‑Side‑Side)
When all three side lengths are known but no angles are given, you can compute any angle using the inversed cosine rule:
These equations produce angles in the range . As long as the three sides satisfy the triangle inequality, the angles will sum to . This SSS case is also unique.
The SSA Ambiguity
The law of cosines can be applied to the SSA (side‑side‑angle) situation, but the outcome is not always definite. Depending on the values there may be zero, one, or two possible triangles. Because of this ambiguity, our free online triangle solver does not include the SSA case; it focuses on the unambiguous SAS and SSS options, guaranteeing a single correct answer.
How the Calculator Works
Using this law of cosines calculator is straightforward:
- Choose your scenario – Select “SAS” or “SSS” from the dropdown.
- Enter the known values – Fill in the side lengths (and the angle, for SAS) as required. The diagram on the screen helps you map your data to the correct fields.
- Get the result – For SAS, the calculator shows the missing side; for SSS, it displays all three angles. Many tools also provide an intermediate step or show the triangle visually.
The calculator automatically checks the validity of the triangle. If the given sides violate the triangle inequality (for example, ), you will receive an error message. It also handles unit conversions, allowing you to work in inches, centimeters, meters, or any other length unit.
Worked Examples
Example 1: SSS Angles
Consider a triangle with sides , , . To find the angle opposite :
Repeating the procedure gives and . The sum , confirming the solution.
Example 2: SAS Side
Suppose you have , , and the included angle . The missing side is:
Now you have an SSS triangle (, , ), so you can find the remaining angles using the SSS formulas if needed.
Proofs of the Law of Cosines
Understanding why the law of cosines holds deepens your grasp of trigonometry. Here are two accessible proofs.
Altitude‑Based Proof
Drop a perpendicular from the vertex where angle lies onto side . This divides the triangle into two right triangles. Denote the foot of the altitude and apply the Pythagorean theorem to each right triangle. Express the segment adjacent to angle using the cosine function: it equals (or an analogous expression). After eliminating common terms, the law of cosines emerges. This method is essentially the one found in Euclid’s work, adapted to modern notation.
Coordinate Geometry Proof
Place the triangle with vertex at , vertex at , and vertex at . Here is the angle at . The side (opposite ) is the distance between and :
Since , this simplifies to . The same reasoning works for the other two formulas.
Both proofs are valid for acute, right, and obtuse triangles, demonstrating the universal nature of the cosine rule.
Practical Applications
The law of cosines is more than a textbook formula. Surveyors use it to calculate distances between points that are not directly measurable. Navigators apply it to determine the great‑circle distance between two locations on Earth. In physics, the rule helps decompose forces and velocities when vectors are not perpendicular. Engineers rely on it for structural analysis and design. Having a fast triangle side calculator at your fingertips allows you to handle these tasks efficiently without manual calculations.
Tips for Accurate Use
- Check the angle unit – Make sure your angle is in degrees or radians, as the calculator expects.
- Verify triangle validity – The sum of any two sides must exceed the third. The calculator will warn you if the input is impossible.
- Use consistent units – All side lengths should be in the same unit before entering.
- Interpret results correctly – For SSS, the angles are given in the range to . If an angle is greater than , the triangle is obtuse.
Conclusion
The law of cosines calculator — a free online triangle solver — makes it easy to solve a triangle using the law of cosines whether you have an SAS triangle or an SSS triangle. By automating the cosine rule formulas, it gives you accurate results in seconds. Try it with your own numbers and discover how simple triangle solving can be.
FAQ
1. What is the law of cosines formula?
For a triangle with sides a, b, c and opposite angles α, β, γ, the law states: a² = b² + c² − 2bc·cos(α); b² = a² + c² − 2ac·cos(β); c² = a² + b² − 2ab·cos(γ). Choose the equation that contains the side you want to find.
2. How do I use the calculator for an SAS triangle?
Select the SAS option, enter the two sides and the included angle (in degrees or radians), then click calculate. The tool will give you the third side using the formula c = √(a² + b² − 2ab·cos(γ)).
3. How do I find all three angles from three side lengths?
Use the SSS option. Enter the three side lengths. The calculator applies the inverse cosine formula (α = arccos[(b² + c² − a²)/(2bc)]) to each angle and shows you the results.
4. Why is the SSA case not included in the calculator?
SSA is ambiguous — depending on the data, there can be 0, 1, or 2 possible triangles. To avoid confusion, the calculator only handles the unambiguous SAS and SSS cases.
5. Does the law of cosines work for right triangles?
Yes. When the angle is 90°, cos(90°) = 0, so the formula becomes a² = b² + c², which is the Pythagorean theorem. The law of cosines is a generalization of Pythagoras' theorem.
How to Use
- Choose between SAS (two sides and the included angle) or SSS (three sides) mode.
- Enter the known values for sides a, b, and angle γ (SAS) or sides a, b, c (SSS).
- The calculator instantly applies the law of cosines to compute the missing side and all angles, or all three angles for SSS.