Average Error: 15.2 → 0.2
Time: 9.2s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1950896635033006241202453604204544:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.525261129384541486350799582595845140217 \cdot 10^{75}:\\ \;\;\;\;\left(2 \cdot x\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -1950896635033006241202453604204544:\\
\;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\

\mathbf{elif}\;x \le 1.525261129384541486350799582595845140217 \cdot 10^{75}:\\
\;\;\;\;\left(2 \cdot x\right) \cdot \frac{y}{x - y}\\

\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\

\end{array}
double f(double x, double y) {
        double r24649326 = x;
        double r24649327 = 2.0;
        double r24649328 = r24649326 * r24649327;
        double r24649329 = y;
        double r24649330 = r24649328 * r24649329;
        double r24649331 = r24649326 - r24649329;
        double r24649332 = r24649330 / r24649331;
        return r24649332;
}

double f(double x, double y) {
        double r24649333 = x;
        double r24649334 = -1.9508966350330062e+33;
        bool r24649335 = r24649333 <= r24649334;
        double r24649336 = 2.0;
        double r24649337 = r24649336 * r24649333;
        double r24649338 = y;
        double r24649339 = r24649333 - r24649338;
        double r24649340 = r24649337 / r24649339;
        double r24649341 = r24649340 * r24649338;
        double r24649342 = 1.5252611293845415e+75;
        bool r24649343 = r24649333 <= r24649342;
        double r24649344 = r24649338 / r24649339;
        double r24649345 = r24649337 * r24649344;
        double r24649346 = r24649343 ? r24649345 : r24649341;
        double r24649347 = r24649335 ? r24649341 : r24649346;
        return r24649347;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.2
Target0.3
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt -1.721044263414944729490876394165887012892 \cdot 10^{81}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \lt 83645045635564432:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.9508966350330062e+33 or 1.5252611293845415e+75 < x

    1. Initial program 19.0

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l*17.4

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.1

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y}\]

    if -1.9508966350330062e+33 < x < 1.5252611293845415e+75

    1. Initial program 12.5

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity12.5

      \[\leadsto \frac{\left(x \cdot 2\right) \cdot y}{\color{blue}{1 \cdot \left(x - y\right)}}\]
    4. Applied times-frac0.3

      \[\leadsto \color{blue}{\frac{x \cdot 2}{1} \cdot \frac{y}{x - y}}\]
    5. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1950896635033006241202453604204544:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.525261129384541486350799582595845140217 \cdot 10^{75}:\\ \;\;\;\;\left(2 \cdot x\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))