Advertisement
franciscominajas

Untitled

Jul 6th, 2020
2,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.44 KB | None | 0 0
  1. %Métodos Numericos
  2. %
  3. %
  4. clc
  5. clear all;
  6. f=inline('(exp(-sin(8*x)))');
  7. a=0;
  8. b=3.5;
  9. k=18; %3,4,6
  10. %a=-pi;b=pi;
  11. %k=8
  12. h=(b-a)/(2*k);
  13. s1=0; %se establecen dos sumadores
  14. s2=0;
  15. for i=1:2*k-1
  16.     if rem(i,2)==1
  17.         s1=s1+f(a+i*h); %sumando impares
  18.     else
  19.         s2=s2+f(a+i*h); %sumando pares
  20.     end
  21. end
  22. syms z
  23. vexacto=double(int(f(z),a,b)) %se calcula el valor exacto de la integral
  24. IS1_3=h/3*(f(a)+4*s1+2*s2+f(b)) %simpson 1/3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement