MATLAB. Secant Method test.

945 Views Asked by At

Test the secant method on an example in which $r$, $f'(r)$ and $f''(r)$ are known in advance. Monitor the ratios $e_{n+1}/(e_n e_{n-1})$ to see whether they converge to $- \frac{1}{2} f"(r) / f'(r)$.

$f(x) = \arctan(x)$ might be a suitable function.

$f'(x) = \frac{1}{x^2 + 1}$

$f"(x) = -\frac{2x}{(x^2+1)^2}$

1

There are 1 best solutions below

0
On BEST ANSWER

example f =inline('sqrt(x)-cos(x)'); p0=1; p1=2; for i=0:50 if abs(p1-p0)<0.000001 break end

p=p1-(f(p1)*((p1-p0)/(f(p1)-f(p0))));
p0=p1;
p1=p;

F_of_p=f(p); end p F_of_p %f(p) i %number of iteration