← Main book chapter 4
Contents / index
Browser back
← Previous chapter
Next chapter →
Laboratory
Memory
Cards
Sort
Match
Visuals
Coding
Quiz
Programming practice
2x2 linear solve — Chapter 4
Fix the determinant formula and singularity check.
Language:
PHP
Student code
<?php function solve2($a,$b,$c,$d,$r1,$r2){ $det = $a*$b - $c*$d; $x = ($d*$r1 - $b*$r2)/$det; $y = (-$c*$r1 + $a*$r2)/$det; return [$x,$y]; } ?>
Check code
Show corrected code
Reset buggy code
Feedback
Corrected code