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

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

\end{array}
double f(double x, double y) {
        double r209447 = 1.0;
        double r209448 = x;
        double r209449 = y;
        double r209450 = r209448 - r209449;
        double r209451 = r209447 - r209449;
        double r209452 = r209450 / r209451;
        double r209453 = r209447 - r209452;
        double r209454 = log(r209453);
        double r209455 = r209447 - r209454;
        return r209455;
}

double f(double x, double y) {
        double r209456 = y;
        double r209457 = -119577009.99898484;
        bool r209458 = r209456 <= r209457;
        double r209459 = 24790650.313024804;
        bool r209460 = r209456 <= r209459;
        double r209461 = !r209460;
        bool r209462 = r209458 || r209461;
        double r209463 = 1.0;
        double r209464 = exp(r209463);
        double r209465 = x;
        double r209466 = 2.0;
        double r209467 = pow(r209456, r209466);
        double r209468 = r209465 / r209467;
        double r209469 = 1.0;
        double r209470 = r209469 / r209456;
        double r209471 = r209468 - r209470;
        double r209472 = r209463 * r209471;
        double r209473 = r209465 / r209456;
        double r209474 = r209472 + r209473;
        double r209475 = r209464 / r209474;
        double r209476 = log(r209475);
        double r209477 = r209465 - r209456;
        double r209478 = r209463 - r209456;
        double r209479 = r209469 / r209478;
        double r209480 = r209477 * r209479;
        double r209481 = r209463 - r209480;
        double r209482 = sqrt(r209481);
        double r209483 = r209469 / r209482;
        double r209484 = log(r209483);
        double r209485 = r209464 / r209482;
        double r209486 = log(r209485);
        double r209487 = r209484 + r209486;
        double r209488 = r209462 ? r209476 : r209487;
        return r209488;
}

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.5
Target0.1
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;y \lt -81284752.619472414:\\ \;\;\;\;1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \lt 3.0094271212461764 \cdot 10^{25}:\\ \;\;\;\;\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 < -119577009.99898484 or 24790650.313024804 < y

    1. Initial program 46.9

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

      \[\leadsto 1 - \log \left(1 - \color{blue}{\left(x - y\right) \cdot \frac{1}{1 - y}}\right)\]
    4. Using strategy rm
    5. Applied add-log-exp45.8

      \[\leadsto \color{blue}{\log \left(e^{1}\right)} - \log \left(1 - \left(x - y\right) \cdot \frac{1}{1 - y}\right)\]
    6. Applied diff-log45.8

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

      \[\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)\]
    8. Simplified0.2

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

    if -119577009.99898484 < y < 24790650.313024804

    1. Initial program 0.1

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

      \[\leadsto 1 - \log \left(1 - \color{blue}{\left(x - y\right) \cdot \frac{1}{1 - y}}\right)\]
    4. Using strategy rm
    5. Applied add-log-exp0.1

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

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

      \[\leadsto \log \left(\frac{e^{1}}{\color{blue}{\sqrt{1 - \left(x - y\right) \cdot \frac{1}{1 - y}} \cdot \sqrt{1 - \left(x - y\right) \cdot \frac{1}{1 - y}}}}\right)\]
    9. Applied *-un-lft-identity0.1

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

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

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

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

Reproduce

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