Given a function f(x) on floating number x and two numbers 'a' and 'b' such that f(a)*f(b) < 0 and f(x)
is continuous in [a, b]. Here f(x) represents algebraic or transcendental equation. Find root of
function in interval [a, b] (Or find a value of x such that f(x) is 0).
Input:
A
function of x,
for example x3 +4x2 + 8. And two values: a=(-5) and b= (1) such
that
f(a)*f(b) < 0, i.e., f(a) and f(b) have opposite signs.
Output:
The value of root is :
-4.412 or any other value with allowed deviation from root.
Given a function f(x) on floating number x and two numbers 'a' and 'b' such that f(a)*f(b) < 0 and f(x)
is continuous in [a, b]. Here f(x) represents transcendental equation. Find root of
function in interval [a, b] (Or find a value of x such that f(x) is 0).
Input:
A
function of x,
for example x2 + x - cos(x). And two values: a=(0) and b= (1) such
that
f(a)*f(b) < 0, i.e., f(a) and f(b) have opposite signs.
Output:
The value of root is :
0.55004 or any other value with allowed deviation from root.
Make sure to add space after typing every variable in the function.
example. x2 + x - cos(x).