필터 지우기
필터 지우기

I am stuck up in error

조회 수: 1 (최근 30일)
Aasif Ahmed
Aasif Ahmed 2022년 8월 31일
답변: Sarthak 2023년 2월 8일
I am using f(x)= exp^x - x^4
for bisection method with initial guesses a = −1 and b = 0 & ε=0.001 but error arises what to do any help in code?

답변 (1개)

Sarthak
Sarthak 2023년 2월 8일
The error is arising due to the following reasons:
  1. The function exp (4) - x^4 isn’t converging. Hence the convergence loop will go in infinite state.
  2. Even if the function was converging, make sure the initial guesses are right. That is, the converging point should be between the initial guesses.
  3. Precision: If the desired precision is too high, the bisection method may not converge within a reasonable amount of time.
You can refer to the below sample code to understand Bisection method.
function c = bisectionMethod(f,a,b,error)
c=(a+b)/2;
while abs(f(c))>error
if f(c)<0&&f(a)<0
a=c;
else
b=c;
end
c=(a+b)/2;
end
end

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by