That "arbitrary precision calculator" gives the same result as does
My suspicion is that same as yours - that 'calc' is computing pi on
the fly - but,
I haven't looked at its source code.
C-style arbitrary precision calculator (version 188.8.131.52)
Calc is open software. For license details type: help copyright
On Aug 1, 2009, at 3:43 PM, Sidney Markowitz wrote:
> I get -0.920731383924191d0 by multiplying the number by a power of ten
> and finding that mod 2*pi-to-some-places times that same power of ten,
> then dividing that result by that power of ten as a double-float and
> getting cos of that.
> Doing it that way the number of decimal places I need for pi is
> thirty-two (the number of digits in the number we're taking cos of)
> the number of digits precision in the result, e.g., at least 48
> to get consistent 15 digit precision double-float results.
> Is there a way to do it with pi to only 32 places?
> Either way, without an algorithm that can reduce the range without
> having pi to at least the same number of places as in the argument,
> can any computation of the function on arbitrary bignums be correct,
> whether in sbcl, R, or glibc? Is there a range reduction algorithm
> does not require pi to arbitrary precision, I guess by computing pi on
> the fly as part of the range reduction?
> ;; code I tested with
> (defparameter *bigpi* (* 2
> (defparameter *testnum* 100000000000000000000000000000000)
> (defun costest (testnum 2piexp77 precision)
> (let ((shrinkpi (expt 10 (- 77 precision)))
> (expandtest (expt 10 (1- precision))))
> (cos (/ (mod (* testnum expandtest)
> (round 2piexp77 shrinkpi))
> (coerce expandtest 'double-float)))))
> (costest *testnum* *bigpi* 48)
> Sidney Markowitz
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> trial. Simplify your report design, integration and deployment - and
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> Sbcl-devel mailing list