# integration using numerical solution

I would like to integrate numerically (as a closed form does not exist) the following function:

$f(x) = a + b (\exp(-g(x-d)^2)$ with respect to $x$

1. I would like to integrate from 0 to infinity
2. I'd like to evaluate the integral for various values of the parameters $a$, $b$, $g$, $d$ (these could be incremental from 0 to 100 in increments of 1 for example for each parameter)
3. Id like to save the results

Can someone give me some direction on this, please?

• Well, Mathematica has a closed form for it....Try the function Integrate[]. – Michael E2 Dec 14 '16 at 23:23
• @MichaelE2 How? It get that Integral of [....] does not converge on {0, Infinity}. Numerically I get integrals like $10^{27950}$ for some parameters. – corey979 Dec 14 '16 at 23:25
• @corey979 a == 0, g > 0. (I meant a closed form for the integral/antiderivative of f(x) w.r.t x, that is, just the first sentence. The "it" is ambiguous, mea culpa. Clearly integrating a nonzero constant over an infinite interval is not going to converge.) – Michael E2 Dec 14 '16 at 23:28
• @MichaelE2 Yes, of course... That's the second time in the last few days when I took the input from the OP without checking whether it makes sense. Time to get some more sleep I think. – corey979 Dec 14 '16 at 23:44

From the mathematical point of view, $a=0$ and $g>0$ for the integral to converge.

Numerical calculations (the long and hard way):

Clear@f
f[b_, g_, d_] := NIntegrate[b Exp[-g (x - d)^2], {x, 0, Infinity}]

{min, max, step} = {0, 100, 10};

int = Flatten[#, 2] & @
Quiet @ Table[{b, g, d, f[b, g, d]}, {b, min, max, step}, {g, min + step, max, step},
{d, min, max, step}]; // AbsoluteTiming


{3.56269, Null}

Length @ int


1210

Largest value:

Last /@ int // Max


56.0518

Part of the output:

int[[680 ;; 688]]


{{60, 20, 80, 0.}, {60, 20, 90, 0.}, {60, 20, 100, 0.}, {60, 30, 0, 9.70813}, {60, 30, 10, 19.4163}, {60, 30, 20, 19.4163}, {60, 30, 30, 0.}, {60, 30, 40, 0.}, {60, 30, 50, 0.}}

But there's a fast and easy way; because the integrand is Gaussian-like, there's an analytical integral:

h[b_, g_, d_] :=
Integrate[b Exp[-g (x - d)^2], {x, 0, Infinity},
Assumptions -> g > 0]

h[b, g, d]


For example

h[12, 4, 7] // N


10.6347