Respuesta :
Answer:
Explanation:
[tex]\text{This is a math function that is integrated using a trapezoidal rule } \\ \\[/tex]
[tex]\text{import math}[/tex]
def [tex]\text{trapezint2(f,a,b):}[/tex]
[tex]\text{midPoint=(a+b)/2}[/tex]
[tex]\text{return .5*((midPoint-a)*(f(a)+f(midPoint))+(b-midPoint)*(f(b)+f(midPoint)))}[/tex]
[tex]\text{trapezint2(math.sin,0,.5*math.pi)}[/tex]
[tex]0.9480594489685199[/tex]
[tex]trapezint2(abs,-1,1)[/tex]
[tex]1.0[/tex]
In this exercise we have to use the knowledge of computational language in python to write the code.
the code can be found in the attachment.
In this way we have that the code in python can be written as:
h = (b-a)/float(n)
s = 0.5*(f(a) + f(b))
for i in range(1,n,1):
s = s + f(a + i*h)
return h*s
from math import exp # or from math import *
def g(t):
return exp(-t**4)
a = -2; b = 2
n = 1000
result = Trapezoidal(g, a, b, n)
print result
See more about python at brainly.com/question/26104476
