0
$\begingroup$

My code goes as follows:

\[Alpha] = 1; n = 2;
g[\[Omega]_] = PDF[NormalDistribution[\[Alpha], n*\[Alpha]], \[Omega]]
f[t_] := NIntegrate[g[\[Omega]]*Exp[I*(\[Alpha] - \[Omega])*(t)], {\[Omega], 0, 10}]

Everything is fine up to this point. And, finally, I want to evaluate:

NDSolve[{G'[t] + NIntegrate[f[t - v]*G[v], {v, 0, t}] == 0, G[0] == 1}, G, {t, 0, 1}]

But, I get error:

NIntegrate::inumr: The integrand E^(-I v (1-[Omega])-1/8 (-1+[Omega])^2)/(2 Sqrt[2 [Pi]]) has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,10}}. ...... x3

General::stop: Further output of NIntegrate::inumr will be suppressed during this calculation.

Why is it unable to evaluate this integral numerically?

$\endgroup$
2
  • $\begingroup$ I'm not at a computer with Mathematica right now, but maybe try replacing f[t_] with f[t_?NumericQ]. This often fixes problems of this type. $\endgroup$ Sep 1, 2021 at 2:00
  • $\begingroup$ Already tried that, same error appears $\endgroup$
    – NiRVANA
    Sep 1, 2021 at 2:15

1 Answer 1

1
$\begingroup$

I don't know why Mathematica doesn't solve, but I can provide a workaround to get an approximated solution:

\[Alpha] = 1; n = 2;
g[\[Omega]_] = PDF[NormalDistribution[\[Alpha], n*\[Alpha]], \[Omega]]

First f[t] can be evaluated symbolically

f = Function[{t},Integrate[g[\[Omega]]*Exp[I*(\[Alpha] - \[Omega])*(t)], {\[Omega], 0, 10}] //Evaluate]
(*Function[{t},1/2 E^(-2 t^2) (-Erf[(-1 + 4 I t)/(2 Sqrt[2])] +Erf[(9 + 4 I t)/(2 Sqrt[2])])]*)

Integrating your ode gives the integralequation

G[t]==1+Integrate[G[v] f[tau-v] , {\[Tau], 0, t} , {v, 0, \[Tau]}]

which is solved iteratively (Piccard iteration seems to converge)

ti = Subdivide[0, 1, 50]; (*discretisation*)
Clear [gip]
gip[G_] := 
Block[{ t, \[Tau], v},
Interpolation[Table[{t,1 - NIntegrate[
   G[v] f[\[Tau] - v] , {\[Tau], 0, t} , {v, 0, \[Tau]}] },
{t,ti}] ]]

sol = NestList[gip, 1 &, 5]; (*complex solution*)

Show[{Plot[ReIm[Through[sol[t]]] // Evaluate, {t, 0, 1}], 
Plot[ReIm[ sol[[-1]][t]] // Evaluate, {t, 0, 1},PlotStyle -> {{Dashed ,Black}, {Dotted , Black}}]}]

enter image description here

Hope it helps!

$\endgroup$
3
  • $\begingroup$ Could you please explain the plot a little bit? What exactly are the colored lines and why two of them? $\endgroup$
    – NiRVANA
    Sep 8, 2021 at 4:19
  • $\begingroup$ Also, what exactly is 1& used for? $\endgroup$
    – NiRVANA
    Sep 8, 2021 at 5:37
  • $\begingroup$ And, shouldn't it be "1+ NIntegrate" rather than "1 -NIntegrate"? $\endgroup$
    – NiRVANA
    Sep 8, 2021 at 5:46

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.