trapecios

an anonymous user · September 16, 2020 · Python
def trapecios(f,a,b,m):
    h=(b-a)/m
    s=0
    for i in range(1,m):
        s=s+f(a+i*h)
    r=h/2*(f(a)+2*s+f(b))
    return r
    
    
from math import*
def f(x): return (8+3*sin(x))
r=trapecios(f,0,pi,10)
r

Comments

Please sign up or log in to contribute to the discussion.