Average Error: 18.8 → 0.2
Time: 16.3s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \le 0.9679400613876859571504951418319251388311:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1}}{\left(1 + \frac{1}{y}\right) \cdot \frac{x}{y} - \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.9679400613876859571504951418319251388311:\\
\;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\

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

\end{array}
double f(double x, double y) {
        double r269193 = 1.0;
        double r269194 = x;
        double r269195 = y;
        double r269196 = r269194 - r269195;
        double r269197 = r269193 - r269195;
        double r269198 = r269196 / r269197;
        double r269199 = r269193 - r269198;
        double r269200 = log(r269199);
        double r269201 = r269193 - r269200;
        return r269201;
}

double f(double x, double y) {
        double r269202 = x;
        double r269203 = y;
        double r269204 = r269202 - r269203;
        double r269205 = 1.0;
        double r269206 = r269205 - r269203;
        double r269207 = r269204 / r269206;
        double r269208 = 0.967940061387686;
        bool r269209 = r269207 <= r269208;
        double r269210 = exp(r269205);
        double r269211 = r269205 - r269207;
        double r269212 = r269210 / r269211;
        double r269213 = log(r269212);
        double r269214 = 1.0;
        double r269215 = r269205 / r269203;
        double r269216 = r269214 + r269215;
        double r269217 = r269202 / r269203;
        double r269218 = r269216 * r269217;
        double r269219 = r269218 - r269215;
        double r269220 = r269210 / r269219;
        double r269221 = log(r269220);
        double r269222 = r269209 ? r269213 : r269221;
        return r269222;
}

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.8
Target0.1
Herbie0.2
\[\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)) < 0.967940061387686

    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 0.967940061387686 < (/ (- x y) (- 1.0 y))

    1. Initial program 61.9

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

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

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

      \[\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.6

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

Reproduce

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