How can I solve an equation using fixed point method?

6 ビュー (過去 30 日間)
Carla Coutinho
Carla Coutinho 2016 年 7 月 2 日
コメント済み: Radu Trimbitas 2020 年 3 月 20 日
g(x)=2^-x;
[1/3,1];
tol=10^-4;
max=100
  2 件のコメント
David Miller
David Miller 2016 年 7 月 2 日
編集済み: David Miller 2016 年 7 月 2 日
Please be more specific. What does [1/3,1] and max=100 represent? I assume tol is the tolerance for convergence, sometimes referred to as epsilon.
Radu Trimbitas
Radu Trimbitas 2020 年 3 月 20 日
Yes, David, tol is the tolerance, or epsilon; max is the maximum number of iterations; x0 is the initial approximation (starting value)
Code for sapmeth
function [z,ni]=sapmeth(f,x0,tol,maxit)
for k=1:maxit x1=f(x0);
if abs(x1-x0) < tol %success
z=x1; ni=k;
return;
end;
x0=x1;
end error('iteration number exceeded')
Call:
f=@(x) 2^(-x);
x0=0.6;
[z,ni]=sapmeth(f,x0,1e-6,100)
Results
z=0.641185
n=15

サインインしてコメントする。

回答 (1 件)

Radu Trimbitas
Radu Trimbitas 2016 年 7 月 4 日
If you wish to solve x=2^(-x) use successive approximation method. Provide a function, a starting value and a tolerance. function [z,ni]=sapmeth(f,x0,tol,maxit) for k=1:maxit x1=f(x0); if abs(x1-x0) < tol %success z=x1; ni=k; return; end; x0=x1; end error('iteration number exceeded')
if you provide the input parameters f=@(x) 2^(-x), x0=0.6 and call [z,ni]=[z,ni]=sapmeth(f,x0,1e-6,100) after 15 iterations one obtains the fixpoint z=0.641185

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by