How can I evaluate a complex definite integral?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello;
I would appreciate if anyone can help me with this problem. I am working in a project, and I was asked to evaluate the next definite integral
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1199233/image.jpeg)
The constants are:
k= 1.380649e-23
h=6.6226069e-34
T=6000
fg2= 484e12
I tried first to evaluate the integral and then multiply the result with the rest of the equation, but I cannot do it. I am a bit new in Matlab, I tried using Live Script. The result should be 0.2952
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1199238/image.png)
Thanks for the help in advance
syms f
k= 1.380649e-23
h=6.6226069e-34
T=6000
fg2= 484e12
n= (f^2/(exp(h*f/k*T)-1))
%Integral
n2=int(n,0,inf)
%Multiply
n3= ((8.17e-43)*((fg2)/(T^4)))*(n2)
var = vpa(n3)
댓글 수: 3
채택된 답변
Paul
2022년 11월 19일
Hi Valentin,
Shouldn't the lower bound on the integral be fg2, not 0? Don't see how the reult will be 0.2952. The integrand is basically zero over the interval 1e8 < f < inf
syms f real
k = sym(1.380649e-23);
h = sym(6.6226069e-34);
T = sym(6000);
fg2 = sym(484e12);
n(f) = (f^2/(exp(h*f/k*T)-1));
fplot(n(f),[0 1e8])
So the integral from fg2 to inf will be tiny
n2 = vpaintegral(n(f),f,fg2,inf)
And the scale factor is much less than 1
vpa(sym(8.17e-43)*fg2/T^4)
댓글 수: 2
Paul
2022년 11월 28일
After reading @David Goodmanson's Answer below, I realize I had a mistake in my code, which I copied from Question. But the code in the Question doesn't represent the actual equation in the Question.
syms f real
k = sym(1.380649e-23);
h = sym(6.6226069e-34);
T = sym(6000);
fg2 = sym(484e12);
%n(f) = (f^2/(exp(h*f/k*T)-1)); % should have divided by T !!!!!
n(f) = (f^2/(exp(h*f/k/T)-1));
n2 = 8.17e-43*fg2/T^4*vpaintegral(n(f),f,fg2,inf)
추가 답변 (2개)
Walter Roberson
2022년 11월 19일
You will need to switch to numeric operations. The definite integral involves polylog(2) and polylog(3) and the limit of those as f approaches 0 and infinity. When I test out the formula on some larger f values, I seem to encounter complex intermediate results, which I do not get numerically.
format long g
Q = @(v) sym(v);
syms f
syms T fg2 positive
k = Q(1380649)*sym(10)^(-29)
h = Q(66226069)*sym(10)^(-41)
T = sym(6000)
fg2 = sym(484)*sym(10)^(12)
h_k = h/k
%assume(0 < h_k & h_k < 1)
n = (f^2/(exp(f*h_k*T)-1))
%fplot(nfun, [0 2/(h_k*T)])
%Integral
nfun = matlabFunction(n)
n2fun = @(F) arrayfun(@(U) integral(nfun, 0, U), F);
F = linspace(0, 1e8, 250);
N = n2fun(F);
plot(F, N)
N(end-2:end)
댓글 수: 0
David Goodmanson
2022년 11월 28일
편집: David Goodmanson
2022년 11월 29일
Hi Valentin,
It's not strictly necessary (see Paul's vpa solution) but it is advantageous to scale things properly before doing the integration. Once that is done, the answer is more apparent conceptually. The result below comes out .3105, slightly different from .2952.
result = 8.17e-43 fg2/T^4 Integral{fg2,inf} f^2/(exp(hf/(kT)) -1) df
To scale this, let f = fg2*u, df = fg2*du, then
result = 8.17e-43 fg2^4/T^4 Integral{1,inf} u^2/(exp( [h fg2/(kT)] u ) -1) du
which goes as follows
k = 1.380649e-23;
h = 6.6226069e-34;
T = 6000;
fg2 = 484e12;
C1 = h*fg2/(k*T)
C2 = 8.17e-43*fg2^4/T^4
I = integral(@(u) fun(u,C1), 1, inf)
result = C2*I
function y = fun(u,C1);
y = u.^2./(exp(C1*u)-1);
end
% scaling works
% C1 = 3.8694
% C2 = 34.5938
% I = 0.0088
result = 0.3105
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!