Created
June 22, 2016 23:42
-
-
Save KelviNosse/48043e4224ce5dc41cbe9282a8534b8a to your computer and use it in GitHub Desktop.
Integrating sin(x) using Simpson Rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Integracion Simpson en funcion seno | |
# | |
from math import * | |
def f(x): | |
return sin(x) | |
def simpson_rule(a,b): | |
c=(a+b)/2.0 | |
h=abs(b-a)/2.0 | |
return h*(f(a)+4.0*f(c)+f(b))/3.0 | |
val_a = input("Ingrese el valor a: ") | |
val_b = input("Ingrese el valor b: ") | |
res = simpson_rule(val_a, val_b) | |
print "Valor aproximado de la integracion: "+str(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment