Average Error: 18.2 → 0.2
Time: 15.6s
Precision: 64
\[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{1.0 - y} \le 0.8581617207853955:\\ \;\;\;\;\log \left(\frac{\sqrt{e^{1.0}}}{1.0 - \frac{x - y}{1.0 - y}} \cdot \sqrt{e^{1.0}}\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 - \log \left(\left(\frac{1.0}{y} \cdot \frac{x}{y} + \frac{x}{y}\right) - \frac{1.0}{y}\right)\\ \end{array}\]
1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1.0 - y} \le 0.8581617207853955:\\
\;\;\;\;\log \left(\frac{\sqrt{e^{1.0}}}{1.0 - \frac{x - y}{1.0 - y}} \cdot \sqrt{e^{1.0}}\right)\\

\mathbf{else}:\\
\;\;\;\;1.0 - \log \left(\left(\frac{1.0}{y} \cdot \frac{x}{y} + \frac{x}{y}\right) - \frac{1.0}{y}\right)\\

\end{array}
double f(double x, double y) {
        double r16638977 = 1.0;
        double r16638978 = x;
        double r16638979 = y;
        double r16638980 = r16638978 - r16638979;
        double r16638981 = r16638977 - r16638979;
        double r16638982 = r16638980 / r16638981;
        double r16638983 = r16638977 - r16638982;
        double r16638984 = log(r16638983);
        double r16638985 = r16638977 - r16638984;
        return r16638985;
}

double f(double x, double y) {
        double r16638986 = x;
        double r16638987 = y;
        double r16638988 = r16638986 - r16638987;
        double r16638989 = 1.0;
        double r16638990 = r16638989 - r16638987;
        double r16638991 = r16638988 / r16638990;
        double r16638992 = 0.8581617207853955;
        bool r16638993 = r16638991 <= r16638992;
        double r16638994 = exp(r16638989);
        double r16638995 = sqrt(r16638994);
        double r16638996 = r16638989 - r16638991;
        double r16638997 = r16638995 / r16638996;
        double r16638998 = r16638997 * r16638995;
        double r16638999 = log(r16638998);
        double r16639000 = r16638989 / r16638987;
        double r16639001 = r16638986 / r16638987;
        double r16639002 = r16639000 * r16639001;
        double r16639003 = r16639002 + r16639001;
        double r16639004 = r16639003 - r16639000;
        double r16639005 = log(r16639004);
        double r16639006 = r16638989 - r16639005;
        double r16639007 = r16638993 ? r16638999 : r16639006;
        return r16639007;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original18.2
Target0.1
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;y \lt -81284752.61947241:\\ \;\;\;\;1.0 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \lt 3.0094271212461764 \cdot 10^{+25}:\\ \;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (- x y) (- 1.0 y)) < 0.8581617207853955

    1. Initial program 0.0

      \[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
    2. Using strategy rm
    3. Applied add-log-exp0.0

      \[\leadsto \color{blue}{\log \left(e^{1.0}\right)} - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
    4. Applied diff-log0.0

      \[\leadsto \color{blue}{\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity0.0

      \[\leadsto \log \left(\frac{e^{1.0}}{\color{blue}{1 \cdot \left(1.0 - \frac{x - y}{1.0 - y}\right)}}\right)\]
    7. Applied add-sqr-sqrt0.0

      \[\leadsto \log \left(\frac{\color{blue}{\sqrt{e^{1.0}} \cdot \sqrt{e^{1.0}}}}{1 \cdot \left(1.0 - \frac{x - y}{1.0 - y}\right)}\right)\]
    8. Applied times-frac0.0

      \[\leadsto \log \color{blue}{\left(\frac{\sqrt{e^{1.0}}}{1} \cdot \frac{\sqrt{e^{1.0}}}{1.0 - \frac{x - y}{1.0 - y}}\right)}\]
    9. Simplified0.0

      \[\leadsto \log \left(\color{blue}{\sqrt{e^{1.0}}} \cdot \frac{\sqrt{e^{1.0}}}{1.0 - \frac{x - y}{1.0 - y}}\right)\]

    if 0.8581617207853955 < (/ (- x y) (- 1.0 y))

    1. Initial program 59.3

      \[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
    2. Taylor expanded around inf 0.7

      \[\leadsto 1.0 - \log \color{blue}{\left(\left(\frac{x}{y} + 1.0 \cdot \frac{x}{{y}^{2}}\right) - 1.0 \cdot \frac{1}{y}\right)}\]
    3. Simplified0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{1.0 - y} \le 0.8581617207853955:\\ \;\;\;\;\log \left(\frac{\sqrt{e^{1.0}}}{1.0 - \frac{x - y}{1.0 - y}} \cdot \sqrt{e^{1.0}}\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 - \log \left(\left(\frac{1.0}{y} \cdot \frac{x}{y} + \frac{x}{y}\right) - \frac{1.0}{y}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"

  :herbie-target
  (if (< y -81284752.61947241) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))

  (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))