multiple integrals

180 views
Skip to first unread message

Thomas Scofield

unread,
Feb 15, 2010, 2:27:13 PM2/15/10
to sage-s...@googlegroups.com

Can someone point me to examples/documentation on doing double integrals numerically?  That is, say you have to calculate a double integral with integrand f(x,y) for which no closed-form antiderivative (neither in x nor y) exists.  Assume my xy-region of integration is rectangular.  Is there a numerical_integral() type command for this case?

Thomas L. Scofield
--------------------------------------------------------
Associate Professor
Department of Mathematics and Statistics
Calvin College
--------------------------------------------------------

Robert Bradshaw

unread,
Feb 15, 2010, 2:37:48 PM2/15/10
to sage-s...@googlegroups.com

On Feb 15, 2010, at 11:27 AM, Thomas Scofield wrote:

>
> Can someone point me to examples/documentation on doing double
> integrals numerically? That is, say you have to calculate a double
> integral with integrand f(x,y) for which no closed-form
> antiderivative (neither in x nor y) exists. Assume my xy-region of
> integration is rectangular. Is there a numerical_integral() type
> command for this case?


Not that I know of, but you can nest them. For example, to do \int_3^4
\int_1^x sin(x^2/y) dy dx one can do

sage: numerical_integral(lambda x: numerical_integral(sin(x^2/y),
1, x)[0], 3, 4)
(-0.78059401567023834, 8.6663344908170892e-15)

Note that the [0] on the inner integral causes it to ignore the error
term there.

- Robert

kcrisman

unread,
Feb 15, 2010, 2:49:35 PM2/15/10
to sage-support
There is a ticket (sorry I don't have these on me, seems to be getting
a habit) for this with symbolic integration under something like
"Mathematics-style syntax for integrals". It is not hard at all to
make (rectangular) regions do this with something nice. The trickier
part is maintaining backward-compatibility for the deprecation period,
which is presumably why this has stalled. I think that some of the
Hussein/Erocal patches under review with Pynac 0.11.0 (?) will make
this even easier than it already would have been.

Anyway, presumably something similar should be done with .nintegral
and numerical_integral (which should really be a method of Symbolic
Expressions, at least ones with one variable if the variable is given,
i.e. (x^2).numerical_integral(x,0,1) ). It would also be really good
to make sure that numerical_integral can start handling cases with
parameters input at run time - am I correct that
numerical_integral(f(x,y).subs(x=3),...) still doesn't work that hot?
Or is that old info?


- kcrisman

On Feb 15, 2:37 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:

Jason Grout

unread,
Feb 15, 2010, 8:24:19 PM2/15/10
to sage-s...@googlegroups.com
On 02/15/2010 01:27 PM, Thomas Scofield wrote:
>
> Can someone point me to examples/documentation on doing double integrals
> numerically? That is, say you have to calculate a double integral with
> integrand f(x,y) for which no closed-form antiderivative (neither in x
> nor y) exists. Assume my xy-region of integration is rectangular. Is
> there a numerical_integral() type command for this case?
>

You can use scipy to calculate the integrals. See the documentation
here: http://docs.scipy.org/doc/scipy/reference/integrate.html (dblquad
and tplquad are the relevant functions).

Thanks,

Jason

Reply all
Reply to author
Forward
0 new messages