Average Error: 18.2 → 0.2
Time: 17.5s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -102078540239.528106689453125 \lor \neg \left(y \le 24595131.31851343810558319091796875\right):\\ \;\;\;\;\log \left(\frac{e^{1}}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{1}{\frac{\sqrt{1 - \frac{x - y}{1 - y}}}{\sqrt{e^{1}}}}\right) + \log \left(\frac{\sqrt{e^{1}}}{\sqrt{1 - \frac{x - y}{1 - y}}}\right)\\ \end{array}\]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;y \le -102078540239.528106689453125 \lor \neg \left(y \le 24595131.31851343810558319091796875\right):\\
\;\;\;\;\log \left(\frac{e^{1}}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}}\right)\\

\mathbf{else}:\\
\;\;\;\;\log \left(\frac{1}{\frac{\sqrt{1 - \frac{x - y}{1 - y}}}{\sqrt{e^{1}}}}\right) + \log \left(\frac{\sqrt{e^{1}}}{\sqrt{1 - \frac{x - y}{1 - y}}}\right)\\

\end{array}
double f(double x, double y) {
        double r374957 = 1.0;
        double r374958 = x;
        double r374959 = y;
        double r374960 = r374958 - r374959;
        double r374961 = r374957 - r374959;
        double r374962 = r374960 / r374961;
        double r374963 = r374957 - r374962;
        double r374964 = log(r374963);
        double r374965 = r374957 - r374964;
        return r374965;
}

double f(double x, double y) {
        double r374966 = y;
        double r374967 = -102078540239.5281;
        bool r374968 = r374966 <= r374967;
        double r374969 = 24595131.318513438;
        bool r374970 = r374966 <= r374969;
        double r374971 = !r374970;
        bool r374972 = r374968 || r374971;
        double r374973 = 1.0;
        double r374974 = exp(r374973);
        double r374975 = x;
        double r374976 = 2.0;
        double r374977 = pow(r374966, r374976);
        double r374978 = r374975 / r374977;
        double r374979 = 1.0;
        double r374980 = r374979 / r374966;
        double r374981 = r374978 - r374980;
        double r374982 = r374973 * r374981;
        double r374983 = r374975 / r374966;
        double r374984 = r374982 + r374983;
        double r374985 = r374974 / r374984;
        double r374986 = log(r374985);
        double r374987 = r374975 - r374966;
        double r374988 = r374973 - r374966;
        double r374989 = r374987 / r374988;
        double r374990 = r374973 - r374989;
        double r374991 = sqrt(r374990);
        double r374992 = sqrt(r374974);
        double r374993 = r374991 / r374992;
        double r374994 = r374979 / r374993;
        double r374995 = log(r374994);
        double r374996 = r374992 / r374991;
        double r374997 = log(r374996);
        double r374998 = r374995 + r374997;
        double r374999 = r374972 ? r374986 : r374998;
        return r374999;
}

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.6194724142551422119140625:\\ \;\;\;\;1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \lt 30094271212461763678175232:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -102078540239.5281 or 24595131.318513438 < y

    1. Initial program 46.7

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
    2. Using strategy rm
    3. Applied add-log-exp46.7

      \[\leadsto \color{blue}{\log \left(e^{1}\right)} - \log \left(1 - \frac{x - y}{1 - y}\right)\]
    4. Applied diff-log46.7

      \[\leadsto \color{blue}{\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)}\]
    5. Taylor expanded around inf 0.2

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

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

    if -102078540239.5281 < y < 24595131.318513438

    1. Initial program 0.2

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

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

      \[\leadsto \color{blue}{\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt0.2

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

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

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

      \[\leadsto \color{blue}{\log \left(\frac{\sqrt{e^{1}}}{\sqrt{1 - \frac{x - y}{1 - y}}}\right) + \log \left(\frac{\sqrt{e^{1}}}{\sqrt{1 - \frac{x - y}{1 - y}}}\right)}\]
    10. Using strategy rm
    11. Applied clear-num0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -102078540239.528106689453125 \lor \neg \left(y \le 24595131.31851343810558319091796875\right):\\ \;\;\;\;\log \left(\frac{e^{1}}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{1}{\frac{\sqrt{1 - \frac{x - y}{1 - y}}}{\sqrt{e^{1}}}}\right) + \log \left(\frac{\sqrt{e^{1}}}{\sqrt{1 - \frac{x - y}{1 - y}}}\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< y -81284752.619472414) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))) (if (< y 3.0094271212461764e25) (log (/ (exp 1) (- 1 (/ (- x y) (- 1 y))))) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y)))))))

  (- 1 (log (- 1 (/ (- x y) (- 1 y))))))