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

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

\end{array}
double f(double x, double y) {
        double r427826 = 1.0;
        double r427827 = x;
        double r427828 = y;
        double r427829 = r427827 - r427828;
        double r427830 = r427826 - r427828;
        double r427831 = r427829 / r427830;
        double r427832 = r427826 - r427831;
        double r427833 = log(r427832);
        double r427834 = r427826 - r427833;
        return r427834;
}

double f(double x, double y) {
        double r427835 = x;
        double r427836 = y;
        double r427837 = r427835 - r427836;
        double r427838 = 1.0;
        double r427839 = r427838 - r427836;
        double r427840 = r427837 / r427839;
        double r427841 = 0.881588056536585;
        bool r427842 = r427840 <= r427841;
        double r427843 = exp(r427838);
        double r427844 = r427838 - r427840;
        double r427845 = r427843 / r427844;
        double r427846 = log(r427845);
        double r427847 = 1.0;
        double r427848 = r427838 / r427836;
        double r427849 = r427847 + r427848;
        double r427850 = r427835 / r427836;
        double r427851 = r427849 * r427850;
        double r427852 = r427851 - r427848;
        double r427853 = r427843 / r427852;
        double r427854 = log(r427853);
        double r427855 = r427842 ? r427846 : r427854;
        return r427855;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original17.9
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 (/ (- x y) (- 1.0 y)) < 0.881588056536585

    1. Initial program 0.0

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

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

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

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

    1. Initial program 61.6

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019350 
(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))))))