Using the Bisection Method,calculating xr and approximate errors???
古いコメントを表示
Hi, I tried to solve a question using the bisection method, trying to find out xr (root of eq.) and aprroximate error, but there is a problem with my program that I need to define xrold anyhow as the value of xr changes in every iteration. In addition, I need to find Ea=((xr-xrold)/xr))*100 using the old and new values for xr in each step once again. I don't know how to employ this circle for each values of xr. Could you possibly help?
That was the program I made where I got an error at xrold value that obviously, it hasn't been defined properly;
In the question we have the given values of Es, xl, xu and a polynomial function which is f(x)=26+85*x-91*x^2+44*x^3-8*x^4+x^5
%Solve the equation using the bisection method.
xl=0.5;
xu=1;
Es=10;
iter=0;
while(1)
xrold=xr;
f=@(x) -26+85*x-91*x^2+44*x^3-8*x^4+x^5;
xr=(xl+xu)/2;
iter=iter+1;
if xr~=0;
Ea=abs((xr-xrold)/xr)*100;
end
test=f(xl)*f(xr);
if test<0;
xu=xr;
elseif test >0;
xl=xr;
else
Ea=0;
end
if Ea<Es
break
end
end
5 件のコメント
Geoff Hayes
2015 年 11 月 7 日
Onur - what exactly are you trying to find using this method and the polynomial that you have defined?
Onur Aytan
2015 年 11 月 7 日
編集済み: Onur Aytan
2015 年 11 月 7 日
Geoff Hayes
2015 年 11 月 7 日
But what are you trying to solve for given the polynomial and the interval that you have defined?
Onur Aytan
2015 年 11 月 7 日
編集済み: Onur Aytan
2015 年 11 月 7 日
Dipankar Dutta
2021 年 4 月 22 日
2. Make an octave code to integrate ex with respect to dx from 0 to 1, by Simpson’s ⅓ rule. Divide the limits into 6 equal parts.
Please solve this
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Utilities for the Solver についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!