Average Error: 7.0 → 2.1
Time: 17.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.0679094448922225 \cdot 10^{66}:\\ \;\;\;\;\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 5.15733133231175267 \cdot 10^{-28}:\\ \;\;\;\;\frac{x}{z \cdot \frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -3.0679094448922225 \cdot 10^{66}:\\
\;\;\;\;\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\\

\mathbf{elif}\;z \le 5.15733133231175267 \cdot 10^{-28}:\\
\;\;\;\;\frac{x}{z \cdot \frac{y - t}{2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r2563 = x;
        double r2564 = 2.0;
        double r2565 = r2563 * r2564;
        double r2566 = y;
        double r2567 = z;
        double r2568 = r2566 * r2567;
        double r2569 = t;
        double r2570 = r2569 * r2567;
        double r2571 = r2568 - r2570;
        double r2572 = r2565 / r2571;
        return r2572;
}

double f(double x, double y, double z, double t) {
        double r2573 = z;
        double r2574 = -3.0679094448922225e+66;
        bool r2575 = r2573 <= r2574;
        double r2576 = x;
        double r2577 = cbrt(r2576);
        double r2578 = r2573 / r2577;
        double r2579 = r2577 / r2578;
        double r2580 = y;
        double r2581 = t;
        double r2582 = r2580 - r2581;
        double r2583 = 2.0;
        double r2584 = r2582 / r2583;
        double r2585 = r2577 / r2584;
        double r2586 = r2579 * r2585;
        double r2587 = 5.157331332311753e-28;
        bool r2588 = r2573 <= r2587;
        double r2589 = r2573 * r2584;
        double r2590 = r2576 / r2589;
        double r2591 = r2576 / r2573;
        double r2592 = r2591 / r2584;
        double r2593 = r2588 ? r2590 : r2592;
        double r2594 = r2575 ? r2586 : r2593;
        return r2594;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.0
Target2.2
Herbie2.1
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt 1.04502782733012586 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -3.0679094448922225e+66

    1. Initial program 13.6

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Simplified11.1

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity11.1

      \[\leadsto \frac{x}{\frac{z \cdot \left(y - t\right)}{\color{blue}{1 \cdot 2}}}\]
    5. Applied times-frac11.1

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied add-cube-cbrt11.5

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}}{\frac{z}{1} \cdot \frac{y - t}{2}}\]
    7. Applied times-frac1.7

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\frac{z}{1}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}}\]
    8. Simplified1.7

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\]

    if -3.0679094448922225e+66 < z < 5.157331332311753e-28

    1. Initial program 2.4

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Simplified2.4

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity2.4

      \[\leadsto \frac{x}{\frac{z \cdot \left(y - t\right)}{\color{blue}{1 \cdot 2}}}\]
    5. Applied times-frac2.4

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Simplified2.4

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

    if 5.157331332311753e-28 < z

    1. Initial program 9.5

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Simplified7.2

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity7.2

      \[\leadsto \frac{x}{\frac{z \cdot \left(y - t\right)}{\color{blue}{1 \cdot 2}}}\]
    5. Applied times-frac7.2

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied associate-/r*1.7

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{z}{1}}}{\frac{y - t}{2}}}\]
    7. Simplified1.7

      \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{y - t}{2}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.0679094448922225 \cdot 10^{66}:\\ \;\;\;\;\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 5.15733133231175267 \cdot 10^{-28}:\\ \;\;\;\;\frac{x}{z \cdot \frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020025 
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (if (< (/ (* x 2) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2) (if (< (/ (* x 2) (- (* y z) (* t z))) 1.0450278273301259e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

  (/ (* x 2) (- (* y z) (* t z))))