Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Finding the root of an equation
Replies: 0

 veru Posts: 3 Registered: 5/9/13
Finding the root of an equation
Posted: May 11, 2013 4:58 AM

I would like to create a function which finds the root of an equation numerically by using the following recursive formula:

x(n+1) = x(n) - ( f(x(n)) / g(x(n) ) , for n=1,2,3,...

where g(x(n)) = f( x(n) + f(x(n)) ) / f(x(n)).

This iterative procedure must stop when the absolute difference between x(n) and x(n+1) is less than a given tolerance epsilon. The function must accept as inputs, a scalar function 'f', an initial number 'x' and a positive number 'epsilon' to terminate the procedure. Hence by using this numerical technique I would like to find the root of the equation e^x-x^2=0.

function y=q3(x)
f=('Enter a scalar function: ');
x=('Enter a number: '); % initial number
epsilon=('Enter a positive number: ');

Any help would be greatly appreciated. Thanks in advance.