Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc; clear all; close all;
- syms x k;
- fc=0;
- c=0;
- y=x+cos(x);
- yx=vectorize(y)
- del=1e-9
- vectorize(y);
- a=-5
- b=5
- while 1
- fa=double(subs(y,'x',a))
- fb=double(subs(y,'x',b))
- c=(a+b)/2;
- fc=double(subs(y,'x',c))
- k=k+1
- if fa*fc>0
- a=c;
- else if fa*fc<0
- b=c;
- end
- end
- if(abs(fc)<=1e-9)
- break;
- end
- end
- fprintf('Nghiem x = %12.10f \n',c);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement