Average Error: 18.3 → 0.1
Time: 8.6s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -29528028708.40175628662109375 \lor \neg \left(y \le 51008935.552216000854969024658203125\right):\\ \;\;\;\;1 - \log \left(1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(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 -29528028708.40175628662109375 \lor \neg \left(y \le 51008935.552216000854969024658203125\right):\\
\;\;\;\;1 - \log \left(1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}\right)\\

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

\end{array}
double f(double x, double y) {
        double r278295 = 1.0;
        double r278296 = x;
        double r278297 = y;
        double r278298 = r278296 - r278297;
        double r278299 = r278295 - r278297;
        double r278300 = r278298 / r278299;
        double r278301 = r278295 - r278300;
        double r278302 = log(r278301);
        double r278303 = r278295 - r278302;
        return r278303;
}

double f(double x, double y) {
        double r278304 = y;
        double r278305 = -29528028708.401756;
        bool r278306 = r278304 <= r278305;
        double r278307 = 51008935.552216;
        bool r278308 = r278304 <= r278307;
        double r278309 = !r278308;
        bool r278310 = r278306 || r278309;
        double r278311 = 1.0;
        double r278312 = x;
        double r278313 = 2.0;
        double r278314 = pow(r278304, r278313);
        double r278315 = r278312 / r278314;
        double r278316 = 1.0;
        double r278317 = r278316 / r278304;
        double r278318 = r278315 - r278317;
        double r278319 = r278311 * r278318;
        double r278320 = r278312 / r278304;
        double r278321 = r278319 + r278320;
        double r278322 = log(r278321);
        double r278323 = r278311 - r278322;
        double r278324 = r278312 - r278304;
        double r278325 = r278311 - r278304;
        double r278326 = r278324 / r278325;
        double r278327 = r278311 - r278326;
        double r278328 = log(r278327);
        double r278329 = r278311 - r278328;
        double r278330 = r278310 ? r278323 : r278329;
        return r278330;
}

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.3
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 < -29528028708.401756 or 51008935.552216 < y

    1. Initial program 46.9

      \[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 -29528028708.401756 < y < 51008935.552216

    1. Initial program 0.2

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

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

      \[\leadsto \color{blue}{\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity0.2

      \[\leadsto \log \left(\frac{e^{1}}{\color{blue}{1 \cdot \left(1 - \frac{x - y}{1 - y}\right)}}\right)\]
    7. Applied add-sqr-sqrt0.2

      \[\leadsto \log \left(\frac{\color{blue}{\sqrt{e^{1}} \cdot \sqrt{e^{1}}}}{1 \cdot \left(1 - \frac{x - y}{1 - y}\right)}\right)\]
    8. Applied times-frac0.2

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

      \[\leadsto \log \left(\color{blue}{\sqrt{e^{1}}} \cdot \frac{\sqrt{e^{1}}}{1 - \frac{x - y}{1 - y}}\right)\]
    10. Using strategy rm
    11. Applied associate-*r/0.2

      \[\leadsto \log \color{blue}{\left(\frac{\sqrt{e^{1}} \cdot \sqrt{e^{1}}}{1 - \frac{x - y}{1 - y}}\right)}\]
    12. Applied log-div0.2

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

      \[\leadsto \color{blue}{1} - \log \left(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 -29528028708.40175628662109375 \lor \neg \left(y \le 51008935.552216000854969024658203125\right):\\ \;\;\;\;1 - \log \left(1 \cdot \left(\frac{x}{{y}^{2}} - \frac{1}{y}\right) + \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(1 - \frac{x - y}{1 - y}\right)\\ \end{array}\]

Reproduce

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