0
$\begingroup$

The form of my problem is as follows:

$\Psi=C\int_{-\infty}^\infty\int_{-\infty}^\infty\left(f(x,y)\times \left(\int_0^t g(x,t)dt\right)dxdy\right)$

I have already attempted numerical solutions using Matlab's integrate3, without success. However integrate3 is meant for problems of the form:

$\Psi=\int_a^b\int_c^d\int_e^f f(x,y,z)dxdydz$

Similarly, attempts made with scipy's integration toolkit have also not borne fruit.

I have attempted to first calculate $\int_0^tg(x,t)$ at discrete $x$ values and then place it in $\Psi$ but for rather obvious reasons that does not work either.

Additionally, $g(x,t)$ cannot be factored in the form of $h(x)\times i(t)$, which might have allowed for a by parts solution which might be integrated symbolically (for x) and numerically for t.

Also $\int_0^t\int_{-\infty}^{\infty} g(x,t)$ has singularities at multiple points.

Is there a mathematica method to solve this?

From the documentation I see mathematica seems to handle only region level integrations with integrate, so perhaps a linear solution in $t$ with a corresponding region integration over $x$ and $y$?

UPDATE

More specifically, I'm trying to reproduce the work of Shen et. al. so my equations are

shenPhiG[_g,_t]:= (1/(1+2(t/tc)))(1-Exp[(-2m*g/(1+2(t/tc)))])
shenU[_g]:=Exp[-(1+I*v)g]
NIntegrate[shenPhiG[g]*Exp[-I*(theta/tc)*NIntegrate[shenPhiG[g,t],{t,0,tf}]],{x, -Infinity, Infinity}, {y, -Infinity, Infinity}]

I've tried with tf as 5 or 10000 but I always get

NIntegrate::inumr : The integrand shenPhiG[g,t] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,1000}}.

UPDATE 2

The equations being modeled are given in the paper (in spherical coordinates, hence the reduction of integrals) as:

$\Theta=\frac{\theta}{t_c}\int_0^t\frac{1}{1+\frac{2t^\prime}{t_c}}\left[1-\mathrm{exp}\left(\frac{-2mg}{1+2\frac{t^\prime}{t_c}}\right)dt^\prime\right]$

and

$U_p=C\int_0^\infty \mathrm{exp}[-(1+\mathrm{i}V)g]\mathrm{exp}(-\mathrm{i}\Theta) dg$

With the approximation $\mathrm{exp}(-\mathrm{i}\Theta)\approx1-\mathrm{i}\Theta$

$U=C\int_0^{\infty}(1-\mathrm{i}\Theta)\mathrm{exp}[-(1+\mathrm{i}V)g]dg$

The form I've explained in the original question is obtained on converting to Cartesian coordinates.

Upon using

shenPhi[g_,t_]:=(1/(1+2(t/tc)))(1-Exp[(-2m*g/(1+2(t/tc)))])

and

shenU[g_]:=Exp[-(1+I*v)*g]NIntegrate[shenPhiG[g]*Exp[-I*(theta/tc)*
Integrate[shenPhiG[g,t], {t, 0, tf}]],
{g, -Infinity, Infinity}]

I get no output at all..

With

shenU[_g,t_]=Exp[-(1+I*v)*g]NIntegrate[shenPhiG[g]
*Exp[-I*NIntegrate[shenPhiG[g,t],{t,0,tf}]],{g,-Infinity,Infinity},{t,-Infinity,Infinity}

and

shenPhi[g_,t_]:=(theta/tc)(1/(1+2(t/tc)))(1-Exp[(-2m*g/(1+2(t/tc)))])

I get

NIntegrate::inumr: The integrand $\frac{1-\mathrm{exp}\left(-\frac{2g}{1+Times[<<2>>]} \right)}{1+\frac{t}{2542}}$ has evaluated to non-numerical values for all sampling points in the refion with boundaries {{0,50000}}.

Throw::nocatch: Uncaught Throw[-HolonomicDifferentialRootReduceDumpy[NIntegrateLevinRuleDumpx\$373597]+HolonomicDifferentialRootReduceDumpy'[NIntegrateLevinRuleDumpx\$373597],NIntegrateLevinRuleDumpFastLookupHolonomicDifferentialEquation] returned to top level.

$\endgroup$
  • $\begingroup$ Do you have formulas for $f(x,y)$ and/or $g(x,t)$, or are you trying to solve for them? It seems like NIntegrate can probably make a decent attempt at this problem directly, but depending on the form of $f(x,y)$ and $g(x,t)$, there may be better alternatives. $\endgroup$ – eyorble Nov 25 '17 at 23:35
  • $\begingroup$ I have equations for $g(x,t)$ and $f(x,y)$ but I'm worried about the fact that $x$ appears in $g(x,t)$ from where $x$ needs to obtained for the RHS. NIntegrate requires a range and also seems to meant for problems like integrate3 $\endgroup$ – HaoZeke Nov 25 '17 at 23:51
  • $\begingroup$ Mathematica can handle that form of problem. But not all such problems, since some integrands are intractable. -- Is the integral over $t$ indefinite (upper limit $t$), or is that a typo? $\endgroup$ – Michael E2 Nov 25 '17 at 23:51
  • $\begingroup$ No, it's meant to be $t$ (indefinite), in practice t is bound by an upper value, around 5000 (5s). $\endgroup$ – HaoZeke Nov 26 '17 at 1:53
  • $\begingroup$ Is the _g in shenPhiG[_g,... a typo? If not, it's an error. You should have g_ instead of _g. $\endgroup$ – Michael E2 Nov 26 '17 at 1:57
1
$\begingroup$

You said you have definitions for $f(x,y)$ and $g(x,t)$ already, so the first step to trying to solve this problem with Mathematica would be to attempt the numerical integral directly after setting tf to the upper bound of the inner integral:

NIntegrate[f[x,y] NIntegrate[g[x,t], {t, 0, tf}],
   {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]

Due to the nested integrals, this may be a fairly slow calculation. It may be better to see if Integrate can find a reasonably closed form of the inner integral first:

NIntegrate[f[x,y] Evaluate[Integrate[g[x,t], {t, 0, tf}]],
   {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]

Though from the sounds of it, $g(x,t)$ probably won't allow that to be effective.

If tf is meant to be left as a variable, then numerical integration methods aren't going to be appropriate for solving this problem.

To provide further advice, examples of $f(x,y)$ and $g(x,t)$ of equivalent complexity to the problem you're trying to solve would be necessary.


shenPhi[_g,_t]:=(1/(1+2(t/tc)))(1-Exp[(-2m*g/(1+2(t/tc)))])

Is actually a nonsensical declaration, since function definitions are divided into name_pattern, and thus the first and second arguments are actually nameless as it stands. Since this is going to be a numerical integration problem, ensure that tc and m have numerical values declared elsewhere and change that line to:

shenPhi[g_,t_]:=(1/(1+2(t/tc)))(1-Exp[(-2m*g/(1+2(t/tc)))])

Then based on your additional information, ensure that all constants also have numerical values and evaluate the integral:

shenU[g_]:=Exp[-(1+I*v)*g]NIntegrate[shenPhiG[g]*Exp[-I*(theta/tc)*
    Integrate[shenPhiG[g,t], {t, 0, tf}]],
    {g, -Infinity, Infinity}, {y, -Infinity, Infinity}]

Clearly x needed to be changed to g to match the problem definition, but I'm not clear on which variable y is supposed to match -- so that will need to be changed as well.

It also appears from a preliminary inspection that the inner integral will need to be Integrate rather than NIntegrate, as the inner NIntegrate won't generally have a value for g to plug in.

$\endgroup$
  • $\begingroup$ Updated the question with more details... $\endgroup$ – HaoZeke Nov 26 '17 at 1:01
  • $\begingroup$ @HaoZeke: Updated answer, hope this helps more, but I don't have access to that article at the moment and there's still some ambiguity in your code (y doesn't appear anywhere but the second integration variable, which value is it supposed to be?) $\endgroup$ – eyorble Nov 26 '17 at 1:11
  • $\begingroup$ Ah, I'm sorry, I'll update the question again... @eyorble $\endgroup$ – HaoZeke Nov 26 '17 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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