Average Error: 11.1 → 0.6
Time: 21.6s
Precision: 64
\[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.782408069109436113491121240500612211051 \cdot 10^{86}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \le 5.349832006809411239167939056485028531928 \cdot 10^{-14}:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\left(\log \left(\frac{x}{y + x}\right)\right)}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \end{array}\]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\begin{array}{l}
\mathbf{if}\;x \le -1.782408069109436113491121240500612211051 \cdot 10^{86}:\\
\;\;\;\;\frac{e^{-y}}{x}\\

\mathbf{elif}\;x \le 5.349832006809411239167939056485028531928 \cdot 10^{-14}:\\
\;\;\;\;\frac{{\left(e^{x}\right)}^{\left(\log \left(\frac{x}{y + x}\right)\right)}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{e^{-y}}{x}\\

\end{array}
double f(double x, double y) {
        double r16222187 = x;
        double r16222188 = y;
        double r16222189 = r16222187 + r16222188;
        double r16222190 = r16222187 / r16222189;
        double r16222191 = log(r16222190);
        double r16222192 = r16222187 * r16222191;
        double r16222193 = exp(r16222192);
        double r16222194 = r16222193 / r16222187;
        return r16222194;
}

double f(double x, double y) {
        double r16222195 = x;
        double r16222196 = -1.782408069109436e+86;
        bool r16222197 = r16222195 <= r16222196;
        double r16222198 = y;
        double r16222199 = -r16222198;
        double r16222200 = exp(r16222199);
        double r16222201 = r16222200 / r16222195;
        double r16222202 = 5.349832006809411e-14;
        bool r16222203 = r16222195 <= r16222202;
        double r16222204 = exp(r16222195);
        double r16222205 = r16222198 + r16222195;
        double r16222206 = r16222195 / r16222205;
        double r16222207 = log(r16222206);
        double r16222208 = pow(r16222204, r16222207);
        double r16222209 = r16222208 / r16222195;
        double r16222210 = r16222203 ? r16222209 : r16222201;
        double r16222211 = r16222197 ? r16222201 : r16222210;
        return r16222211;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.1
Target7.9
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;y \lt -3.73118442066479561492798134439269393419 \cdot 10^{94}:\\ \;\;\;\;\frac{e^{\frac{-1}{y}}}{x}\\ \mathbf{elif}\;y \lt 28179592427282878868860376020282245120:\\ \;\;\;\;\frac{{\left(\frac{x}{y + x}\right)}^{x}}{x}\\ \mathbf{elif}\;y \lt 2.347387415166997963747840232163110922613 \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 2 regimes
  2. if x < -1.782408069109436e+86 or 5.349832006809411e-14 < x

    1. Initial program 10.9

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}\]
    2. Taylor expanded around inf 0.8

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot y}}}{x}\]
    3. Simplified0.8

      \[\leadsto \frac{\color{blue}{e^{-y}}}{x}\]

    if -1.782408069109436e+86 < x < 5.349832006809411e-14

    1. Initial program 11.2

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}\]
    2. Using strategy rm
    3. Applied add-log-exp17.6

      \[\leadsto \frac{e^{\color{blue}{\log \left(e^{x}\right)} \cdot \log \left(\frac{x}{x + y}\right)}}{x}\]
    4. Applied exp-to-pow0.5

      \[\leadsto \frac{\color{blue}{{\left(e^{x}\right)}^{\left(\log \left(\frac{x}{x + y}\right)\right)}}}{x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.782408069109436113491121240500612211051 \cdot 10^{86}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \le 5.349832006809411239167939056485028531928 \cdot 10^{-14}:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\left(\log \left(\frac{x}{y + x}\right)\right)}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, F"

  :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))