How can I evaluate a complex definite integral?
Show older comments
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

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

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 Comments
John D'Errico
on 18 Nov 2022
When you post a picture of your code, you make it far more difficult to get help, since then someone needs to type in everything you did from scratch. Is there a good reason why you want to make it more difficult, since you are asking for help? It is just as easy, if not easier to paste in text as a picture. But the txt is trivially easy for us to then bring into MATLAB.
If you want help, then make it easy to get help.
Valentin Augusto Simbron Mckay
on 19 Nov 2022
John D'Errico
on 19 Nov 2022
That makes it far more easy to offer help. Thanks.
Accepted Answer
More Answers (2)
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)
David Goodmanson
on 28 Nov 2022
Edited: David Goodmanson
on 29 Nov 2022
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
Categories
Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





