Average Error: 44.5 → 42.0
Time: 11.1s
Precision: 64
\[\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right) = -\infty:\\ \;\;\;\;\left(x \cdot 1\right) \cdot \left(\log y + \log \left(\frac{-1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right)\\ \end{array}\]
\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right)
\begin{array}{l}
\mathbf{if}\;\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right) = -\infty:\\
\;\;\;\;\left(x \cdot 1\right) \cdot \left(\log y + \log \left(\frac{-1}{x}\right)\right)\\

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

\end{array}
double f(double x, double y) {
        double r589427 = x;
        double r589428 = 1.0;
        double r589429 = r589427 * r589428;
        double r589430 = y;
        double r589431 = r589430 / r589427;
        double r589432 = r589428 - r589431;
        double r589433 = log(r589432);
        double r589434 = r589429 * r589433;
        return r589434;
}

double f(double x, double y) {
        double r589435 = x;
        double r589436 = 1.0;
        double r589437 = r589435 * r589436;
        double r589438 = y;
        double r589439 = r589438 / r589435;
        double r589440 = r589436 - r589439;
        double r589441 = log(r589440);
        double r589442 = r589437 * r589441;
        double r589443 = -inf.0;
        bool r589444 = r589442 <= r589443;
        double r589445 = log(r589438);
        double r589446 = -1.0;
        double r589447 = r589446 / r589435;
        double r589448 = log(r589447);
        double r589449 = r589445 + r589448;
        double r589450 = r589437 * r589449;
        double r589451 = r589444 ? r589450 : r589442;
        return r589451;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original44.5
Target44.5
Herbie42.0
\[x \cdot \log \left(1 - \frac{y}{x}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if (* (* x 1.0) (log (- 1.0 (/ y x)))) < -inf.0

    1. Initial program 64.0

      \[\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right)\]
    2. Taylor expanded around inf 64.0

      \[\leadsto \left(x \cdot 1\right) \cdot \color{blue}{\left(\left(\log -1 + \log \left(\frac{1}{x}\right)\right) - \log \left(\frac{1}{y}\right)\right)}\]
    3. Simplified0.3

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

    if -inf.0 < (* (* x 1.0) (log (- 1.0 (/ y x))))

    1. Initial program 43.7

      \[\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right) = -\infty:\\ \;\;\;\;\left(x \cdot 1\right) \cdot \left(\log y + \log \left(\frac{-1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 1\right) \cdot \log \left(1 - \frac{y}{x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1978988140 
(FPCore (x y)
  :name "Data.HyperLogLog.Type:size from hyperloglog-0.3.4, A"
  :precision binary64

  :herbie-target
  (* x (log (- 1 (/ y x))))

  (* (* x 1) (log (- 1 (/ y x)))))