필터 지우기
필터 지우기

bisection method error while checking loop with f(p)

조회 수: 3 (최근 30일)
PJS KUMAR
PJS KUMAR 2018년 8월 3일
function p = bisection(f,a,b)
if f(a)*f(b)>0
disp('Wrong choice bro')
else
p = (a + b)/2;
err = abs(f(p));
while err > 1e-7
if f(a)*f(p)<0
b = p;
else
a = p;
end
p = (a + b)/2;
err = abs(f(p));
end
end
The above Bisection method is not working with f(x)=x*tan(x)+1 using the interval [1,2].
>> f=@(x)x*tan(x)+1;
>> bisection(f,1,2)
not giving any output and entering into infinite loop

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by