(x, f)
| 15 | const findRoot = (a, b, func, numberOfIterations) => { |
| 16 | // Check if a given real value belongs to the function's domain |
| 17 | const belongsToDomain = (x, f) => { |
| 18 | const res = f(x) |
| 19 | return !Number.isNaN(res) |
| 20 | } |
| 21 | if (!belongsToDomain(a, func) || !belongsToDomain(b, func)) |
| 22 | throw Error("Given interval is not a valid subset of function's domain") |
| 23 |