Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- function y=f(x)
- y = x **3 - x ** 2 + x - 8
- endfunction
- function [root,ea]=biseccion(x1,xu,es)
- root = (x1+xu)/2
- ea = 100 * abs((x1-xu)/(x1+xu))
- while ea > es
- if f(x1)*f(root) < 0 then
- xu = root
- else if f(x1)*f(root) == 0
- ea = 0
- else
- x1 = root
- end
- if ea <> 0 then
- root = (x1+xu)/2
- ea = 100 * abs((x1-xu)/(x1+xu))
- end
- end
- end
- endfunction
- x1 = input("Limite Inferior: ")
- xu = input("Limite Superior: ")
- es = input("Tolerancia: ")
- [root,ea] = biseccion(x1,xu,es)
- disp("La raiz aproximada es " + string(root))
- disp("El error de aproximacion = " + string(ea))
- disp("f(root)="+string(f(root)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement