Python - sumas de riemman

 
Vista:

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 ;)

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
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 2.239
Plata
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

sumas de riemman

Publicado por xve (1646 intervenciones) el 19/09/2013 09:57:04
Hola Miguel, he probado tu código y me funciona perfectamente, no me da ningún error...


Lo estoy ejecutando bajo Debian GNU/Linux con Python 2.7...

En que sistema operativo lo estas utilizando? que version de Python?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

sumas de riemman

Publicado por miguel barrera (2 intervenciones) el 20/09/2013 04:03:12
hola gracias por tu respuesta haber te cuento lo estoy ejecutando en windows 8 y la version es la 2.7 no se si el error sea de windows q me recomiendas osea necesito adaptarlo para q corra en wx8 q es el q tengo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar