newbie question, forcing numeric result



For big 'm', your calculation suffers from subtractive
cancelation; try bfloat instead of float:

(%i11) huge : gain(61,%i*2*%pi*60)$
(%i12) bfloat(huge), fpprec : 123;
(%o12) 1.1462233314862319837372937172[66
digits]7101238230788110302499429193b0
(%i13) float(huge);
(%o13) 0.0

Barton

-----maxima-bounces at math.utexas.edu wrote: -----

>To: Barton Willis
>From: Hugo Coolens
>Sent by: maxima-bounces at math.utexas.edu
>Date: 12/23/2006 02:43PM
>cc: maxima at math.utexas.edu
>Subject: Re: [Maxima] newbie question, forcing
>numeric result
>
>
>
>
>On Sat, 23 Dec 2006, Barton Willis wrote:
>
>> Try *something* like
>>
>> (%i1) mypow(a,b) := if a=0 and b= 0 then 1 else
>a^b;
>> paldn(m,s) :=
>>
>(sum(binomial(2*m-i,i)*mypow(s,i),i,0,m-1))/(sum(
>binomial(2*m-i,i)*mypow(s,i),i,0,m));
>>
>> gain(m,s) := abs(paldn(m,s));
>> pairs: makelist([0.1*omega,
>gain(2,%i*omega)],omega,0,5);
>>
>> (%o1) mypow(a,b):=if a=0 and b=0 then 1 else
>a^b
>> (%i2)
>> (%o2)
>>
>paldn(m,s):=sum(binom(2*m-i,i)*mypow(s,i),i,0,m-1
>)/sum(binom(2*m-i,i)*mypow(s,i),i,0,m)
>>
>> (%i3)
>> (%o3) gain(m,s):=abs(paldn(m,s))
>> (%i4)
>> (%o4)
>>
>[[0,1],[0.1,sqrt(10)/3],[0.2,sqrt(37)/(3*sqrt(5))
>],[0.3,sqrt(82)/sqrt(145)],[0.4,sqrt(145)/(3*sqrt
>(41))],[0.5,sqrt(226)/(3*sqrt(89))]]
>>
>> (%i5)
>>
>> Notes:
>thanks for the instructive reply, strange enough
>I am confronted now with
>another problem. The above defined function
>gain(m,s) stops functioning
>correctly when m>=60 as you can see below. It is
>a complete mystery to me
>why this happens:
>
>(%i19) float(gain(59,%i*2*%pi*60));
>
>(%o19)                              1.14706260261368
>
>(%i18) float(gain(60,%i*2*%pi*60));
>
>(%o18)                                   0.0
>
>(%i20) float(gain(61,%i*2*%pi*60));
>
>(%o20)                                   0.0
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxim
>a