sumas de riemman
Publicado por miguel barrera (2 intervenciones) el 19/09/2013 02:00:15
HOLA AMIGOS NECESITO REALIZAR UN PROGRAMA QUE REALIZE SUMAS DE RIEMMAN PERO AL EJECUTAR EL CODIGO ME SALE EL SIGUIENTE ERROR:
Traceback (most recent call last):
File "Untitled", line 4
import matplotlib
File "C:\Python27\Lib\site-packages\matplotlib\__init__.py", line 110
raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil
EL CODIGO FUENTE ES ESTE LES ESTARE ETERNAMENTE AGRADECIDO SI ME PUEDEN AYUDAR MUCHAS GRACIAS ;)
Traceback (most recent call last):
File "Untitled", line 4
import matplotlib
File "C:\Python27\Lib\site-packages\matplotlib\__init__.py", line 110
raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil
EL CODIGO FUENTE ES ESTE LES ESTARE ETERNAMENTE AGRADECIDO SI ME PUEDEN AYUDAR MUCHAS GRACIAS ;)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from math import *
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
def Riemann(a, b, n, l, f):
numRange = np.arange(a, b, .02)
y = f(numRange)
w = float(b - a)/n
x = 0.0
d = {"l": 0, "r": 1, "m": 0.5}
offset = d[l[0]]
for i in range(n):
x += f(a + (i+offset)*w)
plt.gca().add_patch(matplotlib.patches.Rectangle((i*w + a,0),w,f(a + (i+offset)*w)))
plt.plot(numRange, y, color=(1.0, 0.00, 0.00), zorder=5)
s = w * x
print '\n', s, '\n'
def main():
print #empty line
functionString = raw_input("Enter a function: ")
a = input("Enter the start point: ")
b = input("Enter the end point: ")
n = input("Enter the number of rectangles: ")
l = raw_input("Type right, left, or middle: ")
Riemann(a, b, n, l, lambda x: eval(functionString))
plt.show()
if __name__ == "__main__":
main()
Valora esta pregunta


0