Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Strange ouput' topicStudent Support Forum > General > Archives > "Strange ouput"

Next Comment >Help | Reply To Topic
Author Comment/Response
Nguyen Duy Hieu
10/18/11 11:23am

Hi all,
When I ran my notebook for some calculations, I received some strange output. For example:

26.2197 + 21.8373 (-1. 2.31637 &)

or,

26.21973331528125` + 21.837273568494403` (-1.` 2.3163669767810915` &)

The output should be a real number. I don't know what is going on, and why. Please give me some advices on how to display the simplest result.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------- My Mathematica code --------%

(* Given parameters *)
ClearAll; Clear["`*"];
K = 20;
Pt = 100; M1 = 4;
Pint = 10; M2 = 4;
sigma2 = 1;
rho = Pt/(sigma2*M1);
mu = Pint/(sigma2*M2);

(*-------------------- Main program ---------------------*)
RBFsumrate = 0;
tmp = 0;
(*---------- Compute tmp2 and tmp5, and add them to tmp -------------*)
For[nn = 1, nn <= K, nn++,

(*--------------- Compute tmp2 ----------------------*)
tmp2 = 0;
For[pp = 1, pp <= nn*(M1 - 1) + 1, pp++,
tmp1 = -Exp[nn/rho] & (-nn/rho)^(pp - 1)*
ExpIntegralEi[-nn/rho]/((pp - 1)!);
For[tt = 1, tt <= pp - 1, tt++,
tmp1 = tmp1 + (-nn/rho)^(tt - 1)/Product[i, {i, pp - tt, pp - 1}];
];
App = (-1)^(nn*(M1 - 1) + 1 - pp)*
Product[i, {i, nn*M2,
nn*(M1 + M2 - 1) -
pp}] *1/ ( (rho/mu - 1)^(nn*(M1 + M2 - 1) + 1 -
pp) ) *1/((nn*(M1 - 1) + 1 - pp)!);
tmp2 = tmp2 + tmp1*App;
];

(*--------------- Compute tmp5 ----------------------*)
tmp5 = 0;
For[qq = 1, qq <= nn*M2, qq++,
tmp4 = -Exp[nn/mu]*(-nn/rho)^(qq - 1)*
ExpIntegralEi[-nn/mu]/((qq - 1)!);
For[mm = 1, mm <= qq - 1, mm++,
tmp4 =
tmp4 + (-nn/rho)^(mm - 1)* (mu/rho)^(qq - mm)/
Product[i, {i, qq - mm, qq - 1}];
];
Bqq = (-1)^(nn*M2 - qq)*
Product[i, {i, nn*(M1 - 1) + 1,
nn*(M1 + M2 - 1) -
qq}]*1 / ( (1 - rho/mu)^(nn*(M1 + M2 - 1) + 1 -
qq) ) *1/((nn*M2 - qq)!) ;
tmp5 = tmp5 + tmp4*Bqq;
];

(*---------- Add tmp2 and tmp5 to tmp -------------*)
tmp = tmp + (-1)^(nn - 1)*
Binomial[K, nn]*(rho/mu)^(nn*M2)*(tmp2 + tmp5);
];


rho
Simplify[N[Simplify[tmp]]]
RBFsumrate = M1*tmp/Log[2];
Simplify[N[Simplify[N[RBFsumrate]]]]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

URL: ,

Subject (listing for 'Strange ouput')
Author Date Posted
Strange ouput Nguyen Duy H... 10/18/11 11:23am
Re: Strange ouput Nguyen Duy H... 10/19/11 00:42am
Next Comment >Help | Reply To Topic