Average Error: 18.7 → 0.3
Time: 5.1s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \le 0.5599263830433665:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{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.5599263830433665:\\
\;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\

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

\end{array}
double f(double x, double y) {
        double r428658 = 1.0;
        double r428659 = x;
        double r428660 = y;
        double r428661 = r428659 - r428660;
        double r428662 = r428658 - r428660;
        double r428663 = r428661 / r428662;
        double r428664 = r428658 - r428663;
        double r428665 = log(r428664);
        double r428666 = r428658 - r428665;
        return r428666;
}

double f(double x, double y) {
        double r428667 = x;
        double r428668 = y;
        double r428669 = r428667 - r428668;
        double r428670 = 1.0;
        double r428671 = r428670 - r428668;
        double r428672 = r428669 / r428671;
        double r428673 = 0.5599263830433665;
        bool r428674 = r428672 <= r428673;
        double r428675 = exp(r428670);
        double r428676 = r428670 - r428672;
        double r428677 = r428675 / r428676;
        double r428678 = log(r428677);
        double r428679 = 2.0;
        double r428680 = pow(r428668, r428679);
        double r428681 = r428667 / r428680;
        double r428682 = 1.0;
        double r428683 = r428682 / r428668;
        double r428684 = r428681 - r428683;
        double r428685 = r428670 * r428684;
        double r428686 = r428667 / r428668;
        double r428687 = r428685 + r428686;
        double r428688 = r428675 / r428687;
        double r428689 = log(r428688);
        double r428690 = r428674 ? r428678 : r428689;
        return r428690;
}

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.7
Target0.1
Herbie0.3
\[\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 (/ (- x y) (- 1.0 y)) < 0.5599263830433665

    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.5599263830433665 < (/ (- x y) (- 1.0 y))

    1. Initial program 61.4

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

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

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

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

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

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

Reproduce

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