If you need good accuracy and you donβt know anything about the distribution of bases (x values) a priori, then pow (x, y) is the best portable answer (on many - not all) platforms, it will be faster than exp (y * log (x)), and itβs also better to behave numerically). If you know something about what ranges of x and y may lie, and with what distribution this will be a big help for people who are trying to give advice.
The usual way to do this faster while maintaining good accuracy is to use a library procedure designed to perform many of these calculations simultaneously for an array of x values ββand an array of y values. The trick is that such library implementations tend to cost money (e.g. Intel MKL) or are platform dependent (e.g. vvpowf in Accelerate.framework on OS X). I don't know much about MinGW, so someone else will need to tell you what is there. GSL may have something in this direction.
source share