Advertisement
Guest User

Untitled

a guest
Apr 8th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.93 KB | None | 0 0
  1. // CAŁKI OZNACZONE
  2. function y=fp(x)  // fp - funkcja podcałkowa
  3.     y=sqrt(x);
  4. endfunction
  5.  
  6. //METODA SIMPSONA
  7. A=0;
  8. disp('A=0')
  9. B=input('B=');
  10. N=12;
  11. h=(B-A)/N;
  12. F2=0;
  13. F3=0;
  14. F1=fp(A+0*h);
  15. for i=1:2:(N-1)      // węzły niepartzyste
  16.      F2=F2+fp(A+i*h);
  17. end
  18. for i=2:2:N-2        // węzły parzyste
  19.      F3=F3+fp(A+i*h);
  20. end
  21. F4=fp(A+N*h);
  22. Simpson12=(1/3)*h*(F1+4*F2+2*F3+F4);
  23. disp('Simpson=  '+string(Simpson12));
  24.  
  25. //EKSTRAPOLACJA RICHARDSONA
  26.  
  27. //obliczenie metodą Simpsona dla N=2*12=24
  28.  
  29. N=24;
  30. h=(B-A)/N;
  31. F2=0;
  32. F3=0;
  33. F1=fp(A+0*h);
  34. for i=1:2:(N-1)      // węzły niepartzyste
  35.      F2=F2+fp(A+i*h);
  36. end
  37. for i=2:2:N-2        // węzły parzyste
  38.      F3=F3+fp(A+i*h);
  39. end
  40. F4=fp(A+N*h);
  41. Simpson24=(1/3)*h*(F1+4*F2+2*F3+F4);
  42. //wzór Richardsona
  43. Richardson=((2^4)*Simpson24-Simpson12)/((2^4)-1);
  44. disp('Richadson='+string(Richardson));
  45.  
  46. //FUNKCJA intg
  47.  
  48. Scilab=intg(A,B,fp);
  49. disp('intg=     '+string(Scilab));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement