Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %By FamiHug@FAMILUG
- function [root1, root2] = chiadoi(f, saiso,cana,canb)
- if subs(f,cana) * subs(f,canb) > 0
- disp('Khong co nghiem trong khoang a, b')
- elseif subs(f,cana) * subs(f,canb) == 0
- disp('Mot trong 2 lai nghiem')
- else
- tb = mean(cana, canb);
- if subs(f,cana) * subs(f,tb) < 0
- if abs(tb - cana) < saiso
- else
- canb = tb;
- end
- elseif subs(f,cana) * subs(f,tb) > 0
- if abs(tb - canb) < saiso
- else
- cana = tb;
- end
- else
- disp('mot trong 2 la nghiem')
- end
- end
- disp('ket qua')
- disp(cana)
- end
- function value = mean(a,b)
- value = (a+b)/2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement