Robert Kern rkern at ucsd.edu
Mon Jul 11 19:30:35 CDT 2005

```guillem at torroja.dmt.upm.es wrote:
> hi
>
> I was trying to solve the following integral
>
> Â  Â  Â  Â  Â  / / / Â  Â  Â  Â  Â dx dy dz
> Â  Â  Â  Â  Â  | | | Â  Â -------------------
> Â  Â  Â  Â  Â  / / / Â  Â SQRT(z + y + x + 2)
>
> Â  Â  Â  Â  Â I(x,y,z) = [0,2]x[0,1]x[-1,4]
>
> with the following script
>
> from scipy_base import *
>
> lower_bound_z= lambda x,y : -1.
> upper_bound_z= lambda x,y : 4.
>
> lower_bound_y= lambda x: 0.
> upper_bound_y= lambda x: 1.
>
> lower_bound_x = 0.
> upper_bound_x = 2.
>
> func = lambda x,y,z: 1./sqrt(x+y+z+2.)
>
> Â  Â  Â  Â  Â  lower_bound_x,
> Â  Â  Â  Â  Â  upper_bound_x,
> Â  Â  Â  Â  Â  lower_bound_y,
> Â  Â  Â  Â  Â  upper_bound_y,
> Â  Â  Â  Â  Â  lower_bound_z,
> Â  Â  Â  Â  Â  upper_bound_z
> print B
> print 1688/15-B[0]
>
> The result should be 1688/15 (112.53) but I get (4.6750890836723107,
> 5.1903915428667244e-14) and I really can't find anything wrong.
>
> Can anyone give me a clue?

Doing the integral by hand gives me the same answer that tplquad gives.

In [1]: 8./15*(9**2.5-8**2.5-4**2.5+3**2.5-7**2.5+6**2.5+2**2.5-1**2.5)
Out[1]: 4.6750890836723009

In [2]: def f(x, y, z):
...:     return 1./sqrt(x+y+z+2.)
...:

In [3]: integrate.tplquad(f, 0., 2., lambda x: 0., lambda x: 1., lambda
x,y: -1., lambda x,y: 4.)
Out[3]: (4.6750890836723098, 5.1903915428667231e-14)

--
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

```