Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CAŁKI OZNACZONE
- function y=fp(x) // fp - funkcja podcałkowa
- y=sqrt(x);
- endfunction
- //METODA SIMPSONA
- A=0;
- disp('A=0')
- B=input('B=');
- N=12;
- h=(B-A)/N;
- F2=0;
- F3=0;
- F1=fp(A+0*h);
- for i=1:2:(N-1) // węzły niepartzyste
- F2=F2+fp(A+i*h);
- end
- for i=2:2:N-2 // węzły parzyste
- F3=F3+fp(A+i*h);
- end
- F4=fp(A+N*h);
- Simpson12=(1/3)*h*(F1+4*F2+2*F3+F4);
- disp('Simpson= '+string(Simpson12));
- //EKSTRAPOLACJA RICHARDSONA
- //obliczenie metodą Simpsona dla N=2*12=24
- N=24;
- h=(B-A)/N;
- F2=0;
- F3=0;
- F1=fp(A+0*h);
- for i=1:2:(N-1) // węzły niepartzyste
- F2=F2+fp(A+i*h);
- end
- for i=2:2:N-2 // węzły parzyste
- F3=F3+fp(A+i*h);
- end
- F4=fp(A+N*h);
- Simpson24=(1/3)*h*(F1+4*F2+2*F3+F4);
- //wzór Richardsona
- Richardson=((2^4)*Simpson24-Simpson12)/((2^4)-1);
- disp('Richadson='+string(Richardson));
- //FUNKCJA intg
- Scilab=intg(A,B,fp);
- disp('intg= '+string(Scilab));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement