Average Error: 11.0 → 0.5
Time: 17.4s
Precision: 64
\[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -18649979204356907008:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \le 0.3987830221801595409480967191484523937106:\\ \;\;\;\;\frac{1}{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 -18649979204356907008:\\
\;\;\;\;\frac{e^{-y}}{x}\\

\mathbf{elif}\;x \le 0.3987830221801595409480967191484523937106:\\
\;\;\;\;\frac{1}{x}\\

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

\end{array}
double f(double x, double y) {
        double r16900666 = x;
        double r16900667 = y;
        double r16900668 = r16900666 + r16900667;
        double r16900669 = r16900666 / r16900668;
        double r16900670 = log(r16900669);
        double r16900671 = r16900666 * r16900670;
        double r16900672 = exp(r16900671);
        double r16900673 = r16900672 / r16900666;
        return r16900673;
}

double f(double x, double y) {
        double r16900674 = x;
        double r16900675 = -1.8649979204356907e+19;
        bool r16900676 = r16900674 <= r16900675;
        double r16900677 = y;
        double r16900678 = -r16900677;
        double r16900679 = exp(r16900678);
        double r16900680 = r16900679 / r16900674;
        double r16900681 = 0.39878302218015954;
        bool r16900682 = r16900674 <= r16900681;
        double r16900683 = 1.0;
        double r16900684 = r16900683 / r16900674;
        double r16900685 = r16900682 ? r16900684 : r16900680;
        double r16900686 = r16900676 ? r16900680 : r16900685;
        return r16900686;
}

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.0
Target7.9
Herbie0.5
\[\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.8649979204356907e+19 or 0.39878302218015954 < x

    1. Initial program 11.0

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

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

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

    if -1.8649979204356907e+19 < x < 0.39878302218015954

    1. Initial program 11.1

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

      \[\leadsto \frac{e^{\color{blue}{0}}}{x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -18649979204356907008:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \le 0.3987830221801595409480967191484523937106:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019169 +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))