hi I've search and read but I couldn't solve this one in matlab. please help me out to solve this problem integral_0^1 x^n e^(x-1) dx
Asked
Active
Viewed 251 times
-4
-
first of all, you should show your effort so far. second, on SO latex syntax is not supported. third, `n` stays variable or not? You should clarify your question. It's easy to figure it out, but you should sort it in a clearer way. – fpe Apr 15 '13 at 19:18
1 Answers
1
Generally, you can use different approaches to calculate the required integral:
1) Symbolic Toolbox --> I'd go for this one because of considerations on n
syms x n;
f = x.^n.*exp( x - 1 );
int(f,0,1)
2) quad
, integral
functions
g = @(n) (integral(@(x) x.^n.*exp(x-1),0,1));
g = @(n) (quad(@(x) x.^n.*exp(x-1),0,1));
Then you can evaluate the result depending on n
.
3) trapz
function
x = 0:.001:1;
y = x.^n.*exp( x - 1 );
trapz(x,y)
But, in this specific case, the calculation of the integral is driven by the exponent n
.
Since I suppose and assume that you know how the integral of 'x.^n' behaves for different n
, I will skip the discussion.

fpe
- 2,700
- 2
- 23
- 47