Average Error: 18.2 → 0.1
Time: 54.5s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -69178602.405435622 \lor \neg \left(y \le 53143023.8704946265\right):\\ \;\;\;\;\log \left(\frac{e^{1}}{\mathsf{fma}\left(\frac{x}{{y}^{2}}, 1, \frac{x}{y}\right) - \frac{1}{y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(1 - \frac{\frac{\frac{x - y}{\sqrt[3]{1 - y}}}{\sqrt[3]{1 - y}}}{\sqrt[3]{1 - y}}\right)\\ \end{array}\]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;y \le -69178602.405435622 \lor \neg \left(y \le 53143023.8704946265\right):\\
\;\;\;\;\log \left(\frac{e^{1}}{\mathsf{fma}\left(\frac{x}{{y}^{2}}, 1, \frac{x}{y}\right) - \frac{1}{y}}\right)\\

\mathbf{else}:\\
\;\;\;\;1 - \log \left(1 - \frac{\frac{\frac{x - y}{\sqrt[3]{1 - y}}}{\sqrt[3]{1 - y}}}{\sqrt[3]{1 - y}}\right)\\

\end{array}
double f(double x, double y) {
        double r499256 = 1.0;
        double r499257 = x;
        double r499258 = y;
        double r499259 = r499257 - r499258;
        double r499260 = r499256 - r499258;
        double r499261 = r499259 / r499260;
        double r499262 = r499256 - r499261;
        double r499263 = log(r499262);
        double r499264 = r499256 - r499263;
        return r499264;
}

double f(double x, double y) {
        double r499265 = y;
        double r499266 = -69178602.40543562;
        bool r499267 = r499265 <= r499266;
        double r499268 = 53143023.87049463;
        bool r499269 = r499265 <= r499268;
        double r499270 = !r499269;
        bool r499271 = r499267 || r499270;
        double r499272 = 1.0;
        double r499273 = exp(r499272);
        double r499274 = x;
        double r499275 = 2.0;
        double r499276 = pow(r499265, r499275);
        double r499277 = r499274 / r499276;
        double r499278 = r499274 / r499265;
        double r499279 = fma(r499277, r499272, r499278);
        double r499280 = r499272 / r499265;
        double r499281 = r499279 - r499280;
        double r499282 = r499273 / r499281;
        double r499283 = log(r499282);
        double r499284 = r499274 - r499265;
        double r499285 = r499272 - r499265;
        double r499286 = cbrt(r499285);
        double r499287 = r499284 / r499286;
        double r499288 = r499287 / r499286;
        double r499289 = r499288 / r499286;
        double r499290 = r499272 - r499289;
        double r499291 = log(r499290);
        double r499292 = r499272 - r499291;
        double r499293 = r499271 ? r499283 : r499292;
        return r499293;
}

Error

Bits error versus x

Bits error versus y

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 < -69178602.40543562 or 53143023.87049463 < 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}{\mathsf{fma}\left(\frac{x}{{y}^{2}}, 1, \frac{x}{y}\right) - \frac{1}{y}}}\right)\]

    if -69178602.40543562 < y < 53143023.87049463

    1. Initial program 0.1

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

      \[\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 associate-/r*0.1

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

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

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

Reproduce

herbie shell --seed 2020047 +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.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))))))