Understanding the line intersection calculator — concept and principle
Two straight lines in a plane either cross at exactly one point, never meet (parallel) or lie on top of each other (identical). This calculator takes two lines written as a₁x + b₁y = c₁ and a₂x + b₂y = c₂, finds their intersection point and gives the angle between them. This is the same as solving a system of two linear equations, as in break-even or supply and demand problems.
How it is calculated
- Determinant: D = a₁b₂ − b₁a₂.
- Intersection (Cramer's rule): x = (c₁b₂ − b₁c₂) ÷ D, y = (a₁c₂ − c₁a₂) ÷ D.
- If D = 0: the lines are parallel or identical, and there is no single intersection.
- Angle: θ = |atan2(a₁b₂ − a₂b₁, a₁a₂ + b₁b₂)| in degrees, the angle between the lines' normal vectors (a₁, b₁) and (a₂, b₂).
The principle
Each equation describes all points that satisfy it, and the intersection is the one point that satisfies both. Cramer's rule solves the system by eliminating one variable: multiply the first equation by b₂ and the second by b₁, subtract, and y drops out, leaving D × x = c₁b₂ − b₁c₂. The determinant D measures how differently the two lines are oriented. When D = 0 the coefficients are proportional, the lines point in the same direction, and no unique solution exists.
For the angle, the vector (a, b) is perpendicular to its line, so the angle between the two normals equals an angle between the lines. The atan2 of the cross product over the dot product gives that angle robustly, from 0° to 180°.
Worked example
- Inputs: x − y = 1 and 2x + y = 8.
- D = 1 × 1 − (−1) × 2 = 3.
- x = (1 × 1 − (−1) × 8) ÷ 3 = 9 ÷ 3 = 3; y = (1 × 8 − 1 × 2) ÷ 3 = 6 ÷ 3 = 2. Intersection (3, 2).
- Angle: atan2(1 × 1 − 2 × (−1), 1 × 2 + (−1) × 1) = atan2(3, 1) ≈ 71.56505118°.
How to read the result
The intersection is the only pair (x, y) that makes both equations true, such as the price and quantity where supply equals demand. An angle of 90° means the lines are perpendicular. The output may exceed 90°; the acute angle between the lines is then 180° minus the shown value. A very small D compared with the coefficients means the lines are nearly parallel, so tiny changes in the inputs move the intersection a long way.
Common mistakes
- Entering a line in slope form y = mx + k directly. Rewrite it as −mx + y = k, so a = −m, b = 1, c = k.
- Mixing up the sign of c: this calculator uses ax + by = c, not ax + by + c = 0.
- Assuming D = 0 always means "no solution"; identical lines have infinitely many.
Frequently asked questions
How can I tell whether parallel lines are identical?
When D = 0, check whether all three coefficients are proportional, a₁ : b₁ : c₁ = a₂ : b₂ : c₂. If so, the lines coincide.
How do I get the angle from slopes?
tan θ = |(m₂ − m₁) ÷ (1 + m₁m₂)|. For slopes 1 and −2, tan θ = 3, so θ ≈ 71.57°.
Can this be used for three equations?
Cramer's rule extends to 3 × 3 systems with three-variable determinants, but this calculator handles two lines in a plane.
Sources: G. Cramer, Introduction à l'analyse des lignes courbes algébriques (1750) · G. Strang, Introduction to Linear Algebra, Wellesley-Cambridge Press