Fast fixed point pow, log, exp and sqrt

A very simple solution is to use a decent table-driven approximation. You don’t actually need a lot of data if you reduce your inputs correctly. exp(a)==exp(a/2)*exp(a/2), which means you really only need to calculate exp(x) for 1 < x < 2. Over that range, a runga-kutta approximation would give reasonable results with ~16 entries IIRC. … Read more

Deal with overflow in exp using numpy

You can use the bigfloat package. It supports arbitrary precision floating point operations. http://packages.python.org/bigfloat/ import bigfloat bigfloat.exp(5000,bigfloat.precision(100)) # -> BigFloat.exact(‘2.9676283840236670689662968052896e+2171′, precision=100) Are you using a function optimization framework? They usually implement value boundaries (using penalty terms). Try that. Are the relevant values really that extreme? In optimization it’s not uncommon to minimize log(f). (approximate log … Read more