This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @return array An array of two elements containing roots in any order | |
| */ | |
| function findRoots($a, $b, $c) | |
| { | |
| $delta = ($b * $b) - 4 * ($a * $c); | |
| $x = (- $b - sqrt($delta)) / (2 * $a); | |
| $y = (- $b + sqrt($delta)) / (2 * $a); | |
| return [$x, $y]; |
OlderNewer