Average Error: 18.3 → 0.1
Time: 6.4s
Precision: 64
\[1 - \log \left(1 - \frac{x - y}{1 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -199754789.0343833863735198974609375 \lor \neg \left(y \le 32910417.669902421534061431884765625\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{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 -199754789.0343833863735198974609375 \lor \neg \left(y \le 32910417.669902421534061431884765625\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{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\

\end{array}
double f(double x, double y) {
        double r380919 = 1.0;
        double r380920 = x;
        double r380921 = y;
        double r380922 = r380920 - r380921;
        double r380923 = r380919 - r380921;
        double r380924 = r380922 / r380923;
        double r380925 = r380919 - r380924;
        double r380926 = log(r380925);
        double r380927 = r380919 - r380926;
        return r380927;
}

double f(double x, double y) {
        double r380928 = y;
        double r380929 = -199754789.0343834;
        bool r380930 = r380928 <= r380929;
        double r380931 = 32910417.66990242;
        bool r380932 = r380928 <= r380931;
        double r380933 = !r380932;
        bool r380934 = r380930 || r380933;
        double r380935 = 1.0;
        double r380936 = exp(r380935);
        double r380937 = x;
        double r380938 = 2.0;
        double r380939 = pow(r380928, r380938);
        double r380940 = r380937 / r380939;
        double r380941 = 1.0;
        double r380942 = r380941 / r380928;
        double r380943 = r380940 - r380942;
        double r380944 = r380935 * r380943;
        double r380945 = r380937 / r380928;
        double r380946 = r380944 + r380945;
        double r380947 = r380936 / r380946;
        double r380948 = log(r380947);
        double r380949 = r380937 - r380928;
        double r380950 = r380935 - r380928;
        double r380951 = r380949 / r380950;
        double r380952 = r380935 - r380951;
        double r380953 = r380936 / r380952;
        double r380954 = log(r380953);
        double r380955 = r380934 ? r380948 : r380954;
        return r380955;
}

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 < -199754789.0343834 or 32910417.66990242 < y

    1. Initial program 46.8

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

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

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

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

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

    if -199754789.0343834 < y < 32910417.66990242

    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 -199754789.0343833863735198974609375 \lor \neg \left(y \le 32910417.669902421534061431884765625\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{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \end{array}\]

Reproduce

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