[SciPy-User] Integration of double integral with integration variable as
Jose Amoreira
ljmamoreira@gmail....
Thu Jan 14 07:21:04 CST 2010
Torsten,
Your example is easy!
Since sin(y) is an odd function, integrating over [-x,x] gives zero and that's
it. For a more illustrative example, replace sin with cos (still easy enough
to do it quicker analytically). Using scipy.integrate.quad, you do it like
this (excerpt from an idle session):
>>> def g(x):
return quad(cos,-x,x)[0]
>>> quad(g,0.,1.)[0]
0.91939538826372047
The reason I take the zero-th element of the quad output is that the remaining
is an estimate of the error.
Maybe you should also look into scipy.integrate.dblquad.
Hope this helps.
jose
On Thursday 14 January 2010 09:23:28 am Torsten Andre wrote:
> Hey everyone,
>
> I am new to SciPy, but need to integrate something like this, where the
> boundaries of the inner integral are terms of outer variable's
> integration variable:
>
> \int{\int{sin(y)dy}_{-x}^{+x}dx}_0^1
>
> Is this feasible in SciPy? I tried using quad but it only complains that
> x is not defined. Unfortunately I was unable to find anything on the
> list or in the documentation.
>
> Thanks for your time.
>
> Cheers,
> Torsten
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
More information about the SciPy-User
mailing list