Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
Plot[Integrate[Sin[6.28*10^10 x]/(-x + t)
   (1 + (-0.99995*(3.33*10^-8 - 0.99995 x) + 
     22.4 Sin[1.256*10^11 x])/
    ((3.33*10^-8 - 0.99995 x)^2 + 
      7.13*10^-10 (Sin[6.28*10^10 x])^2)^0.5)*
  x -  t + ((3.33*10^-8 - 0.99995 x)^2 + 
       7.13*10^-10*(Sin[6.28*10^10 x])^2)^(1/2)], {x,0, 0,5*10^-9}], {t, 0, 0.001}] 

I tried evaluating the above expression, but takes forever. Am I doing it right? Should I use NIntegrate

Plot[f[t], {t, 0, 0.0001}]

Then (took~20hrs)

enter image description here

Could I get better plot from this?

share|improve this question
Before try to plot the results of the integration, you should evaluate the Integrate expression at top-level. You will (quickly) find it does't work. – m_goldberg Jul 3 '14 at 21:21
Yes I tried to evaluate Integrate at top-level, but neither work – user16308 Jul 3 '14 at 21:23
For {t -> 0.0005, x -> 10^-9} the argument of DiracDelta has a nonzero imaginary component and the DiracDelta function is undefined. Perhaps you should check your formula. – Michael E2 Jul 4 '14 at 1:45
Michael E2: Nope. t->0.0001 is for plot range and x->10^-9 is for the integration range – user16308 Jul 4 '14 at 7:57
...So the DiracDelta would have an argument that complex with a nonzero imaginary part. AFAIK, the delta function is undefined for nonreal arguments. I thought you might know of such a definition. But now you have changed the formula to eliminate the problem, without indicating that you have done so -- that seems rather DISHONEST! – Michael E2 Jul 8 '14 at 12:17

with the fix, Integrate works, the trick is you need to Integrate for numerical values of t: (Primarily I'm posting this because i was surprised it works )

 f[t_?NumericQ] := f[t] =   Integrate[ ..., {x, 0, 5*10^-9}]

I'm using ListPlot on a small table here so I can control exactly the points that get calculated -- This should work with Plot but I expect it might take hours. (5-10 minutes as is)

 ListPlot[Table[ {t, f[t]} , {t, 0, 2/100000, 1/1000000}], 
      Joined -> True, PlotRange -> All]

enter image description here

note I'm not at all confident this is accurate.. the argument of your DiracDelta has a few dozen roots for each t.

simpler example

To see how this works here is a cleaner example of the same form:

 g[x_] = x^3;
 f[x_] = x Cos[x + Pi/4];
 Integrate[g[x]  DiracDelta[f[x] ] , {x, -2 Pi, 2 Pi }]

-2 Pi^2

the argument to DiracDelta , f[x] has five roots in the integration domain:

 fxroots = {  -7 Pi/4  , -3 Pi/4, 0 , Pi/4  , 5 Pi/4 };

after finding the roots the integral is reduced to the sum of the following values at the roots:

 g[x]/Abs[f'[x]] /. x -> # & /@ fxroots

{-((49 Pi^2)/16), -((9 Pi^2)/16), 0, Pi^2/16, ( 25 Pi^2)/16}

which totals to the value obtained by Integrate


-2 Pi^2

For the example in he question f[x] is highly oscillatory with ~20 roots that need to be numerically determined for each t, which is why its so slow..

share|improve this answer
I got 199 roots at some point. I suppose one needs to worry about multiple roots, too.... – Michael E2 Jul 9 '14 at 18:57
i did too, somewhere in the edit trail he threw in a factor of 10 .. – george2079 Jul 9 '14 at 22:55
Isn't it the case that if a multiple root appears inside DiracDelta there's a problem. Consider Integrate[x DiracDelta[(x - 3)^2], {x, 0, 4}]. If the argument of DiracDelta is written f[x] - t, it seems there are many values of t, one for every minimum of f[x], that give such a double root. I think an accurate graph will take some effort to obtain. – Michael E2 Jul 11 '14 at 4:10
@MichaelE2 the integral blows up at the repeated root because the first derivative is zero. – george2079 Jul 11 '14 at 14:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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