I came across some old code that calculates
double y = 1 / std::sqrt(x);
Using:
constexpr double base16 = 16.0;
double log_base16 = std::log(base16);
double y = std::pow(base16, -0.5 * std::log(x) / log_base16);
Which is essentially:
double y = std::exp(-0.5 * std::log(x));
Are there any rationales for quantitative advantages (e.g. accuracy or, most likely, prevention of overflow / overflow) between the methods? Perhaps the author of the original.
keith source
share