Integration in python -


the code have written integrate giving wrong results.i c_0,c_1,...c_4 zeros! doing wrong? using 0.7.6 on mac.

from numpy import * matplotlib.pyplot import * sympy import * x = symbol('x') f = 1.0*sin(np.pi * x) phi_0 = 1.0 phi_1 = 1.0*x phi_2 = 1./2*(3*x**2-1) phi_3 = 1./2*(5*x**3-3*x) phi_4 = 1./8*(35*x**4-30*x**2+3) c_0 = integrate(f*phi_0, (x, -1.0, 1.0)) c_1 = integrate(f*phi_1, (x, -1.0, 1.0)) c_2 = integrate(f*phi_2, (x, -1.0, 1.0)) c_3 = integrate(f*phi_3, (x, -1.0, 1.0)) c_4 = integrate(f*phi_4, (x, -1.0, 1.0)) print c_0 print c_1 print c_2 print c_3 print c_4 

other need import numpy np, don't see problems in recent version (0.7.6). values 0 (as expected due symmetry consideration) others not:

>>> print c_0 0 >>> print c_1 0.636619772367581 >>> print c_2 0 >>> print c_3 -0.330926260628403 >>> print c_4 0 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -