I am trying to evaluate the following expression numerically $$\frac{d^2}{dt^2}e^{-2t^2}\int_0^\infty\frac{\xi/\sqrt{2}}{\xi^{3/2}}e^{(-\xi^2/2-2\xi t))}$$

My code is as follows

Der[t_] := f''[t]

But when I evaluate, say by entering


I am getting an error that the integrand has evaluated to non-numerical values for all sampling points in the region. Now I know that this is a common error, and other threads have revealed that this is happening because Mathematica is not recognizing something in my expression (likely $\xi$) as a numerical variable. However, I am not sure how I would go about fixing this. I have tried putting in ?NumericQ beside all instances of $\xi$ but that didn't seem to work.

How would I go about numerically evaluating this expression (and ideally, plotting it as a function of t) without the NIntegrate::inumr error?

Thank you in advance!

  • $\begingroup$ Why not simplify the integrand by dividing out $\xi$ and bringing out constants? And you need a $d \xi$ within the integral. $\endgroup$ Feb 9, 2017 at 20:59

2 Answers 2


f[t_?NumericQ] := 
    Exp[-(ξ^2/2) - 2*ξ*t], {ξ, 0, Infinity}]

Use ND

Der[t_?NumericQ] := ND[f[x], {x, 2}, t]


(*  3.41091*10^-20  *)
  • $\begingroup$ @PratikSamant - I just copied and pasted and evaluated without any problems. You apparently have problems with prior definitions. Either clear all variables or start with a fresh kernel. $\endgroup$
    – Bob Hanlon
    Feb 13, 2017 at 16:51

Notice: my formula contains a sign error (-t instaed of +t). But the derivation is still valid. Only the final numeric value must be taken at t = -5.

The integral can be written as

f[t_] := 
 NIntegrate[\[Xi]^(-3/2 )
    Erf[\[Xi]/Sqrt[2]] Exp[-(1/2) (\[Xi] - 2 t)^2], {\[Xi], 
   0, \[Infinity]}]

Let us form the second derivative with respect to t under the integral:

D[Exp[-1/2 (\[Xi] - 2 t)^2], {t, 2}]

(* Out[22]= -4 E^(-(1/2) (-2 t + \[Xi])^2) + 
 4 E^(-(1/2) (-2 t + \[Xi])^2) (-2 t + \[Xi])^2 *)

and call f''[t] = f2[t] which is

f2[t_] := 
 NIntegrate[\[Xi]^(-3/2 )
    Erf[\[Xi]/Sqrt[2]] 4 E^(-(1/
     2) (-2 t + \[Xi])^2) (-1 + (-2 t + \[Xi])^2), {\[Xi], 
   0, \[Infinity]}]

The value requested is then


(* Out[24]= 0.0129202 *)

This is very different from Bob Hanlon's result which is, in fact


(* Out[30]= 3.43309*10^-20 *)

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.