Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function I = simpson(a,b,n)
- deff('y=f(x)','y=x^4')
- h=(b-a)/n
- suma1=0
- suma2=0
- suma3=0
- for i=0:n
- x=a+i*h
- y=f(x)
- disp([x y])
- if (i==0)|(i==n) then
- suma1=suma1+y
- else if (modulo(i,3)==0) then
- suma2=suma2+y
- else
- suma3=suma3+y
- end
- end
- end
- I=((3*h)/8)*(suma1+2*suma2+3*suma3)
- endfunction
- a=input("Ingresa Limite Inferior: ")
- b=input("Ingresa Limite Superior: ")
- n=input("Ingresa numero de intervalos: ")
- if modulo(n,3) == 0 then
- disp(simpson(a,b,n),"El resultado de integrar usando la regla de simpson 3/8 es:")
- else
- disp("Tu numero de intervalos no es divisible por 3")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement