MCPcopy Create free account
hub / github.com/FastLED/FastLED / exp_impl_double

Function exp_impl_double

src/fl/math/math.cpp.hpp:101–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101double 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

Callers 2

pow_impl_doubleFunction · 0.85
expFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected