daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function [y,z]=dhorner(W,x)
  2.   n=length(W) ;
  3.   y=W(1) ;
  4.   z=0;
  5.   for i=2:n
  6.     z=y+z.*x;
  7.     y=y.*x+W(i);
  8.   end
  9. end
  10.  
  11. function[pn,err,k]=polnewton(W,p0,delta,max)
  12.  for k=1:max
  13.     [y,z]=dhorner(W,p0);
  14.     pn=p0 - y / z;
  15.     err=abs(pn - p0);
  16.     p0=pn;
  17.     if(err<delta)
  18.         return;
  19.     end
  20. end
  21.  
  22. W=[2 -1]
  23.  
  24. polnewton(W, 1, 0.2, 100)
  25.  
  26. W=[2 -1 0]
  27.  
  28. polnewton(W, 1, 0.2, 100)
  29.  
  30. W=[1 -2 0 1]
  31.  
  32. polnewton(W, 0.5, 0.2, 100)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top