| 99 | } |
| 100 | |
| 101 | double exp_impl_double(double value) { |
| 102 | if (value > 10.0) |
| 103 | return 22026.465794806718; // e^10 approx |
| 104 | if (value < -10.0) |
| 105 | return 0.0000453999297625; // e^-10 approx |
| 106 | |
| 107 | // For negative values, use exp(x) = 1/exp(-x) to keep the Taylor series |
| 108 | // input non-negative where it converges well with limited terms. |
| 109 | if (value < 0.0) { |
| 110 | return 1.0 / exp_impl_double(-value); |
| 111 | } |
| 112 | |
| 113 | double result = 1.0; |
| 114 | double term = 1.0; |
| 115 | for (int i = 1; i < 10; ++i) { |
| 116 | term *= value / static_cast<double>(i); |
| 117 | result += term; |
| 118 | } |
| 119 | return result; |
| 120 | } |
| 121 | |
| 122 | // ============================================================================= |
| 123 | // Libm-free trig / sqrt / log / pow implementations |
no outgoing calls
no test coverage detected