Viète à grande Vitesse or Accelerated Viète (kind of)
|
06-23-2024, 06:00 PM
Post: #21
|
|||
|
|||
RE: Viète à grande Vitesse or Accelerated Viète (kind of)
(06-23-2024 03:00 AM)Gerson W. Barbosa Wrote: \(\pi \approx \pi{'} \left[1+\frac{1}{6}\left(\frac{\pi{'}}{2^{n+1} }\right)^2\right]\left[1+\frac{3}{40}\left(\frac{\pi{'}}{2^{n+1} }\right)^4\right]\left[1+\frac{9}{280}\left(\frac{\pi{'}}{2^{n+1} }\right)^6\right] \) Correction factor had error of O(z^8), where z=pi'/2^(n+1) If we use Horner's scheme, we might as well use correct z^8 coefficient. It made code shorter (less terms), also more accurate, error = O(z^10) XCas> expand( (1+1/6*z^2) * (1+3/40*z^4) * (1+9/280*z^6) ) 1 + 1/6*z^2 + 3/40*z^4 + 5/112*z^6 + 3/560*z^8 + 27/11200*z^10 + 9/22400*z^12 Replaced this with asin(z)/z, upto z^8 only XCas> expand( 1+1/6*z^2 * (1+3²/(4*5)*z^2 * (1+5²/(6*7)*z^2 * (1+7²/(8*9)*z^2))) ) 1 +1/6*z^2 + 3/40*z^4 + 5/112*z^6 + 35/1152*z^8 To make code stack-only, we can't store n, and had to recover 2^(n+1) factor. Code was using 2^(n+1) = IP((355/113)/z), but this will fail if n is too big. Instead, I use log to recover n from z (Yes, this is stupid, all we need is to store n) z = pi' / 2^(n+1) log2(z) = log2(pi') - (n+1) -(n+1) ≈ log2(z) - 1.6515 -(n+1) = IP(log2(z)) - 2 n=1 --> IP(log2(z)) - 2 = IP(-0.50) - 2 = -2 n=9 --> IP(log2(z)) - 2 = IP(-8.35) - 2 = -10 n=99 --> IP(log2(z)) - 2 = IP(-98.35) - 2 = -100 n=999 --> IP(log2(z)) - 2 = IP(-998.35) - 2 = -1000 ... Code: 00 { 79-Byte Prgm } 1 XEQ "Vh" --> 3.138316846974900201597524772067293 10 XEQ "Vh" --> 3.141592653589793238462643383274432 11 XEQ "Vh" --> 3.141592653589793238462643383279499 12 XEQ "Vh" --> 3.141592653589793238462643383279504 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)