Advertisement
codisinmyvines

sr3and4

Mar 28th, 2022 (edited)
948
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function x = method_Newton(f, df, x0, eps)
  2.     x=x0-double(subs(f,x0))/double(subs(df,x0));
  3.     while(abs(x-x0)>eps)
  4.         x0=x;
  5.         x=x0-double(subs(f,x0))/double(subs(df,x0));
  6.     end
  7. end
  8.  
  9. %main
  10. syms x;
  11. eps = input('Enter eps: ');
  12. x0 = input('Enter x0: ');
  13. f = input('Enter your function: ');
  14. df = diff(f,x);
  15. x = method_Newton(f,df,x0,eps)
  16.  
  17.  
  18. %sr4
  19. %задание 1
  20. A = input('Enter the matrix of system: ');
  21. b = input('Enter the vector b: ');
  22. detA=det(A);
  23. i=1:size(A);
  24. B1=A; B2=A; B3=A; B4=A;
  25. B1(i,1)=b(i);
  26. B2(i,2)=b(i);
  27. B3(i,3)=b(i);
  28. B4(i,4)=b(i);
  29. [det(B1)/detA det(B2)/detA det(B3)/detA det(B4)/detA]
Advertisement
RAW Paste Data Copied
Advertisement