3

I want to compute the following type of integrals in Matlab.

\int _{0}^\infty e^{-(u*u)} du

It is the integral of function e^-(u)*u and the boundaries are zero and infinity. This integral should return 1.

How can I do this in Matlab?

Mohammad nagdawi
  • 553
  • 4
  • 18
emper
  • 401
  • 1
  • 7
  • 14
  • The integrand that you show in the formula is e^(-u*u), not e^(-u)*u. You should edit the formula in the question – lucianopaz Dec 19 '16 at 13:05

2 Answers2

5

And if you don't have the symbolic toolbox, or want more speed, quadgk supports infinite limits:

f = @(x) x.*exp(-x);
a = quadgk(f, 0, inf) 

a =
    1.000000000000000e+00
Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
2

Symbolic toolbox.

syms u
int(exp(-u)*u, u, 0, inf)
Steve Tjoa
  • 59,122
  • 18
  • 90
  • 101