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

\mathbf{elif}\;x \le 3.45921811371722128919155174305014492874 \cdot 10^{-46}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r22565084 = x;
        double r22565085 = 2.0;
        double r22565086 = r22565084 * r22565085;
        double r22565087 = y;
        double r22565088 = r22565086 * r22565087;
        double r22565089 = r22565084 - r22565087;
        double r22565090 = r22565088 / r22565089;
        return r22565090;
}

double f(double x, double y) {
        double r22565091 = x;
        double r22565092 = -9.761946362776927e+30;
        bool r22565093 = r22565091 <= r22565092;
        double r22565094 = y;
        double r22565095 = 2.0;
        double r22565096 = r22565094 * r22565095;
        double r22565097 = r22565091 - r22565094;
        double r22565098 = r22565091 / r22565097;
        double r22565099 = r22565096 * r22565098;
        double r22565100 = 3.4592181137172213e-46;
        bool r22565101 = r22565091 <= r22565100;
        double r22565102 = r22565091 * r22565095;
        double r22565103 = r22565097 / r22565094;
        double r22565104 = r22565102 / r22565103;
        double r22565105 = r22565101 ? r22565104 : r22565099;
        double r22565106 = r22565093 ? r22565099 : r22565105;
        return r22565106;
}

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.2
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 < -9.761946362776927e+30 or 3.4592181137172213e-46 < x

    1. Initial program 15.6

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied div-inv14.5

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

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

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

    if -9.761946362776927e+30 < x < 3.4592181137172213e-46

    1. Initial program 14.8

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

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

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

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(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)))