Average Error: 18.2 → 0.1
Time: 7.2s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -173788009.49411574 \lor \neg \left(y \le 98105251.590079397\right):\\ \;\;\;\;\log \left(\frac{e^{1}}{\frac{x}{y} + \left(1 \cdot \frac{x}{{y}^{2}} - \frac{1}{y}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1}}{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 -173788009.49411574 \lor \neg \left(y \le 98105251.590079397\right):\\
\;\;\;\;\log \left(\frac{e^{1}}{\frac{x}{y} + \left(1 \cdot \frac{x}{{y}^{2}} - \frac{1}{y}\right)}\right)\\

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

\end{array}
double f(double x, double y) {
        double r531003 = 1.0;
        double r531004 = x;
        double r531005 = y;
        double r531006 = r531004 - r531005;
        double r531007 = r531003 - r531005;
        double r531008 = r531006 / r531007;
        double r531009 = r531003 - r531008;
        double r531010 = log(r531009);
        double r531011 = r531003 - r531010;
        return r531011;
}

double f(double x, double y) {
        double r531012 = y;
        double r531013 = -173788009.49411574;
        bool r531014 = r531012 <= r531013;
        double r531015 = 98105251.5900794;
        bool r531016 = r531012 <= r531015;
        double r531017 = !r531016;
        bool r531018 = r531014 || r531017;
        double r531019 = 1.0;
        double r531020 = exp(r531019);
        double r531021 = x;
        double r531022 = r531021 / r531012;
        double r531023 = 2.0;
        double r531024 = pow(r531012, r531023);
        double r531025 = r531021 / r531024;
        double r531026 = r531019 * r531025;
        double r531027 = r531019 / r531012;
        double r531028 = r531026 - r531027;
        double r531029 = r531022 + r531028;
        double r531030 = r531020 / r531029;
        double r531031 = log(r531030);
        double r531032 = r531021 - r531012;
        double r531033 = r531019 - r531012;
        double r531034 = r531032 / r531033;
        double r531035 = r531019 - r531034;
        double r531036 = r531020 / r531035;
        double r531037 = log(r531036);
        double r531038 = r531018 ? r531031 : r531037;
        return r531038;
}

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.1
\[\begin{array}{l} \mathbf{if}\;y \lt -81284752.619472414:\\ \;\;\;\;1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \lt 3.0094271212461764 \cdot 10^{25}:\\ \;\;\;\;\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 < -173788009.49411574 or 98105251.5900794 < y

    1. Initial program 47.1

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

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

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

      \[\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.1

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

    if -173788009.49411574 < y < 98105251.5900794

    1. Initial program 0.1

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

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

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

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

Reproduce

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

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

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