1

I'm writing a program in MuPAD. In this I'm using an equation which contains summation as well as product of N terms. But on running the code MuPAD throws an error:

Error: The summation variable must be an identifier or indexed identifier. [sum]

Can anyone suggest something? Thanks in advance. Below is my entire code.In this i am getting error in the second last line.

N:= 2;
lamda:= 785*10^(-9);
d:= 1*10^3;
a:= 5*10^-2;
ap:= 10;
be:=5;
bo:=0.25;
rhom:= 0.95;
g:= 2*bo*(1-rhom);
ohm:= 0.5;
f:= ohm + 2*(bo)*rhom;
A:= ((2*(ap)^(ap/2))/((g^(1+(ap/2)))*gamma(ap)))*(((g*be)/(g*be+f))^(be+(ap/2)));
k:= 2*PI/lamda;
ak:= (binomial(be-1,k-1)/gamma(k))*((g*be+f)^(1-(k/2)))*((f/g)^(k-1))*(ap/be)^(k/2);
ad:= 0.6;
v:= (sqrt(PI)*a)/(sqrt(2)*ad);
ae:= float(sqrt((ad^2*sqrt(PI)*erf(v))/(2*v*exp(-v^2))));
sigmas:= 0.3;
z:= ae/(2*sigmas);
sk:=(z^2/(1+z^2));
Y:=(ap^2*be^2*sk^2*(g+f)^2)/(16*ui*((g*be)+f)^2);
ccc:= meijerG(5,1,[1,(2+z^2)/2],[z^2/2,ap/2,(1+ap)/2,k/2,(1+k)/2],Y);
X:= (((ap*be)/(g*be+f))^(-((ap+k)/2)));
pb:=(1/2)*product(numeric::sum(((z^2*A*ak*(2^(ap+k-4)))/PI)*X*ccc,k=1..be),i=1..N);
S2:=hfarray(1..3,[pb $ ui=1..3]);
tushar
  • 23
  • 5
  • Here is my code line in which i am facing this error. – tushar Nov 23 '17 at 04:49
  • pb:=(1/2)*(1/PI)*sum(product(z^(2)*A*ak*(2^(a+k-4))*((a*b)/(g*b+f))^(-((a+k)/2))*meijerG(5,1,[1,(2+z^2)/(2)],[(z^2)/(2),(a)/(2),(1+a)/(2),(k)/(2),(1+k)/(2)],Y),i=1..N),k=1..b); – tushar Nov 23 '17 at 04:49
  • @yacc....pls check , i had edited my question – tushar Nov 29 '17 at 17:15
  • It seems a lot of variables are not defined, what is a, b, Y, N etc? Please provide a minimal, complete and verifiable example to reproduce the error. See https://stackoverflow.com/help/mcve. – yacc Nov 29 '17 at 18:36
  • @ yaac....now i had written my entire code. pls check it – tushar Nov 30 '17 at 18:09
  • In the line where `pb` is computed you have used abundant parentheses for this term: `((z^2*A*ak*(2^(ap+k-4)))/PI)*X*ccc`, I think it can be reduced to `z^2*A*ak*2^(ap+k-4)/PI*X*ccc`, could you check? – yacc Nov 30 '17 at 19:52
  • What is the sense of `product(..., i=1..N)` when `i` is never used in the product's term? Couldn't you write that as `(numeric::sum(...) ^ N)`? Try to simplify that line, split it to pieces, try with `k=1..5` instead of `k=1..be` just to rule out possible error sources. – yacc Nov 30 '17 at 20:17
  • @ yaac .....thanks for your comments. That i = 1..N is used becoz there is ui (actually it is mu suffix i). It is mentioned in 5th line from last. – tushar Dec 01 '17 at 12:41
  • And then you are using `k` in two places, see `2*PI/lamda`. I don't know MuPad, but I'd use a different name for the summation variable just to go sure. – yacc Dec 01 '17 at 13:10
  • @yaac.....thank you very much....that two k values was the problem. – tushar Dec 02 '17 at 05:04
  • @yaac..once again thanks. in this program now i am trying to plot pb versus sigmas plot in matlab using semilogy command. But my Y axis is not converted to logarithm, it is still in linear. Can you suggest something. Thanks – tushar Dec 03 '17 at 09:04
  • You're welcome. I suggest to make question for this to attract a greater audience. Close this question by accepting the answer and open a new one. – yacc Dec 03 '17 at 13:42

1 Answers1

0

The summation variable name k is already used here: k:= 2*PI/lamda. Changing to a different variable name fixes the error.

yacc
  • 2,915
  • 4
  • 19
  • 33