Conditions | 2 |
Paths | 1 |
Total Lines | 11 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public function run(callable $fx, callable $fdx, float $guess): float |
||
35 | { |
||
36 | $newValue = $guess; |
||
37 | $errorLimit = pow(10, -1 * $this->precision); |
||
38 | do { |
||
39 | $previousValue = $newValue; |
||
40 | $newValue = $previousValue - ($fx($previousValue) / $fdx($previousValue)); |
||
41 | } while (abs($newValue - $previousValue) > $errorLimit); |
||
42 | |||
43 | return $newValue * 12; |
||
44 | } |
||
45 | } |
||
46 |