Average Error: 18.2 → 0.1
Time: 5.8s
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}}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}}\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}}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}}\right)\\

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

\end{array}
double f(double x, double y) {
        double r430735 = 1.0;
        double r430736 = x;
        double r430737 = y;
        double r430738 = r430736 - r430737;
        double r430739 = r430735 - r430737;
        double r430740 = r430738 / r430739;
        double r430741 = r430735 - r430740;
        double r430742 = log(r430741);
        double r430743 = r430735 - r430742;
        return r430743;
}

double f(double x, double y) {
        double r430744 = y;
        double r430745 = -173788009.49411574;
        bool r430746 = r430744 <= r430745;
        double r430747 = 98105251.5900794;
        bool r430748 = r430744 <= r430747;
        double r430749 = !r430748;
        bool r430750 = r430746 || r430749;
        double r430751 = 1.0;
        double r430752 = exp(r430751);
        double r430753 = x;
        double r430754 = 2.0;
        double r430755 = pow(r430744, r430754);
        double r430756 = r430753 / r430755;
        double r430757 = 1.0;
        double r430758 = r430757 / r430744;
        double r430759 = r430756 - r430758;
        double r430760 = r430751 * r430759;
        double r430761 = r430753 / r430744;
        double r430762 = r430760 + r430761;
        double r430763 = r430752 / r430762;
        double r430764 = log(r430763);
        double r430765 = r430753 - r430744;
        double r430766 = r430751 - r430744;
        double r430767 = r430765 / r430766;
        double r430768 = r430751 - r430767;
        double r430769 = r430752 / r430768;
        double r430770 = log(r430769);
        double r430771 = r430750 ? r430764 : r430770;
        return r430771;
}

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}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}}}\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}}{1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}}\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))))))