Programming in MatLab and taking the following mathematical
Programming in MatLab and taking the following mathematical expression:
****Find the roots.****
x^5 + x + 1=0
Considerations:
• use: clear all, clc, disp, fprint, input, if-else, for, while, subprograms, vectors, matrix...
• do not use: roots, fzero, poly, polyval, residue, floor...
Programming in MatLab and taking the following mathematical expression:
****Find the roots.****
x^5 + x + 1=0
Considerations:
• use: clear all, clc, disp, fprint, input, if-else, for, while, subprograms, vectors, matrix...
• do not use: roots, fzero, poly, polyval, residue, floor...
Programming in MatLab and taking the following mathematical expression:
****Find the roots.****
x^5 + x + 1=0
Considerations:
• use: clear all, clc, disp, fprint, input, if-else, for, while, subprograms, vectors, matrix...
• do not use: roots, fzero, poly, polyval, residue, floor...
Solution
f=@(x) x^5+x+1;
a=1;
b=2;
for i=1:100
c=(a+b)/2;
if f(c)>0
b=c;
else a=c;
end
end
a=1; b=2; p=c;
for i=1:100
c=(a+b)/2;
er(i)=f(c)-f(p);
if f(c)>0
b=c;
else a=c;
end
end
fprintf(\'Root of given equation is %f\',c)

