Average Error: 18.4 → 0.1
Time: 20.9s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -391848944.810126841068267822265625 \lor \neg \left(y \le 6764068.6677209436893463134765625\right):\\ \;\;\;\;1 - \log \left(\mathsf{fma}\left(1, \frac{x}{{y}^{2}}, \frac{x}{y}\right) - \frac{1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\mathsf{fma}\left(\frac{x - y}{{1}^{3} - {y}^{3}}, -\mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right), {\left(\sqrt[3]{1}\right)}^{3}\right) + \frac{x - y}{{1}^{3} - {y}^{3}} \cdot \left(\left(-\mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right)\right) + \mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right)\right)\right)\\ \end{array}\]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;y \le -391848944.810126841068267822265625 \lor \neg \left(y \le 6764068.6677209436893463134765625\right):\\
\;\;\;\;1 - \log \left(\mathsf{fma}\left(1, \frac{x}{{y}^{2}}, \frac{x}{y}\right) - \frac{1}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;1 - \log \left(\mathsf{fma}\left(\frac{x - y}{{1}^{3} - {y}^{3}}, -\mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right), {\left(\sqrt[3]{1}\right)}^{3}\right) + \frac{x - y}{{1}^{3} - {y}^{3}} \cdot \left(\left(-\mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right)\right) + \mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right)\right)\right)\\

\end{array}
double f(double x, double y) {
        double r244088 = 1.0;
        double r244089 = x;
        double r244090 = y;
        double r244091 = r244089 - r244090;
        double r244092 = r244088 - r244090;
        double r244093 = r244091 / r244092;
        double r244094 = r244088 - r244093;
        double r244095 = log(r244094);
        double r244096 = r244088 - r244095;
        return r244096;
}

double f(double x, double y) {
        double r244097 = y;
        double r244098 = -391848944.81012684;
        bool r244099 = r244097 <= r244098;
        double r244100 = 6764068.667720944;
        bool r244101 = r244097 <= r244100;
        double r244102 = !r244101;
        bool r244103 = r244099 || r244102;
        double r244104 = 1.0;
        double r244105 = x;
        double r244106 = 2.0;
        double r244107 = pow(r244097, r244106);
        double r244108 = r244105 / r244107;
        double r244109 = r244105 / r244097;
        double r244110 = fma(r244104, r244108, r244109);
        double r244111 = r244104 / r244097;
        double r244112 = r244110 - r244111;
        double r244113 = log(r244112);
        double r244114 = r244104 - r244113;
        double r244115 = r244105 - r244097;
        double r244116 = 3.0;
        double r244117 = pow(r244104, r244116);
        double r244118 = pow(r244097, r244116);
        double r244119 = r244117 - r244118;
        double r244120 = r244115 / r244119;
        double r244121 = r244104 + r244097;
        double r244122 = r244097 * r244121;
        double r244123 = fma(r244104, r244104, r244122);
        double r244124 = -r244123;
        double r244125 = cbrt(r244104);
        double r244126 = pow(r244125, r244116);
        double r244127 = fma(r244120, r244124, r244126);
        double r244128 = r244124 + r244123;
        double r244129 = r244120 * r244128;
        double r244130 = r244127 + r244129;
        double r244131 = log(r244130);
        double r244132 = r244104 - r244131;
        double r244133 = r244103 ? r244114 : r244132;
        return r244133;
}

Error

Bits error versus x

Bits error versus y

Target

Original18.4
Target0.1
Herbie0.1
\[\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 y < -391848944.81012684 or 6764068.667720944 < y

    1. Initial program 47.1

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
    2. Taylor expanded around inf 0.1

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

      \[\leadsto 1 - \log \color{blue}{\left(\mathsf{fma}\left(1, \frac{x}{{y}^{2}}, \frac{x}{y}\right) - \frac{1}{y}\right)}\]

    if -391848944.81012684 < y < 6764068.667720944

    1. Initial program 0.1

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

      \[\leadsto 1 - \log \left(1 - \frac{x - y}{\color{blue}{\frac{{1}^{3} - {y}^{3}}{1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)}}}\right)\]
    4. Applied associate-/r/0.1

      \[\leadsto 1 - \log \left(1 - \color{blue}{\frac{x - y}{{1}^{3} - {y}^{3}} \cdot \left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right)}\right)\]
    5. Applied add-cube-cbrt0.1

      \[\leadsto 1 - \log \left(\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}} - \frac{x - y}{{1}^{3} - {y}^{3}} \cdot \left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right)\right)\]
    6. Applied prod-diff0.1

      \[\leadsto 1 - \log \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{1} \cdot \sqrt[3]{1}, \sqrt[3]{1}, -\left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right) \cdot \frac{x - y}{{1}^{3} - {y}^{3}}\right) + \mathsf{fma}\left(-\left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right), \frac{x - y}{{1}^{3} - {y}^{3}}, \left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right) \cdot \frac{x - y}{{1}^{3} - {y}^{3}}\right)\right)}\]
    7. Simplified0.1

      \[\leadsto 1 - \log \left(\color{blue}{\mathsf{fma}\left(\frac{x - y}{{1}^{3} - {y}^{3}}, -\mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right), {\left(\sqrt[3]{1}\right)}^{3}\right)} + \mathsf{fma}\left(-\left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right), \frac{x - y}{{1}^{3} - {y}^{3}}, \left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right) \cdot \frac{x - y}{{1}^{3} - {y}^{3}}\right)\right)\]
    8. Simplified0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -391848944.810126841068267822265625 \lor \neg \left(y \le 6764068.6677209436893463134765625\right):\\ \;\;\;\;1 - \log \left(\mathsf{fma}\left(1, \frac{x}{{y}^{2}}, \frac{x}{y}\right) - \frac{1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\mathsf{fma}\left(\frac{x - y}{{1}^{3} - {y}^{3}}, -\mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right), {\left(\sqrt[3]{1}\right)}^{3}\right) + \frac{x - y}{{1}^{3} - {y}^{3}} \cdot \left(\left(-\mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right)\right) + \mathsf{fma}\left(1, 1, y \cdot \left(1 + y\right)\right)\right)\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< y -81284752.619472414) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))) (if (< y 3.0094271212461764e25) (log (/ (exp 1) (- 1 (/ (- x y) (- 1 y))))) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y)))))))

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