The following expression shows significant numerical differences in a program when I compile in x86 (32 bit) versus x64 (64 bit), when $a$ is small:
$$ \left( \dfrac{1}{a} - b \right) \left( 1- \exp(-a)\right)$$
Is there a way that I can refactor this expression so that it is more robust for small $a$? It is not completely clear to me that simply expanding the expression into four terms is the best solution.
You can approximate $$ e^x \approx 1+x + \frac{x^2}{2!} + \frac{x^3}{3!} \qquad \Rightarrow e^{-x} \approx 1-x + \frac{x^2}{2!} - \frac{x^3}{3!} $$ Plugging this into the equation, we get $$ \left(\frac{1}{x}-b\right) \left(1- \left[ 1-x + \frac{x^2}{2!} - \frac{x^3}{3!}\right]\right) = \left(\frac{1}{x}-b\right) \left(x - \frac{x^2}{2!} + \frac{x^3}{3!}\right) = \left(\frac{1}{x}-b\right) x\left(1 - \frac{x}{2!} + \frac{x^2}{3!}\right) $$ Then assume $x\neq 0$ ... Can you continue from here?