문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top