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

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?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer

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.