Average Error: 18.4 → 0.1
Time: 9.0s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le \frac{-7757395642503235}{33554432} \lor \neg \left(y \le \frac{226964482154373}{33554432}\right):\\ \;\;\;\;1 - \log \left(1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \end{array}\]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;y \le \frac{-7757395642503235}{33554432} \lor \neg \left(y \le \frac{226964482154373}{33554432}\right):\\
\;\;\;\;1 - \log \left(1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}\right)\\

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

\end{array}
double f(double x, double y) {
        double r259167 = 1.0;
        double r259168 = x;
        double r259169 = y;
        double r259170 = r259168 - r259169;
        double r259171 = r259167 - r259169;
        double r259172 = r259170 / r259171;
        double r259173 = r259167 - r259172;
        double r259174 = log(r259173);
        double r259175 = r259167 - r259174;
        return r259175;
}

double f(double x, double y) {
        double r259176 = y;
        double r259177 = -7757395642503235.0;
        double r259178 = 33554432.0;
        double r259179 = r259177 / r259178;
        bool r259180 = r259176 <= r259179;
        double r259181 = 226964482154373.0;
        double r259182 = r259181 / r259178;
        bool r259183 = r259176 <= r259182;
        double r259184 = !r259183;
        bool r259185 = r259180 || r259184;
        double r259186 = 1.0;
        double r259187 = x;
        double r259188 = 2.0;
        double r259189 = pow(r259176, r259188);
        double r259190 = r259187 / r259189;
        double r259191 = 1.0;
        double r259192 = r259191 / r259176;
        double r259193 = r259190 - r259192;
        double r259194 = r259186 * r259193;
        double r259195 = r259187 / r259176;
        double r259196 = r259194 + r259195;
        double r259197 = log(r259196);
        double r259198 = r259186 - r259197;
        double r259199 = exp(r259186);
        double r259200 = r259187 - r259176;
        double r259201 = r259186 - r259176;
        double r259202 = r259200 / r259201;
        double r259203 = r259186 - r259202;
        double r259204 = r259199 / r259203;
        double r259205 = log(r259204);
        double r259206 = r259185 ? r259198 : r259205;
        return r259206;
}

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.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 < -231188405.82678422 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(1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}\right)}\]

    if -231188405.82678422 < y < 6764068.667720944

    1. Initial program 0.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le \frac{-7757395642503235}{33554432} \lor \neg \left(y \le \frac{226964482154373}{33554432}\right):\\ \;\;\;\;1 - \log \left(1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \end{array}\]

Reproduce

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