herndon@umn-cs.UUCP (Robert Herndon) (02/01/84)
#N:umn-cs:1300001:000:745
umn-cs!herndon Jan 31 17:59:00 1984
There is a bug in the BC library. The arc-tangent function ("a")
returns pi/4 for the arctangent of any non-zero number. The cause
of this is a mis-associated "if" statement in the function definition.
The fix for this is to change the definition of the a() function.
The file currently reads:
125a126,128
> if(x==1)
> if(scale<52)
> return(.7853981633974483096156608458198757210492923498437764/1)
The following may be substituted:
126,130d125
> if(x==1) {
> if(scale<52) {
> return(.7853981633974483096156608458198757210492923498437764/1)
> }
> }
Or the lines may be deleted entirely. This will slow down the
evaluation of a(1) substantially but will not otherwise harm the
function.
Robert Herndon
umn-cs!herndondcw@ukc.UUCP (D.C.Wood) (02/03/84)
Here is a Bigger and Better Bug in Bc: scale=99 x=sqrt(2) x 1.414213562373095048801688724209698078569671875376948073176679737990732\ 478462107038850387534327641572 x*x 199999999999999999999999999999999999999999999999999999999999999999999\ 9999999999999999999999999999997921066900256462438170679779231122858093\ 9665738428702231869954990504493272650132450052758957026311840./ x^2 1.999999999999999999999999999999999999999999999999999999999999999999999\ 999999999999999999999999999997 Multiplication can give a relative error of 199(!) orders of magnitude when the scale is greater than 63. Is this a record? Exponetiation gets it right. There may still be a bug in another bc library function - I think it was s() (sine) - which used an undeclared variable `t'. This caused no problems unless it was called from a program which also used `t'. David Wood dcw@ukc.UUCP ...!vax135!ukc!dcw