Newton Raphson Method and Bisection Method

7 Ansichten (letzte 30 Tage)
Irem Tas
Irem Tas am 7 Dez. 2021
Beantwortet: Irem Tas am 7 Dez. 2021
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 Kommentar
James Tursa
James Tursa am 7 Dez. 2021
What have you done so far? What specific problems are you having with your code?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Irem Tas
Irem Tas am 7 Dez. 2021
% 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.

Community Treasure Hunt

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

Start Hunting!

Translated by