That "arbitrary precision calculator" gives the same result as does
your technique.
My suspicion is that same as yours  that 'calc' is computing pi on
the fly  but,
I haven't looked at its source code.
Cstyle arbitrary precision calculator (version 2.12.3.3)
Calc is open software. For license details type: help copyright
; cos(100000000000000000000000000000000)
0.9207313839241906876
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*pitosomeplaces times that same power of ten,
> then dividing that result by that power of ten as a doublefloat and
> getting cos of that.
>
> Doing it that way the number of decimal places I need for pi is
> thirtytwo (the number of digits in the number we're taking cos of)
> plus
> the number of digits precision in the result, e.g., at least 48
> digits
> to get consistent 15 digit precision doublefloat 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,
> how
> can any computation of the function on arbitrary bignums be correct,
> whether in sbcl, R, or glibc? Is there a range reduction algorithm
> that
> 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
> 31415926535897932384626433832795028841971693993751058209749445923078164062862
> ))
>
> (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 'doublefloat)))))
>
> ;;;;;;;;;;;
>
> (costest *testnum* *bigpi* 48)
> 0.9207313839241906d0
>
>
>
> Sidney Markowitz
> http://sidney.com
>
>
>
> 
> Let Crystal Reports handle the reporting  Free Crystal Reports 2008
> 30Day
> 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/bobjjuly
> _______________________________________________
> Sbcldevel mailing list
> Sbcldevel@...
> https://lists.sourceforge.net/lists/listinfo/sbcldevel
>
