TheAlgorithms / JavaScript

Algorithms and Data Structures implemented in JavaScript for beginners, following best practices.
https://the-algorithms.com/language/javascript
GNU General Public License v3.0
32.19k stars 5.52k forks source link

fix: hadnle zeros at the endpoints in `BisectionMethod` #1640

Closed vil02 closed 6 months ago

vil02 commented 6 months ago

Open in Gitpod know more

Describe your change:

findRoot errors when one is trying to find a root for x^3 on the interval [-1, 1]. This PR fixes that and adds a test cave case covering: https://github.com/TheAlgorithms/JavaScript/blob/4a4ed57d4285fc61b5385d2c2525369ce2c4e6fb/Maths/BisectionMethod.js#L29

Checklist:

codecov-commenter commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 84.09%. Comparing base (bd34e9f) to head (f2f10bd).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1640 +/- ## ========================================== + Coverage 84.07% 84.09% +0.02% ========================================== Files 375 375 Lines 19688 19687 -1 Branches 2913 2914 +1 ========================================== + Hits 16552 16556 +4 + Misses 3136 3131 -5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.