Average Error: 15.2 → 0.2
Time: 10.8s
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 r20105779 = x;
        double r20105780 = 2.0;
        double r20105781 = r20105779 * r20105780;
        double r20105782 = y;
        double r20105783 = r20105781 * r20105782;
        double r20105784 = r20105779 - r20105782;
        double r20105785 = r20105783 / r20105784;
        return r20105785;
}

double f(double x, double y) {
        double r20105786 = x;
        double r20105787 = -1.9508966350330062e+33;
        bool r20105788 = r20105786 <= r20105787;
        double r20105789 = 2.0;
        double r20105790 = r20105789 * r20105786;
        double r20105791 = y;
        double r20105792 = r20105786 - r20105791;
        double r20105793 = r20105790 / r20105792;
        double r20105794 = r20105793 * r20105791;
        double r20105795 = 1.5252611293845415e+75;
        bool r20105796 = r20105786 <= r20105795;
        double r20105797 = r20105791 / r20105792;
        double r20105798 = r20105790 * r20105797;
        double r20105799 = r20105796 ? r20105798 : r20105794;
        double r20105800 = r20105788 ? r20105794 : r20105799;
        return r20105800;
}

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 +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)))