SHARE
TWEET

Untitled

a guest Nov 12th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clc;clear;
  2. E = 1e-4; kmax = 40; X0 = [2 2 2]';
  3. X = zeros(3,1); J = zeros(3,3);
  4. k = 0; Fn = ones(3,1)*2*E;
  5. J(1,2) = -2;
  6. J(2,1) = 1;
  7. J(2,3) = 0;
  8. J(3,1) = 1;
  9. J(3,2) = 1;
  10. J(3,3) = 1;
  11. while abs(max(Fn)) >= E & k <= kmax
  12.     k = k+1;
  13.     if k == 1
  14.         Xp = X0;
  15.     else
  16.         Xp = X(:,k-1);
  17.     end
  18.     Fn(1) = exp(Xp(1)/2)-2*Xp(2)+3*Xp(3)^2-24.65;
  19.     Fn(2) = Xp(1)-log(Xp(2))-0.699;
  20.     Fn(3) = Xp(1)+Xp(2)+Xp(3)-6;
  21.     J(1,1) = 0.5*exp(Xp(1)/2);
  22.     J(1,3) = 6*Xp(3);
  23.     J(2,2) = -Xp(2)^(-1);
  24.     X(:,k) = Xp-inv(J)*Fn;
  25. end
  26. disp('x1');disp(X(1,k));
  27. disp('x2');disp(X(2,k));
  28. disp('x3');disp(X(3,k));
  29. disp('liczba iteracji:');disp(k);
  30. disp('dokładność ');disp(abs(max(Fn)));
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