How I can impliment this type of infinite series in MATLAB given a function as where ,, and . Here l,γ,R are constant.

댓글 수: 6

Walter Roberson
Walter Roberson 2021년 2월 15일
You can implement it using symsum(), but I would be rather surprised if it is able to come up with a formula for it; chances are it will just leave it as a symsum()
You mention those three variables as constants, but you do not mention ? Is that the input variable?
Sudhir Sahoo
Sudhir Sahoo 2021년 2월 15일
편집: Sudhir Sahoo 2021년 2월 15일
Yes that one is q function .. yes gamma_{av} is a input variables.. the function H() is a difference between gamma function and uppor incomplete gamma function you have answered a previous question of using symsum() how ever I have tried to implement in my code .. but I got the error like symobl to double conversation so I am requesting for this can you implement this above function
Walter Roberson
Walter Roberson 2021년 2월 16일
I am not interested in doing that much typing.
  1. Use an infinite limit but do not use double. Use vpa() with a large number of digits. You might need 150 or more digits to prevent vpa() from having problems; OR
  2. Use a finite limit, in which case double() appears to do a nice job; OR
  3. Use vpa() with a large number of digits and double() the result.
Sudhir Sahoo
Sudhir Sahoo 2021년 2월 16일
Thanks for your valuable comment however I am unable to debug because of same error coming hence asked the same. Sorry for the inconvinience.
Walter Roberson
Walter Roberson 2021년 2월 16일
Post your code.
In terms of the code I posted earlier, the way forward would be to comment out that line that produces the error message, as I showed in the code how to get outputs without the error; I left the call to double() in to demonstrate that double() itself could not be used for the situation.
format long g
syms k;snr = 2;l = 2;
Limit = Inf;
expression2 = symsum([D(k,R)*(G(snr,l) + H(k + 1, snr,l)*(snr/2)^1.5*(l^((2*k + 1)*(m + 2))/sqrt(pi)) )],k,1,Limit);
D = 150;
ev = vpa(expression2, D);
ed = double(ev);
where is function
function [out] = D(k,R)
m = -1/log2(cos(pi/6)); % Here m is $\gamma$
exp_c_k = factorial(2*k -1)/(factorial(k)*factorial(k-1)*2^(2*k - 1));
exp_r = (1 + R)^[((2*m + 4)*k + m + 4)/2] - 1;
exp_denom = pi * R * (2*k + 1)* ((2*m + 4)*k + m + 4);
out = 8*exp_c_k * exp_r/exp_denom;
end
and as
function [out] = H(k,z,l)
%gam, y,z,l are user inputs
y = k;
m = -1/log2(cos(pi/6)); % in paper its used as small gamma.(\gamma)
out1 = (2/z)^y;
out2 = gamma(y) - igamma(y,(l^(-2*(m + 2))/2)*z);
out = out1 * out2;
end
as
function out = G(x,l)
m = -1/log2(cos(pi/6));
out = qfunc(sqrt(l^(-2*(m + 2))*x))
end
This code is simplified version of the expression of the
where ,, and . Here l,γ,R are constant.
when I code this I got the error like this "The following error occurred converting from sym to double:
Unable to convert expression containing remaining symbolic function calls into double array. Argument must be expression that evaluates to number."
Howerver I have tried in this manner for convergence is it correct one ?
Limit = Inf;
for k = 1:Inf
expression2 = [D(k,R)*(G(snr,l) + H(k + 1, snr,l)*(snr/2)^1.5*(l^((2*k + 1)*(m + 2))/sqrt(pi)))];
if abs(expression2) < 10^(-7)
break;
end
end

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2021년 2월 17일

1 개 추천

You did not give a value or range for R. My suspicion is that if R is not -1 or less, that the sum is infinite when the upper bound is infinite.
The code you were using required evaluation at over 1500 digits of precision to stableize the output when using 200 terms. However once I looked more closely at the code, I realized that some of it was being evaluated in pure double precision, so the answers it was getting were effectively numeric nonsense.
Unfortunately, the revised version is very slow.
I had to completely invent a value of R for testing purpose. As I had no guidance as to a proper value, I used 7 in the code.
With 200 terms, and using 5000 decimal places, the result is over 10^3000 . As the number of terms goes up, the result goes up quickly.
If you use fewer DIGITS, and the answer you get out for ev is in scientific notation, starting with a digit followed by a period, then you need to increase the DIGITS: whatever result you got out has been compromised. If the result you get out is negative, then you need to increase the DIGITS. If you do get out an actual number without scientific notation, then you might still need to increase the DIGITS

댓글 수: 3

Walter Roberson
Walter Roberson 2021년 2월 17일
Note that I had to change all of your functions, so make sure you create a new directory to download these versions into.
Sudhir Sahoo
Sudhir Sahoo 2021년 2월 17일
편집: Sudhir Sahoo 2021년 2월 17일
Sir R value is 1. Actually this is a part of a code of probablility of error calculation in a communication research.
Walter Roberson
Walter Roberson 2021년 2월 17일
Note: going beyond 500 terms for the upper limit will make the calculation unbearably slow. I do not mean a gradual deterioration, I mean a sharp deterioration. vpa(factorial(sym(1001)),2600) is very very slow, but 1000 instead is fast.

댓글을 달려면 로그인하십시오.

Sudhir Sahoo
Sudhir Sahoo 2021년 2월 16일

0 개 추천

format long g
syms k;snr = 2;l = 2;
Limit = Inf;
expression2 = symsum([D(k,R)*(G(snr,l) + H(k + 1, snr,l)*(snr/2)^1.5*(l^((2*k + 1)*(m + 2))/sqrt(pi)) )],k,1,Limit);
D = 150;
ev = vpa(expression2, D);
ed = double(ev);
where is function
function [out] = D(k,R)
m = -1/log2(cos(pi/6)); % Here m is $\gamma$
exp_c_k = factorial(2*k -1)/(factorial(k)*factorial(k-1)*2^(2*k - 1));
exp_r = (1 + R)^[((2*m + 4)*k + m + 4)/2] - 1;
exp_denom = pi * R * (2*k + 1)* ((2*m + 4)*k + m + 4);
out = 8*exp_c_k * exp_r/exp_denom;
end
and as
function [out] = H(k,z,l)
%gam, y,z,l are user inputs
y = k;
m = -1/log2(cos(pi/6)); % in paper its used as small gamma.(\gamma)
out1 = (2/z)^y;
out2 = gamma(y) - igamma(y,(l^(-2*(m + 2))/2)*z);
out = out1 * out2;
end
This code is simplified version of the expression of the
where ,, and . Here l,γ,R are constant.
when I code this I got the error like this "The following error occurred converting from sym to double:
Unable to convert expression containing remaining symbolic function calls into double array. Argument must be expression that evaluates to number."

질문:

2021년 2월 15일

댓글:

2021년 2월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by