MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / belongsToDomain

Function belongsToDomain

Maths/BisectionMethod.js:17–20  ·  view source on GitHub ↗
(x, f)

Source from the content-addressed store, hash-verified

15const 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

Callers 1

findRootFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected