Notebooks · posts/two-lines-cross
Two lines cross
Two straight lines, and , meet at one point unless they are parallel. Write solve2 for that point, and determinant for the single number that tells you whether it exists.
Elimination, substitution, Cramer's rule: they are the same arithmetic in three arrangements, and any of them solves this. The lines and cross at , and so do and : a different pair of lines through the same point. A third pair crosses at , so an answer that always returns fails.
The last test checks a failure. Slide one line until it is parallel
to the other and the crossing runs off to infinity; something in the arithmetic must
have gone to zero at that moment. Find what, and that is determinant.
Look inside this program
- Atlas
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
This is a problem: its tests fail until the functions in it are written. Edit a cell and run it to try; the cells below it show whether the tests pass.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.