Average Error: 18.5 → 0.2
Time: 6.9s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \le 0.0893607720034448744:\\ \;\;\;\;1 - \log \left(1 - \frac{1}{\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}} \cdot \frac{x - y}{\sqrt[3]{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\left(\frac{x}{y} + 1 \cdot \frac{x}{{y}^{2}}\right) - 1 \cdot \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.0893607720034448744:\\
\;\;\;\;1 - \log \left(1 - \frac{1}{\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}} \cdot \frac{x - y}{\sqrt[3]{1 - y}}\right)\\

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

\end{array}
double f(double x, double y) {
        double r510003 = 1.0;
        double r510004 = x;
        double r510005 = y;
        double r510006 = r510004 - r510005;
        double r510007 = r510003 - r510005;
        double r510008 = r510006 / r510007;
        double r510009 = r510003 - r510008;
        double r510010 = log(r510009);
        double r510011 = r510003 - r510010;
        return r510011;
}

double f(double x, double y) {
        double r510012 = x;
        double r510013 = y;
        double r510014 = r510012 - r510013;
        double r510015 = 1.0;
        double r510016 = r510015 - r510013;
        double r510017 = r510014 / r510016;
        double r510018 = 0.08936077200344487;
        bool r510019 = r510017 <= r510018;
        double r510020 = 1.0;
        double r510021 = cbrt(r510016);
        double r510022 = r510021 * r510021;
        double r510023 = r510020 / r510022;
        double r510024 = r510014 / r510021;
        double r510025 = r510023 * r510024;
        double r510026 = r510015 - r510025;
        double r510027 = log(r510026);
        double r510028 = r510015 - r510027;
        double r510029 = r510012 / r510013;
        double r510030 = 2.0;
        double r510031 = pow(r510013, r510030);
        double r510032 = r510012 / r510031;
        double r510033 = r510015 * r510032;
        double r510034 = r510029 + r510033;
        double r510035 = r510020 / r510013;
        double r510036 = r510015 * r510035;
        double r510037 = r510034 - r510036;
        double r510038 = log(r510037);
        double r510039 = r510015 - r510038;
        double r510040 = r510019 ? r510028 : r510039;
        return r510040;
}

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.5
Target0.1
Herbie0.2
\[\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.08936077200344487

    1. Initial program 0.0

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

      \[\leadsto 1 - \log \left(1 - \frac{x - y}{\color{blue}{\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}\right) \cdot \sqrt[3]{1 - y}}}\right)\]
    4. Applied *-un-lft-identity0.0

      \[\leadsto 1 - \log \left(1 - \frac{\color{blue}{1 \cdot \left(x - y\right)}}{\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}\right) \cdot \sqrt[3]{1 - y}}\right)\]
    5. Applied times-frac0.0

      \[\leadsto 1 - \log \left(1 - \color{blue}{\frac{1}{\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}} \cdot \frac{x - y}{\sqrt[3]{1 - y}}}\right)\]

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

    1. Initial program 61.2

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

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

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

      \[\leadsto 1 - \log \color{blue}{\left(\left(\frac{x}{y} + 1 \cdot \frac{x}{{y}^{2}}\right) - 1 \cdot \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.0893607720034448744:\\ \;\;\;\;1 - \log \left(1 - \frac{1}{\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}} \cdot \frac{x - y}{\sqrt[3]{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\left(\frac{x}{y} + 1 \cdot \frac{x}{{y}^{2}}\right) - 1 \cdot \frac{1}{y}\right)\\ \end{array}\]

Reproduce

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