RE: help needed with mathematical calculation
- To: mathgroup at smc.vnet.net
- Subject: [mg33383] RE: [mg33336] help needed with mathematical calculation
- From: Hartmut.Wolf at t-systems.com
- Date: Mon, 18 Mar 2002 23:38:56 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
> -----Original Message----- > From: Salman Durrani [mailto:dsalman at itee.uq.edu.au] To: mathgroup at smc.vnet.net > Sent: Saturday, March 16, 2002 7:40 AM > To: mathgroup at smc.vnet.net > Subject: [mg33383] [mg33336] help needed with mathematical calculation > > > Hi > > The formula I have to program is > > P = ((M/2)/(M-1))* sum (k=1) to (M-1) > [ binomial(M-1,k) *( ((-1)^(k+1)) /(1+k+k*K*X) )] > > where M =64 > > K=log2(M) > > XdB = 0:5:30 ( dB values) > > X = 10^(XdB/10) > > I need the semilog plot of XdB and P. > > I plotted the formula in Mathematica. > > For M = 2,4,8,16 and 32, I get smooth curves, which are correct. > > When i go for M=64, there is some error or overflow that > causes incorrect > curve to be displayed. > > I know my formula is correct and i am implementing it correctly ( from > results for M=2,4,8,16 and 32) > > However I need the result for M =64. > > I would be grateful if anybody can point out how to get the > correct plot for > M=64. > ( plot for M=64 should follow the same trend as M =32) > > The mathematica code is given below > > Thanks > > Salman > ...snipped... > > > Salman, indeed, this a problem of numerical precision. Where does it arise? Your formula for p is of arbitrary precision, as the Log[2,M] evaluates to an exact integer for M being an integer power of 2. Also X = 10^(XdB/10) is treated exacly. This means, for each point to be plotted you will get an exact expression containing many (huge) terms. These will be evaluated numericaly within the plotting function LinearLogListPlot, you used. But this is is done with machine precision, which is not good enough for M > 45 (say). All you have to do is this: do that numerical evaluation to a floating point result with higher precision (outside of Plot, I used 22 here); those numbers will then be plotted perfectly: ((plst[#1] = N[ With[{M = 2^#1}, With[{K = Log[2, M]}, ((M/2/(M - 1))* Sum[Binomial[M - 1, k]*((-1)^(k + 1)/(1 + k + k*K*10^(#1/10))), {k, 1, M - 1}] & ) /@ Range[20] ]], 22]) & ) /@ Range[6]; (g[#] = LinearLogListPlot[plst[#], Axes -> False, Frame -> True, PlotJoined -> True, PlotRange -> All, DisplayFunction -> Identity, PlotStyle -> {AbsoluteThickness[1.5], Hue[(# + 1)/8]}]) & /@ Range[6] Show[g /@ Range[6], DisplayFunction -> $DisplayFunction] -- Hartmut Wolf