The aim is to calculate the definite integral of the function $f$ of the form $$f(x,t) \;\;\;\; x \in [0, \infty ) \;\;, \;\;t \in [t_0,T]$$ numerically. For example consider the function below $$f = e^{-xt}$$

For each $t_i$ belongs to interval $[t_0, T]$, there is an integral like this:

$$\int_{0}^{\infty} f(x, t) dx \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;(*)$$

If the interval of $[t_0,T]$ divided to $n$ equal part, then we have $n$ integral of the form $(*)$ where $t_i$ is the lower bound of each interval. Also I'm willing to plot the result of $n$ integration.

In MATLAB it's easy to code the above integral; by defining a for loop, one can deal with sweeping t over interval $[t_0,T]$.

          for t = t0 : 0.01 : T 
              fun = @(x) f(x, t);
              q = integral(fun,0,Inf);

I familiar with the command "Integrate" (in Mathematica) but I can't sweep t over interval.

How can I do this?


1 Answer 1


See if this helps:

f[x_, t_] := E^(-x t);
Table[NIntegrate[f[x, t], {x, 0, \[Infinity]}], {t, t0, T, 0.01}]

Because this is a numerical integration, you need to define t0 and T before integration. Otherwise you can replace NIntegrate with Integrate and that should be fine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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