title: Solving an integral in R gives error "The integral is probably divergent"
body: <p>I am trying to solve an integral in R. However, I am getting an error when I am trying to solve for that integral. </p>
  
  <p>The equation that I am trying to solve is as follows:</p>
  
  <pre><code>$$ C_m = \frac{{abs{x}}e^{2x}}{\pi^{1/2}}\int_0^t t^{-3/2}e^{-x^2/t-t}dt $$
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Bka7l.png" alt="enter image description here"></p>
  
  <p>The code that I am using is as follows:</p>
  
  <pre><code>a &lt;- seq(from=-10, by=0.5,length=100)
  
  ## Create a function to compute integration
  Cfun &lt;- function(XX, upper){
    integrand &lt;- function(x)x^(-1.5)*exp((-XX^2/x)-x)
    integrated &lt;- integrate(integrand, lower=0, upper=upper)$value
    (final &lt;- abs(XX)*pi^(-0.5)*exp(2*XX)*integrated) }
  
  
  b&lt;- sapply(a, Cfun, upper=1)
  </code></pre>
  
  <p>The error that I am getting is as follows:</p>
  
  <pre><code>Error in integrate(integrand, lower = 0, upper = upper) : 
    the integral is probably divergent
  </code></pre>
  
  <p>Does this mean I cannot solve the integral ? </p>
  
  <p>Any possible ways to fix this problem will be highly appreciated. </p>
  
  <p>Thanks. </p>