Average Error: 17.5 → 0.3
Time: 16.0s
Precision: 64
\[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{1.0 - y} \le 0.5242927222148749:\\ \;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1.0}}{\left(\frac{x}{y} \cdot \frac{1.0}{y} - \frac{1.0}{y}\right) + \frac{x}{y}}\right)\\ \end{array}\]
1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1.0 - y} \le 0.5242927222148749:\\
\;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\

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

\end{array}
double f(double x, double y) {
        double r8169375 = 1.0;
        double r8169376 = x;
        double r8169377 = y;
        double r8169378 = r8169376 - r8169377;
        double r8169379 = r8169375 - r8169377;
        double r8169380 = r8169378 / r8169379;
        double r8169381 = r8169375 - r8169380;
        double r8169382 = log(r8169381);
        double r8169383 = r8169375 - r8169382;
        return r8169383;
}

double f(double x, double y) {
        double r8169384 = x;
        double r8169385 = y;
        double r8169386 = r8169384 - r8169385;
        double r8169387 = 1.0;
        double r8169388 = r8169387 - r8169385;
        double r8169389 = r8169386 / r8169388;
        double r8169390 = 0.5242927222148749;
        bool r8169391 = r8169389 <= r8169390;
        double r8169392 = exp(r8169387);
        double r8169393 = r8169387 - r8169389;
        double r8169394 = r8169392 / r8169393;
        double r8169395 = log(r8169394);
        double r8169396 = r8169384 / r8169385;
        double r8169397 = r8169387 / r8169385;
        double r8169398 = r8169396 * r8169397;
        double r8169399 = r8169398 - r8169397;
        double r8169400 = r8169399 + r8169396;
        double r8169401 = r8169392 / r8169400;
        double r8169402 = log(r8169401);
        double r8169403 = r8169391 ? r8169395 : r8169402;
        return r8169403;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original17.5
Target0.1
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;y \lt -81284752.61947241:\\ \;\;\;\;1.0 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \lt 3.0094271212461764 \cdot 10^{+25}:\\ \;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (- x y) (- 1.0 y)) < 0.5242927222148749

    1. Initial program 0.0

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

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

      \[\leadsto \color{blue}{\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)}\]

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

    1. Initial program 59.0

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

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

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

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

      \[\leadsto \log \left(\frac{e^{1.0}}{\color{blue}{\left(\frac{1.0}{y} \cdot \frac{x}{y} - \frac{1.0}{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.0 - y} \le 0.5242927222148749:\\ \;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1.0}}{\left(\frac{x}{y} \cdot \frac{1.0}{y} - \frac{1.0}{y}\right) + \frac{x}{y}}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"

  :herbie-target
  (if (< y -81284752.61947241) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))

  (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))