Calculates the function EXPB 1067 listed in the book's appendix. It is of the * form * (Q(x^2) + x*P(x^2)) / (Q(x^2) - x*P(x^2)) * * Associated math function: 2^x * Allowed input range: [-1/2, 1/2] * Precision: 18.08 */
| 376 | * Precision: 18.08 |
| 377 | */ |
| 378 | static double Exp2Stage1(double x) { |
| 379 | const double A_P[] = { |
| 380 | .1513906799054338915894328e4, |
| 381 | .20202065651286927227886e2, |
| 382 | .23093347753750233624e-1, |
| 383 | }; |
| 384 | |
| 385 | const double A_Q[] = { |
| 386 | .4368211662727558498496814e4, |
| 387 | .233184211427481623790295e3, |
| 388 | 1.0, |
| 389 | }; |
| 390 | |
| 391 | double x_2 = x * x; |
| 392 | double P, Q; |
| 393 | int i; |
| 394 | |
| 395 | P = A_P[2]; |
| 396 | for (i = 1; i >= 0; i--) { |
| 397 | P *= x_2; |
| 398 | P += A_P[i]; |
| 399 | } |
| 400 | P *= x; |
| 401 | |
| 402 | Q = A_Q[2]; |
| 403 | for (i = 1; i >= 0; i--) { |
| 404 | Q *= x_2; |
| 405 | Q += A_Q[i]; |
| 406 | } |
| 407 | |
| 408 | return (Q + P) / (Q - P); |
| 409 | } |
| 410 | |
| 411 | /* Reduces the range of 2^x to [-1/2, 1/2] by using the property |
| 412 | * 2^x = 2^(integer value) * 2^(fractional part). |