Borrar filtros
Borrar filtros

How can I find the root of this equation?

1 visualización (últimos 30 días)
veru
veru el 11 de Mayo de 2013
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=input('Enter a scalar function: ')
x=input('Enter a number: '); % initial number
epsilon=input('Enter a positive number: ')
Any help would be greatly appreciated. Thanks in advance.

Respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by