/** * This is the Taylor expansion of the first derivative of $$\frac{\exp(x)-1}{x}$$. * * @param x the value * @return the result */ public static double epsilonP(double x) { if (Math.abs(x) > 1e-7) { return ((x - 1) * Math.expm1(x) + x) / x / x; } return taylor(x, COEFF2); }
/** * This is the Taylor expansion of $$\frac{\exp(x)-1}{x}$$ - note for $$|x| > 10^{-10}$$ the expansion is note used . * * @param x the value * @return the result */ public static double epsilon(double x) { if (Math.abs(x) > 1e-10) { return Math.expm1(x) / x; } return taylor(x, COEFF1); }
/** * This is the Taylor expansion of the second derivative of $$\frac{\exp(x)-1}{x}$$. * * @param x the value * @return the result */ public static double epsilonPP(double x) { if (Math.abs(x) > 1e-5) { double x2 = x * x; double x3 = x * x2; return (Math.expm1(x) * (x2 - 2 * x + 2) + x2 - 2 * x) / x3; } return taylor(x, COEFF3); }