Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Finding the root of an equation
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
veru

Posts: 3
Registered: 5/9/13
Finding the root of an equation
Posted: May 11, 2013 4:58 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.