Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solucion=difdiv(f,vector)
- tamanio=size(vector)
- tamanio=tamanio(1,2)
- if (tamanio==1) then
- printf("ERROR TAMAÑO 1")
- else
- if (tamanio==2) then
- solucion=(f(vector(2))-f(vector(1)))/(vector(2)-vector(1))
- else
- v1=vector(2:tamanio)
- v2=vector(1:tamanio-1)
- solucion=(difdiv(f,v1)-difdiv(f,v2))/(vector(tamanio)-vector(1))
- end
- end
- endfunction
- function pol=polinewton(f,v)
- tam=size(v)
- tam=tam(1,2)
- pol=poly(f(v(1)),"x","coef")
- polaux=poly(1,"x","coef")
- for (i=2:tam)
- polcambio=poly(v(i-1),"x")
- polaux=polaux*polcambio
- coef=difdiv(f,v(1:i))
- pol=pol+polaux*coef
- end
- endfunction
Add Comment
Please, Sign In to add comment