Average Error: 11.2 → 0.9
Time: 5.2s
Precision: binary64
\[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
\[\begin{array}{l} t_0 := e^{-y}\\ \mathbf{if}\;x \leq -12.932303641541722:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y \cdot \frac{y}{x}}{e^{y}}, t_0\right)}{x}\\ \mathbf{elif}\;x \leq 7.8205546484089 \cdot 10^{-32}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y}{e^{y} \cdot \frac{x}{y}}, t_0\right)}{x}\\ \end{array} \]
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (exp (- y))))
   (if (<= x -12.932303641541722)
     (/ (fma 0.5 (/ (* y (/ y x)) (exp y)) t_0) x)
     (if (<= x 7.8205546484089e-32)
       (/ 1.0 x)
       (/ (fma 0.5 (/ y (* (exp y) (/ x y))) t_0) x)))))
double code(double x, double y) {
	return exp((x * log((x / (x + y))))) / x;
}
double code(double x, double y) {
	double t_0 = exp(-y);
	double tmp;
	if (x <= -12.932303641541722) {
		tmp = fma(0.5, ((y * (y / x)) / exp(y)), t_0) / x;
	} else if (x <= 7.8205546484089e-32) {
		tmp = 1.0 / x;
	} else {
		tmp = fma(0.5, (y / (exp(y) * (x / y))), t_0) / x;
	}
	return tmp;
}
function code(x, y)
	return Float64(exp(Float64(x * log(Float64(x / Float64(x + y))))) / x)
end
function code(x, y)
	t_0 = exp(Float64(-y))
	tmp = 0.0
	if (x <= -12.932303641541722)
		tmp = Float64(fma(0.5, Float64(Float64(y * Float64(y / x)) / exp(y)), t_0) / x);
	elseif (x <= 7.8205546484089e-32)
		tmp = Float64(1.0 / x);
	else
		tmp = Float64(fma(0.5, Float64(y / Float64(exp(y) * Float64(x / y))), t_0) / x);
	end
	return tmp
end
code[x_, y_] := N[(N[Exp[N[(x * N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[Exp[(-y)], $MachinePrecision]}, If[LessEqual[x, -12.932303641541722], N[(N[(0.5 * N[(N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision] / N[Exp[y], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 7.8205546484089e-32], N[(1.0 / x), $MachinePrecision], N[(N[(0.5 * N[(y / N[(N[Exp[y], $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / x), $MachinePrecision]]]]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\begin{array}{l}
t_0 := e^{-y}\\
\mathbf{if}\;x \leq -12.932303641541722:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y \cdot \frac{y}{x}}{e^{y}}, t_0\right)}{x}\\

\mathbf{elif}\;x \leq 7.8205546484089 \cdot 10^{-32}:\\
\;\;\;\;\frac{1}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y}{e^{y} \cdot \frac{x}{y}}, t_0\right)}{x}\\


\end{array}

Error

Bits error versus x

Bits error versus y

Target

Original11.2
Target8.0
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;y < -3.7311844206647956 \cdot 10^{+94}:\\ \;\;\;\;\frac{e^{\frac{-1}{y}}}{x}\\ \mathbf{elif}\;y < 2.817959242728288 \cdot 10^{+37}:\\ \;\;\;\;\frac{{\left(\frac{x}{y + x}\right)}^{x}}{x}\\ \mathbf{elif}\;y < 2.347387415166998 \cdot 10^{+178}:\\ \;\;\;\;\log \left(e^{\frac{{\left(\frac{x}{y + x}\right)}^{x}}{x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\frac{-1}{y}}}{x}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if x < -12.932303641541722

    1. Initial program 11.4

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
    2. Simplified11.4

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}} \]
    3. Taylor expanded in x around inf 3.2

      \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{{y}^{2} \cdot e^{-y}}{x} + e^{-y}}}{x} \]
    4. Simplified0.1

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.5, \frac{y}{\frac{x}{y}} \cdot e^{-y}, e^{-y}\right)}}{x} \]
    5. Applied egg-rr0.1

      \[\leadsto \frac{\mathsf{fma}\left(0.5, \color{blue}{\frac{y \cdot \frac{y}{x}}{e^{y}}}, e^{-y}\right)}{x} \]

    if -12.932303641541722 < x < 7.8205546484089e-32

    1. Initial program 12.4

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
    2. Simplified12.4

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}} \]
    3. Taylor expanded in x around 0 0.4

      \[\leadsto \frac{\color{blue}{1}}{x} \]

    if 7.8205546484089e-32 < x

    1. Initial program 9.3

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
    2. Simplified9.3

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}} \]
    3. Taylor expanded in x around inf 12.1

      \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{{y}^{2} \cdot e^{-y}}{x} + e^{-y}}}{x} \]
    4. Simplified7.0

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.5, \frac{y}{\frac{x}{y}} \cdot e^{-y}, e^{-y}\right)}}{x} \]
    5. Applied egg-rr2.1

      \[\leadsto \frac{\mathsf{fma}\left(0.5, \color{blue}{\frac{y}{e^{y} \cdot \frac{x}{y}}}, e^{-y}\right)}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -12.932303641541722:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y \cdot \frac{y}{x}}{e^{y}}, e^{-y}\right)}{x}\\ \mathbf{elif}\;x \leq 7.8205546484089 \cdot 10^{-32}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y}{e^{y} \cdot \frac{x}{y}}, e^{-y}\right)}{x}\\ \end{array} \]

Reproduce

herbie shell --seed 2022150 
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, F"
  :precision binary64

  :herbie-target
  (if (< y -3.7311844206647956e+94) (/ (exp (/ -1.0 y)) x) (if (< y 2.817959242728288e+37) (/ (pow (/ x (+ y x)) x) x) (if (< y 2.347387415166998e+178) (log (exp (/ (pow (/ x (+ y x)) x) x))) (/ (exp (/ -1.0 y)) x))))

  (/ (exp (* x (log (/ x (+ x y))))) x))