From: ofer on
hi,
i have a pretty nasty double integral which i need to solve numerically but mathematica gives me error messages when i try to solve it straightforward using NIntegrate

the integrand is:

Exp[-I*\[Lambda]*(x+y)]*(x-y)*((Sinh[Pi*(x+I*\[Epsilon])]*Sinh[Pi*(y-I*\[Epsilon])])^-2 -(Sinh[Pi*(x-I*\[Epsilon])]*Sinh[Pi*(y+I*\[Epsilon])])^-2)

in the limits x=-infinity..infinity, y=-infinity..infinity

with epsilon==>0

i'm new to mathematica and will appreciate any suggestions

From: Peter Pein on
Am Mon, 28 Jun 2010 06:29:45 +0000 (UTC)
schrieb ofer <ofershl(a)gmail.com>:

> hi,
> i have a pretty nasty double integral which i need to solve
> numerically but mathematica gives me error messages when i try to
> solve it straightforward using NIntegrate
>
> the integrand is:
>
> Exp[-I*\[Lambda]*(x+y)]*(x-y)*((Sinh[Pi*(x+I*\[Epsilon])]*Sinh[Pi*(y-I*\[Epsilon])])^-2
> -(Sinh[Pi*(x-I*\[Epsilon])]*Sinh[Pi*(y+I*\[Epsilon])])^-2)
>
> in the limits x=-infinity..infinity, y=-infinity..infinity
>
> with epsilon==>0
>
> i'm new to mathematica and will appreciate any suggestions
>

Assuming you replaced epsilon and lambda by numerical values, I can not
understand why NIntegrate fails. If you didn't so, you'll get an error
stating that the integrand is nowhere numeric. ("The integrand" ...
"has evaluated to non-numerical values for all sampling points in the
region with boundaries"...)

Peter


From: ofer on
thanks peter.
actually i don't get error messages but warnings like :

NIntegrate::slwcon: Numerical integration converging too slowly; \
suspect one of the following: singularity, value of the integration \
is 0, highly oscillatory integrand, or WorkingPrecision too small

and the result i get is far from the accurate result obtained via analytic methods

From: Pratip Chakraborty on
Hi,
Seems like Mathemtica can solve this both symbolically as well as Numerically.
But if you want exact symbolic solution it needs some time to integrate.
Here is the code.

(*Symbolic Integration*)
re=Assuming[\[Lambda] \[Element] Reals && \[Epsilon] > 0,
Integrate[
Exp[-I*\[Lambda]*(x + y)]*(x -
y)*((Sinh[Pi*(x + I*\[Epsilon])]*
Sinh[Pi*(y - I*\[Epsilon])])^-2 - (Sinh[
Pi*(x - I*\[Epsilon])]*
Sinh[Pi*(y + I*\[Epsilon])])^-2), {x, -Infinity,
Infinity}, {y, -Infinity, Infinity}]]

Lets form a function that takes Lambda and Epsilon and returns the result of
the integral as a pair of real numbers {RealPart, ImaginaryPart}.

(*Integral as a function of Parameters Lambda and Epsilon*)
IntegrationResult[Lambda_?NumericQ, Epsilon_?NumericQ] :=
Module[{val},
val = re /. \[Lambda] -> Lambda /. \[Epsilon] -> Epsilon; {Re[val],
Im[val]}];
IntegrationResult[1.5, 2.]

Now for the numerical integration you need to specify numerical values for
the Lambda and the Epsilon. This can be acheived by using the With function
of Mathematica along with NIntegrate. I see that MAthematica can integrate
even with Imaginary value of Lambda.

(*Numerical Integration*)
With[{\[Lambda] = 1. + .2 I, \[Epsilon] = 0.1},
NIntegrate[
Exp[-I*\[Lambda]*(x + y)]*(x -
y)*((Sinh[Pi*(x + I*\[Epsilon])]*
Sinh[Pi*(y - I*\[Epsilon])])^-2 - (Sinh[
Pi*(x - I*\[Epsilon])]*
Sinh[Pi*(y + I*\[Epsilon])])^-2), {x, -Infinity,
Infinity}, {y, -Infinity, Infinity}]]

I hope this solves your problem. However you can see with Mathematica even
nasty seeming integrals sometimes behave quite like a easy one.

Regards,

Pratip

On Tue, Jun 29, 2010 at 12:59 PM, Peter Pein <petsie(a)dordos.net> wrote:

> Am Mon, 28 Jun 2010 06:29:45 +0000 (UTC)
> schrieb ofer <ofershl(a)gmail.com>:
>
> > hi,
> > i have a pretty nasty double integral which i need to solve
> > numerically but mathematica gives me error messages when i try to
> > solve it straightforward using NIntegrate
> >
> > the integrand is:
> >
> >
> Exp[-I*\[Lambda]*(x+y)]*(x-y)*((Sinh[Pi*(x+I*\[Epsilon])]*Sinh[Pi*(y-I*\[Epsilon])])^-2
> > -(Sinh[Pi*(x-I*\[Epsilon])]*Sinh[Pi*(y+I*\[Epsilon])])^-2)
> >
> > in the limits x=-infinity..infinity, y=-infinity..infinity
> >
> > with epsilon==>0
> >
> > i'm new to mathematica and will appreciate any suggestions
> >
>
> Assuming you replaced epsilon and lambda by numerical values, I can not
> understand why NIntegrate fails. If you didn't so, you'll get an error
> stating that the integrand is nowhere numeric. ("The integrand" ...
> "has evaluated to non-numerical values for all sampling points in the
> region with boundaries"...)
>
> Peter
>
>
>
From: Bill Rowe on
On 6/29/10 at 8:39 AM, ofershl(a)gmail.com (ofer) wrote:

>thanks peter. actually i don't get error messages but warnings like
>:

>NIntegrate::slwcon: Numerical integration converging too slowly; \
>suspect one of the following: singularity, value of the integration
>\ is 0, highly oscillatory integrand, or WorkingPrecision too small

So, try increasing WorkingPrecision or trying a different method
or both. No matter what is chosen for the default settings of a
numerical integration routine, they will never be adequate for
all possible integrals. NIntegrate allows for quite a bit of
customization in terms of precision, accuracy and methods used
to perform the integration.

>and the result i get is far from the accurate result obtained via
>analytic methods

Well the error message is stating there is a problem with
convergence. So, why would you expect the result to be accurate
with that error message? And if you have an accurate result
obtained by analytic methods, why bother with NIntegrate any further?

Doing integration problems is hard. It should never be
surprising that the built-in routines with default settings fail
for some integrals.