Newton Raphson Method and Bisection Method

조회 수: 7 (최근 30일)
Irem Tas
Irem Tas 2021년 12월 7일
답변: Irem Tas 2021년 12월 7일
f(x)=114.94253x^2-1.31705x^3-0.00436522x^4-4.72276*10^4
I need to write codes for this function by applying Newton Raphson Method and Bisection Method.
For Bisection Method: a=0 b=48 error=0.0000001
For Newton-Raphson Method: x1=24 error=0.0000001
  댓글 수: 1
James Tursa
James Tursa 2021년 12월 7일
What have you done so far? What specific problems are you having with your code?

댓글을 달려면 로그인하십시오.

답변 (1개)

Irem Tas
Irem Tas 2021년 12월 7일
% Clearing Screen
clc
% Input Section
y = 114.94253*(x^2)-1.31705*(x^3)-0.00436522*(x^4)-(4.72276*10^4);
a = 0;
b = 48;
e = 0.0000001;
% Finding Functional Value
fa = eval(subs(y,x,a));
fb = eval(subs(y,x,b));
% Implementing Bisection Method
if fa*fb > 0
disp('Given initial values do not bracket the root.');
else
c = (a+b)/2;
fc = eval(subs(y,x,c));
fprintf('\n\na\t\t\tb\t\t\tc\t\t\tf(c)\n');
while abs(fc)>e
fprintf('%f\t%f\t%f\t%f\n',a,b,c,fc);
if fa*fc< 0
b =c;
else
a =c;
end
c = (a+b)/2;
fc = eval(subs(y,x,c));
end
fprintf('\nRoot is: %f\n', c);
end
I tried this code for Bisection Method but I couldnt result.

카테고리

Help CenterFile Exchange에서 Newton-Raphson Method에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by