Average Error: 18.7 → 0.9
Time: 17.1s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \le 1.537598818068412357583554970976054410148 \cdot 10^{-9}:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1}}{\frac{1 \cdot x}{y \cdot y} + \left(\frac{x}{y} - \frac{1}{y}\right)}\right)\\ \end{array}\]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \le 1.537598818068412357583554970976054410148 \cdot 10^{-9}:\\
\;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\

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

\end{array}
double f(double x, double y) {
        double r301506 = 1.0;
        double r301507 = x;
        double r301508 = y;
        double r301509 = r301507 - r301508;
        double r301510 = r301506 - r301508;
        double r301511 = r301509 / r301510;
        double r301512 = r301506 - r301511;
        double r301513 = log(r301512);
        double r301514 = r301506 - r301513;
        return r301514;
}

double f(double x, double y) {
        double r301515 = x;
        double r301516 = y;
        double r301517 = r301515 - r301516;
        double r301518 = 1.0;
        double r301519 = r301518 - r301516;
        double r301520 = r301517 / r301519;
        double r301521 = 1.5375988180684124e-09;
        bool r301522 = r301520 <= r301521;
        double r301523 = exp(r301518);
        double r301524 = r301518 - r301520;
        double r301525 = r301523 / r301524;
        double r301526 = log(r301525);
        double r301527 = r301518 * r301515;
        double r301528 = r301516 * r301516;
        double r301529 = r301527 / r301528;
        double r301530 = r301515 / r301516;
        double r301531 = r301518 / r301516;
        double r301532 = r301530 - r301531;
        double r301533 = r301529 + r301532;
        double r301534 = r301523 / r301533;
        double r301535 = log(r301534);
        double r301536 = r301522 ? r301526 : r301535;
        return r301536;
}

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.7
Target0.1
Herbie0.9
\[\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 (/ (- x y) (- 1.0 y)) < 1.5375988180684124e-09

    1. Initial program 0.0

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

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

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

    if 1.5375988180684124e-09 < (/ (- x y) (- 1.0 y))

    1. Initial program 59.1

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

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

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

      \[\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. Simplified2.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \le 1.537598818068412357583554970976054410148 \cdot 10^{-9}:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1}}{\frac{1 \cdot x}{y \cdot y} + \left(\frac{x}{y} - \frac{1}{y}\right)}\right)\\ \end{array}\]

Reproduce

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