Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fp=falsa_posicion(f,p0,p1,iteraciones,tol)
- fp="No existe"
- if(f(p0)*f(p1)==0) then
- if (f(p0)==0) then
- fp=p0
- else
- fp=p1
- end
- end
- if (f(p0)*f(p1)>0) then
- fp="Los extremeos tienen mismo signo"
- else
- if(fp<>"No existe") then
- i=2
- q0=f(p0)
- q1=f(p1)
- _p0=p0
- _p1=p1
- while (i<=iteraciones) do
- p=_p1-q1*(_p1-_p0)/(q1-q0)
- if abs(p-_p1)<tol then
- fp=p
- i=iteraciones+1
- else
- i=i+1
- q=f(p)
- if q*q1<0 then
- _p0=_p1
- q0=q1
- end
- _p1=p
- q1=q
- end
- end
- end
- end
- if (fp=="No existe" | fp=="Los extremeos tienen mismo signo") then
- error("Metodo fallo")
- end
- endfunction
Add Comment
Please, Sign In to add comment