[gambit-list] Patch to improve elementary functions for complex and exact arguments

Bradley Lucier lucier at math.purdue.edu
Fri Oct 31 11:49:34 EDT 2008


On Oct 31, 2008, at 11:44 AM, Bradley Lucier wrote:

> Well, I ran things through my computable reals package (with a quick  
> implementation of computable-sin and computable-cos, so there could  
> be bugs here) and got
>
>> [descartes:computation/computational-reals/src] lucier% gsi
>> Gambit v4.3.0
>>
>> > (load "exact-reals.scm")
>> "/Volumes/lucier/text/courses/computation/computational-reals/src/ 
>> exact-reals.scm"
>> > (computable->inexact (computable-/-by-integer computable-pi 4))
>> .7853981633974483
>> > (computable->inexact (computable-sin (computable-/-by-integer  
>> computable-pi 4)))
>> .7071067811865476
>> > (computable->inexact (computable-sin (exact->computable (inexact- 
>> >exact (computable->inexact (computable-/-by-integer computable-pi  
>> 4))))))
>> .7071067811865475
>> > (computable->inexact (computable-cos (computable-/-by-integer  
>> computable-pi 4)))
>> .7071067811865476
>> > (computable->inexact (computable-cos (exact->computable (inexact- 
>> >exact (computable->inexact (computable-/-by-integer computable-pi  
>> 4))))))
>> .7071067811865476
>
> So the inexact (double-precision floating-point) approximations to  
> the sine and cosine of exact pi/4 are equal, as one would expect,  
> but the inexact approximations to the sine and cosine of the inexact  
> approximation to pi/4 are not equal (it's obvious that they're not  
> equal to infinite precision, but indeed they round to different  
> floating-point numbers) and it appears that glibc on linux is  
> getting it right and the math library on Mac OS X 10.5.5 is getting  
> it wrong.

There's the further test:

> > (computable-< (exact->computable (inexact->exact . 
> 7853981633974483)) (computable-/-by-integer computable-pi 4))
> #t

So the floating point approximation to pi/4 is smaller than pi/4, so  
its cosine is bigger than its sine.

Brad




More information about the Gambit-list mailing list