emper
emper

Reputation: 401

infinite integration with matlab

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?

Upvotes: 3

Views: 8639

Answers (2)

Rody Oldenhuis
Rody Oldenhuis

Reputation: 38032

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

Upvotes: 5

Steve Tjoa
Steve Tjoa

Reputation: 61054

Symbolic toolbox.

syms u
int(exp(-u)*u, u, 0, inf)

Upvotes: 2

Related Questions