Skip to content

Instantly share code, notes, and snippets.

@sujyrokimora
Created October 3, 2024 16:04
Show Gist options
  • Select an option

  • Save sujyrokimora/6825f9e37da99c2fd358a6947750c5b1 to your computer and use it in GitHub Desktop.

Select an option

Save sujyrokimora/6825f9e37da99c2fd358a6947750c5b1 to your computer and use it in GitHub Desktop.
def f(x):
a=2.0
b=3.0
c=4.0
return a*x**2+b*x+c
def area(f,a,b,N=100):
soma=0.0
dx=(b-a)/N
for i in range(N):
soma+=f(a+i*dx)*dx
pass
return soma
def main():
a=-1.0
b=2.0
soma=area(f,a,b)
print("A={}".format(soma))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment