1
$\begingroup$

I am trying essentially to compute a fourier transform with Integrate.

1]Is integrate faster or slower than FourierTransform?

2]Does anyone know how to efficiently calculate these integrals?

My code is the following

$Assumptions = {h > 0, d > 0, p0 >= 0, s > 0, M > 0, 
  L2 \[Element] Reals, dt \[Element] Reals, x \[Element] Reals, 
  y \[Element] Reals, z \[Element] Reals, p \[Element] Reals, 
  Dxx >= 0, Dpp >= 0}

h = 1
d = 100
s = 3
M = 1
p0 = 0
L2

xGpiu[x_] := xGpiu[x] = 
  Exp[-(x - d/2)^2/(2 s^2) + (I*(-p0)*(x - d/2))/(h)]/(Pi^(1/4)*Sqrt[s])

xGpiuconj[x_] :=  xGpiuconj[x] = 
  Exp[-(x - d/2)^2/(2 s^2) - (I*(-p0)*(x - d/2))/(h)]/(Pi^(1/4)*Sqrt[s])

pGpiu[p_] :=  pGpiu[p] = 
  Integrate[ xGpiu[x]*Exp[-I*p*x/h]/Sqrt[2*Pi*h], {x, -\[Infinity], +\[Infinity]}]

pGpiu[p]

pGpiuconj[p_] := Integrate[xGpiuconj[x]*Exp[+I*p*x/h]/Sqrt[2*Pi*h], {x, -\[Infinity], +\[Infinity]}]
pGpiuconj[p]

XZUtGpiu[x_, z_, Dt_] := XZUtGpiu[x, z, Dt] = 
  Integrate[
   pGpiu[p]*Exp[-I*p^2*Dt/(2*M*h)]*
    Exp[I*p*(x - z)/h]/(Sqrt[2*Pi*h]), {p, -\[Infinity], +\[Infinity]}]

XZUtGpiu[x, z, dt]

GpiuUtdagYZ[y_, z_, Dt_] := GpiuUtdagYZ[y, z, Dt] = 
  Integrate[
   pGpiuconj[p]*Exp[+I*p^2*Dt/(2*M*h)]*
    Exp[-I*p*(y - z)/h]/(Sqrt[
       2*Pi*h]), {p, -\[Infinity], +\[Infinity]}]

GpiuUtdagYZ[y, z, dt]

XDecPiupiutY[x_, y_, Dt_] := XDecPiupiutY[x, y, Dt] = 
  Integrate[
   Exp[I/h*Dpp*Dt^2/M*z*(x - y)/L2]*Exp[-z^2/(2*L2)]*
    XZUtGpiu[x, z, Dt]*
    GpiuUtdagYZ[y, z, Dt], {z, -\[Infinity], +\[Infinity]}]

XDecPiupiutY[x, y, dt]

The first integrals are computed within seconds, while the last one, XDecPiupiutY[x, y, dt], does not come out with an output in hours.

Thank you in advance to anybody who will respond.

$\endgroup$
3
  • 7
    $\begingroup$ I am not sure this is the reason, but Dt is a reserved symbol in Mathematica. It stands for total derivative, so maybe change the variable. $\endgroup$
    – mattiav27
    Commented Jul 8 at 14:36
  • $\begingroup$ Evaluation of the indefinite integral shows there is no problems with Dt, a function name, in a Pattern $\endgroup$
    – Roland F
    Commented Jul 9 at 7:12
  • $\begingroup$ Evaluating the integrand Exp[I/h*Dpp*Dt^2/M*z*(x - y)/L2]*Exp[-z^2/(2*L2)]* XZUtGpiu[x, z, Dt]* GpiuUtdagYZ[y, z, Dt] of the last integral, Mathematica 12.2 shows a condition -9 < Im[Dt] < 9 . What is the parameter range of Dt to be condidered? $\endgroup$ Commented Jul 9 at 10:01

1 Answer 1

0
$\begingroup$

You ran into the mess that Mathematica has with its definite integral input check. They try a list of known algorithms, primarily in the real line residues.,

The alternative of doing the indefinite integral, evaluating the difference at the boundaries, seems to be so obvious to a mathematician, that he forgets that users from applied sciences often lack the basics.

If the result contains roots, use an assumption, that all symbols are PositiveReals.

I use

    PositiveIntegrate[expr_, range_,opt___] := 
      Integrate[expr, range, opt,
        Assumptions -> (# > 0 &) /@ 
            Union[Cases[{expr, range}, _Symbol, \[Infinity]]]] 

   Timing[XZUtGpiu[x, z, dt]] 

$$\left\{3.45313, \frac{1}{\sqrt[4]{\pi } \sqrt{s+\frac{i \text{dt} h}{M s}}}\exp \left(\frac{i \left(d^2 h M+4 d M \left(h (z-x)-i \text{p0} s^2\right)+4 i \text{dt} \text{p0}^2 s^2+4 M (x-z) \left(h x-h z+2 i \text{p0} s^2\right)\right)}{8 h \left(\text{dt} h-i M s^2\right)}\right)\right\} $$

Evaluating the indefinite integral and taking the difference at the infinities works even faster, but again has indefinite erf functions at the infinities with coefficients of complicated function of the free coefficients.

Mathematicas course is to Reduce the value expression - mostly by its residues - by the construction of a logical decision tree. In all cases with more that 4 free parameters the desired complete solution may not be representable on a normal computer in finite memory in finite time.

Sometimes even a worked out result challanges the rendering process on a machine. Work araound: calculate complex results without screen output by teminating ";" and inspect the result by Parts: res[[0]] = Header, res[[1,0]] = Header of first argument.

$\endgroup$
2
  • $\begingroup$ Thank you. Do i need to specify the assumptions in Integrate[] even if I already stated them at the beginning? $\endgroup$
    – GJ P
    Commented Jul 9 at 13:58
  • $\begingroup$ There was always a conflict of strategies with Assuming, $Assumptions and Assumptions->. Reduce e.g. neclects Assumptions under the assumption to act locally with a complete set of relations in its argument. One should spent an afternoon with execises for Integrate, Solve, Reduce etc $\endgroup$
    – Roland F
    Commented Jul 9 at 15:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.