Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [y,z]=dhorner(W,x)
- n=length(W) ;
- y=W(1) ;
- z=0;
- for i=2:n
- z=y+z.*x;
- y=y.*x+W(i);
- end
- end
- function[pn,err,k]=polnewton(W,p0,delta,max)
- for k=1:max
- [y,z]=dhorner(W,p0);
- pn=p0 - y / z;
- err=abs(pn - p0);
- p0=pn;
- if(err<delta)
- return;
- end
- end
- W=[2 -1]
- polnewton(W, 1, 0.2, 100)
- W=[2 -1 0]
- polnewton(W, 1, 0.2, 100)
- W=[1 -2 0 1]
- polnewton(W, 0.5, 0.2, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement