I have two numerical integration functions in MATLAB as follows:
fun1 = @(x) log2(1+x).*(4*exp(2*lambda*(d*sqrt(- d^2 + (a./x).^(2/alp))-(a./x).^(2/alp).*...
acos(((a./x).^(1/alp)./d).^(-1)))).*(a./x).^(2/alp).*lambda.*acos(((a./x).^(1/alp)./d).^(-1)))./(x.*alp);
num1=integral(@(x)fun1(x),0,a/(d^alp));
fun2 = @(x) exp(1./x).*expint(1./x).*(4*exp(2*lambda*(d*sqrt(- d^2 + (a./x).^(2/alp))-(a./x).^(2/alp).*...
acos(((a./x).^(1/alp)./d).^(-1)))).*(a./x).^(2/alp).*lambda.*acos(((a./x).^(1/alp)./d).^(-1)))./(x.*alp);
num2=integral(@(x)fun2(x),0,a/(d^alp));
In fun1
, I have log2(1+x)
(rest of the terms are same for fun1
and fun2
) and it gives numerical answer.
In fun2
, I have exp(1./x).*expint(1./x)
and it does not give numerical value.
for d=1.2; lambda=4.5; alp=2.7;f=1;a=0.5;
num1 =
0.3078
Warning: Infinite or Not-a-Number value encountered.
num2 =
NaN
I noticed that this can be calculated with MATHEMATICA. But I need it in MATLAB as my simulation run in it.
Can anyone help?
I guess the integral
function causes overflow or underflow since it uses double-precision arithmetic. You can try vpaintegral
, which uses variable-precision arithmetic.
The modified code:
d=1.2; lambda=4.5; alp=2.7;f=1;a=0.5;
fun1 = @(x) log2(1+x).*(4*exp(2*lambda*(d*sqrt(- d^2 + (a./x).^(2/alp))-(a./x).^(2/alp).*...
acos(((a./x).^(1/alp)./d).^(-1)))).*(a./x).^(2/alp).*lambda.*acos(((a./x).^(1/alp)./d).^(-1)))./(x.*alp);
num1=integral(@(x)fun1(x),0,a/(d^alp))
syms x
fun2 = exp(1./x).*expint(1./x).*(4*exp(2*lambda*(d*sqrt(- d^2 + (a./x).^(2/alp))-(a./x).^(2/alp).*...
acos(((a./x).^(1/alp)./d).^(-1)))).*(a./x).^(2/alp).*lambda.*acos(((a./x).^(1/alp)./d).^(-1)))./(x.*alp);
num2=vpaintegral(fun2,0,a/(d^alp))
Output:
num1 =
0.3078
num2 =
0.197608