## Reasonable integration speed? (24 hrs and counting)

### Reasonable integration speed? (24 hrs and counting)

I downloaded the trial version of Mathematica to see if it could
solve a complex integral. After getting comfortable with solving
simple integrals, I input my target problem:

In[1]:= f[x] = Sqrt[a^2+(q-x)^2]

In[2]:= Integrate[Cos[(2*n + 1)*Pi*x/d]*
(Exp[-I*k*f[x]]/(4*Pi*f[x]^5)*((1 + I*k*f[x])*(2*f[x]^2 - 3*a^2)
+ (k*a*f[x])^2) * I*d/(2*Pi* w) + p), {x, -d/2, d/2}]

Observations:

1. It's been sitting there for over 24 hours now.

2. Task Manager shows Mathematica's CPU usage at a constant 50%.

3. The "Kernel" pull-down menu has "Interrupt Evaluation" grayed out.
I can abort it.

4. Mathematica won't solve any subsequent problem in another window
(seems like the first one is occupying a queue).

Earlier I tested some simple function-reference integrals (e.g.
defining f[x] first and then integrating f[x]dx) and they worked.

What sort of speed can I expect from this? Is 24 hours too long to
solve a problem like this on a 2.6 GHz Windows XP platform with 1.25
GB RAM? Is Mathematica hung up on something? Is the fact that I'm
using the trial version make any difference? Did I do something
wrong?

Thanks.
-Alex

### Reasonable integration speed? (24 hrs and counting)

i Alex

I think you have a problem. My Mathematica installation solved the
integral in about 3 seconds, here's the solution (in CellExpression
form)

Cell[BoxData[
RowBox[{
SubsuperscriptBox["\[Integral]",
RowBox[{"-",
FractionBox["d", "2"]}],
FractionBox["d", "2"]],
RowBox[{
RowBox[{
RowBox[{"Cos", "[",
FractionBox[
RowBox[{
RowBox[{"(",
RowBox[{"1", "+",
RowBox[{"2", " ", "n"}]}], ")"}], " ", "\[Pi]",
" ", "x"}], "d"], "]"}], " ",
RowBox[{"(",
RowBox[{"p", "+",
RowBox[{
FractionBox["1",
RowBox[{"8", " ",
SuperscriptBox["\[Pi]", "2"], " ", "w", " ",
SuperscriptBox[
RowBox[{"f", "[", "x", "]"}], "5"]}]],
RowBox[{"(",
RowBox[{"\[ImaginaryI]", " ", "d", " ",
SuperscriptBox["\[ExponentialE]",
RowBox[{
RowBox[{"-", "\[ImaginaryI]"}], " ", "k", " ",

RowBox[{"f", "[", "x", "]"}]}]], " ",
RowBox[{"(",
RowBox[{
RowBox[{
SuperscriptBox["a", "2"], " ",
SuperscriptBox["k", "2"], " ",
SuperscriptBox[
RowBox[{"f", "[", "x", "]"}], "2"]}], "+",

RowBox[{
RowBox[{"(",
RowBox[{"1", "+",
RowBox[{
"\[ImaginaryI]", " ", "k", " ",
RowBox[{"f", "[", "x", "]"}]}]}],
")"}], " ",
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"-", "3"}], " ",
SuperscriptBox["a", "2"]}], "+",
RowBox[{"2", " ",
SuperscriptBox[
RowBox[{"f", "[", "x", "]"}],
"2"]}]}], ")"}]}]}], ")"}]}],
")"}]}]}], ")"}]}],
RowBox[{"\[DifferentialD]", "x"}]}]}]], "Output",
CellLabel->"Out[1]="]

and again as plain text, which you may prefer

Out[1]=
\!\(\[Integral]\_\(-\(d\/2\)\)\%\(d\/2\)\(Cos[\(\((1 + 2\ n)\)\ \[Pi]\
\
x\)\/d]\ \((p + \(\(1\/\(8\ \[Pi]\^2\ w\ f[x]\^5\)\)\((\[ImaginaryI]\
d\ \
\[ExponentialE]\^\(\(-\[ImaginaryI]\)\ k\ f[x]\)\ \((a\^2\ k\^2\
f[x]\^2 + \
\((1 + \[ImaginaryI]\ k\ f[x])\)\ \((\(-3\)\ a\^2 +
2\ f[x]\^2)\))\))\)\))\)\)
\[DifferentialD]x\)

Hope this helps

Mark Westwood
Parallel Programmer

axlq wrote:

### Reasonable integration speed? (24 hrs and counting)

Hi,

ave you considered the possibility, that your
"complex integral" does not have a analytical
solution?

Regards
Jens

"axlq" < XXXX@XXXXX.COM > schrieb im Newsbeitrag

see if it could
| solve a complex integral. After getting
comfortable with solving
| simple integrals, I input my target problem:
|
| In[1]:= f[x] = Sqrt[a^2+(q-x)^2]
|
| In[2]:= Integrate[Cos[(2*n + 1)*Pi*x/d]*
| (Exp[-I*k*f[x]]/(4*Pi*f[x]^5)*((1 +
I*k*f[x])*(2*f[x]^2 - 3*a^2)
| + (k*a*f[x])^2) * I*d/(2*Pi* w) + p),
{x, -d/2, d/2}]
|
| Observations:
|
| 1. It's been sitting there for over 24 hours
now.
|
| 2. Task Manager shows Mathematica's CPU usage at
a constant 50%.
|
| 3. The "Kernel" pull-down menu has "Interrupt
Evaluation" grayed out.
| I can abort it.
|
| 4. Mathematica won't solve any subsequent
problem in another window
| (seems like the first one is occupying a
queue).
|
| Earlier I tested some simple function-reference
integrals (e.g.
| defining f[x] first and then integrating f[x]dx)
and they worked.
|
| What sort of speed can I expect from this? Is
24 hours too long to
| solve a problem like this on a 2.6 GHz Windows
XP platform with 1.25
| GB RAM? Is Mathematica hung up on something?
Is the fact that I'm
| using the trial version make any difference?
Did I do something
| wrong?
|
| Thanks.
| -Alex
|

### Reasonable integration speed? (24 hrs and counting)

Hi

My version of Mathematica cant solve this integral (it gets returned
unevaluated),
to I guess your kernel simply hang up (happens occasionaly).

In[19]:=
Integrate[
Cos[(2*n+1)*Pi*
x/d]*(Exp[-I*k*f[x]]/(4*Pi*
f[x]^5)*((1+I*k*f[x])*(2*f[x]^2-3*a^2)+(k*a*f[x])^2)*I*
d/(2*Pi*w)+p),{x,-d/2,d/2}]

Out[19]=
\!\(\[Integral]\_\(-\(d\/2\)\)\%\(d\/2\)\(Cos[\(\((1 + 2\ n)\)\ \[Pi]\
\
x\)\/d]\ \((p + \(\(1\/\(8\ \[Pi]\^2\ w\ f[x]\^5\)\)\((\[ImaginaryI]\
d\ \
\[ExponentialE]\^\(\(-\[ImaginaryI]\)\ k\ f[x]\)\ \((a\^2\ k\^2\
f[x]\^2 + \
\((1 + \[ImaginaryI]\ k\ f[x])\)\ \((\(-3\)\ a\^2 +
2\ f[x]\^2)\))\))\)\))\)\)
\[DifferentialD]x\)

Bye Ben

axlq schrieb:

### Reasonable integration speed? (24 hrs and counting)

Update: Going on 48 hours now. I'm concerned that something is
hung, but I fear aborting the job if there's any chance it may
actually be progressing to a solution. I'm unfamiliar with what I
can expect in terms of Mathematica's speed of solving an integral.
Is this reasonable? Is there a setting somewhere that shows some
sort of progress indicator?

-Alex

### Reasonable integration speed? (24 hrs and counting)

Observations:

1. To paraphrase Barbie ( http://www.yqcomputer.com/ ),
"integration is hard".

2. Let's break down your problem. First, the term involving p

Integrate[Cos[(2 n + 1) Pi x/d] p, {x, -d/2, d/2}]

is trivial. Next, can you compute, or do you expect to be able to compute

Integrate[Cos[(2n + 1) Pi x/d] Exp[-I k f[x]], {x, -d/2, d/2}] ?

This integral, even though it appears to be simple, is non-trivial. I
suspect that it can be computed via Bessel functions.

3. Rescaling variables simplifies this integral slightly.

4. If you can compute this integral, then you can solve your target
problem using parametric differentiation. Why? Because it is easy to
verify that

(1/a) D[(1/a) D[a D[Exp[-I k f[x]], a] - 2 Exp[-I k f[x]], a], a]

multiplied by the constant

d/(8 k Pi^2 w)

(a combination of terms only involving differentiation with respect to
a) equals the "difficult" part of your target problem,

Exp[-I k f[x]]/(4 Pi f[x]^5) ((1 + I k f[x]) (2 f[x]^2 - 3 a^2) +
(k a f[x])^2) I d/(2 Pi w))

5. Note that Sqrt[a^2+(q-x)^2] is the distance between {q,a} and {x,0}.
This suggests possible change of variables so as to simplify the
integral.

Cheers,
Paul

_______________________________________________________________________
Paul Abbott Phone: 61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://www.yqcomputer.com/ ~paul

### Reasonable integration speed? (24 hrs and counting)

Hi Alex,

I think you can abort the evaluation. Here is what I get on my system:

f[x] = Sqrt[a^2 + (q - x)^2]

Integrate[Cos[(2*n + 1)*Pi*(x/d)]*((Exp[(-I)*k*f[x]]/(4*Pi*f[x]^5))*((1
+ I*k*f[x])*(2*f[x]^2 - 3*a^2) + (k*a*f[x])^2)*I*(d/(2*Pi*w)) + p), {x,
-d/2, d/2}]

displays after several minutes

Integrate::"gener" : "Unable to check convergence.

(I aborted the still running evaluation loop after that.)

\$Version
"5.2 for Microsoft Windows (June 20, 2005)"

Regards,
Jean-Marc

### Reasonable integration speed? (24 hrs and counting)

In article <e9q8sd\$7h1\$ XXXX@XXXXX.COM >,

If that's the case, will Mathematica run forever or eventually give up,
telling me it can't find a solution? What's a reasonable time to wait?

-A

### Reasonable integration speed? (24 hrs and counting)

In article <e9q95s\$7o9\$ XXXX@XXXXX.COM >,

This happens for me too if I don't input the first part of the
problem which defines f[x]:

And then

Defining f[x], or substituting the expression for f[x] into the
integral, results in mathematica not returning a result in 2 days.

I suspect it can only be solved numerically, given specific values
for all the constants.

-A

### Reasonable integration speed? (24 hrs and counting)

In article <e9qabo\$8bl\$ XXXX@XXXXX.COM >,

What I did was use Mathematica's Expand[] function to break down
the integrand into individual terms. I got 13 terms, the first
of which was the trival one you describe above. All the others
have one of these 6 forms:

c1 I Exp[-I k f] Cos[c2 x] / f^5
c1 I Exp[-I k f] x Cos[c2 x] / f^5
c1 I Exp[-I k f] x^2 Cos[c2 x] / f^5
c1 Exp[-I k f] Cos[c2 x] / f^4
c1 Exp[-I k f] x Cos[c2 x] / f^4
c1 Exp[-I k f] x^2 Cos[c2 x] / f^4

...where c1 and c2 are constants, and f = Sqrt[a^2+(q-x)^2].

As you said, these are non-trivial to solve. Mathematica seems to
get hung up on any of them.

Thanks for the suggestions. I think I will have to resort to
numerical integration for this one. I was hoping to get a
closed-form solution.

This is eventually going into some Visual Basic code, in which I
have to manage the real and imaginary parts myself.

-Alex

### Reasonable integration speed? (24 hrs and counting)

In article <e9rhl6\$p7k\$ XXXX@XXXXX.COM >,

Hmmm... I never got any such message. Oh, well, I did abort it
after I broke it down into several simpler terms using Expand[] and
discovered Mathematica couldn't integrate most of them. At least it
gave me output eventually; after an hour or it gave back the same
thing I input.

Now I'm writing a routine in Visual Basic for Excel solve it
numerically.

-Alex