Average Error: 11.1 → 0.6
Time: 22.0s
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 r22388043 = x;
        double r22388044 = y;
        double r22388045 = r22388043 + r22388044;
        double r22388046 = r22388043 / r22388045;
        double r22388047 = log(r22388046);
        double r22388048 = r22388043 * r22388047;
        double r22388049 = exp(r22388048);
        double r22388050 = r22388049 / r22388043;
        return r22388050;
}

double f(double x, double y) {
        double r22388051 = x;
        double r22388052 = -1.782408069109436e+86;
        bool r22388053 = r22388051 <= r22388052;
        double r22388054 = y;
        double r22388055 = -r22388054;
        double r22388056 = exp(r22388055);
        double r22388057 = r22388056 / r22388051;
        double r22388058 = 5.349832006809411e-14;
        bool r22388059 = r22388051 <= r22388058;
        double r22388060 = exp(r22388051);
        double r22388061 = r22388054 + r22388051;
        double r22388062 = r22388051 / r22388061;
        double r22388063 = log(r22388062);
        double r22388064 = pow(r22388060, r22388063);
        double r22388065 = r22388064 / r22388051;
        double r22388066 = r22388059 ? r22388065 : r22388057;
        double r22388067 = r22388053 ? r22388057 : r22388066;
        return r22388067;
}

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