Symbolic quadrature in Python

Viewed 24

I want to calculate the following symbolic integral with a Quadrature using sympy and mpmath:

I = \int _{a}^b (1/(x-y))* exp^(-x^2 - y^2)

However, I just want to integrate once respect to the x variable, leaving an overall function depending on y only:

int (I) dx = F(y)

I did this with sympy-mpmath:

X,Y = sympy.symbols("x,y")
f = (1/(X-Y))*sympy.exp(-X**2 - Y**2)


f_math=sympy.lambdify(x,f,"mpmath")

val = mpmath.quad(f_math,(0,1),method="gauss-legendre")

I get this error afterwards:

TypeError: cannot create mpf from -y**2 - 0.0127016653792583114821

Is this integration task possible with sympy?

0 Answers
Related