Advertisement
Adytzu04

To

Apr 5th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.59 KB | None | 0 0
  1. clc;
  2. clear all;
  3.  
  4. x1=10;
  5. x2=20;
  6.  
  7. T=10^(-6);
  8.  
  9. eps=10^-8;
  10.  
  11. xk=[x1; x2];
  12.  
  13. rk=[ (f(x1+T,x2)-f(x1,x2))/T ;(f(x1,x2+T)-f(x1,x2))/T ]
  14.  
  15. x1
  16. x2
  17.  
  18.  
  19. while norm(rk)>eps
  20.    
  21. hk1= (f(x1+2*T,x2)-2*f(x1+T,x2)+f(x1,x2))/T^2;
  22. hk2= (f(x1+T,x2+T)-f(x1+T,x2)-f(x1,x2+T)+f(x1,x2))/T^2;
  23. hk3= (f(x1+T,x2+T)-f(x1+T,x2)-f(x1,x2+T)+f(x1,x2))/T^2;
  24. hk4= (f(x1,x2+2*T)-2*f(x1,x2+T)+f(x1,x2))/T^2;
  25.  
  26. H=[hk1 hk2; hk3 hk4]
  27. theta=(rk'*rk)/(rk'*H*rk);
  28.  
  29. xk=xk-theta*rk;
  30. x1=xk(1);
  31. x2=xk(2);
  32. rk=[ (f(x1+T,x2)-f(x1,x2))/T ;(f(x1,x2+T)-f(x1,x2))/T ]
  33.  
  34. end
  35.  
  36. %theta=(rk'*rk)/(rk'*(H*rk));
  37.  
  38. %q=xk+theta*hk
  39. %q
  40. xk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement