필터 지우기
필터 지우기

How can I find the root of this equation?

조회 수: 2 (최근 30일)
veru
veru 2013년 5월 11일
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.

답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by