Average Error: 7.1 → 2.4
Time: 16.2s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.00904334297314605 \cdot 10^{-54} \lor \neg \left(z \le 35899075.9933054224\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -4.00904334297314605 \cdot 10^{-54} \lor \neg \left(z \le 35899075.9933054224\right):\\
\;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r428764 = x;
        double r428765 = 2.0;
        double r428766 = r428764 * r428765;
        double r428767 = y;
        double r428768 = z;
        double r428769 = r428767 * r428768;
        double r428770 = t;
        double r428771 = r428770 * r428768;
        double r428772 = r428769 - r428771;
        double r428773 = r428766 / r428772;
        return r428773;
}

double f(double x, double y, double z, double t) {
        double r428774 = z;
        double r428775 = -4.009043342973146e-54;
        bool r428776 = r428774 <= r428775;
        double r428777 = 35899075.99330542;
        bool r428778 = r428774 <= r428777;
        double r428779 = !r428778;
        bool r428780 = r428776 || r428779;
        double r428781 = 2.0;
        double r428782 = x;
        double r428783 = r428781 * r428782;
        double r428784 = r428783 / r428774;
        double r428785 = y;
        double r428786 = t;
        double r428787 = r428785 - r428786;
        double r428788 = r428784 / r428787;
        double r428789 = r428782 * r428781;
        double r428790 = r428774 * r428787;
        double r428791 = r428789 / r428790;
        double r428792 = r428780 ? r428788 : r428791;
        return r428792;
}

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.1
Target2.2
Herbie2.4
\[\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.045027827330126 \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 2 regimes
  2. if z < -4.009043342973146e-54 or 35899075.99330542 < z

    1. Initial program 10.3

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied div-inv8.6

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt8.6

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

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{z} \cdot \frac{\sqrt[3]{1}}{y - t}\right)}\]
    8. Simplified8.0

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\color{blue}{\frac{1}{z}} \cdot \frac{\sqrt[3]{1}}{y - t}\right)\]
    9. Simplified8.0

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{\frac{1}{y - t}}\right)\]
    10. Using strategy rm
    11. Applied un-div-inv7.9

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\frac{\frac{1}{z}}{y - t}}\]
    12. Applied associate-*r/2.1

      \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot \frac{1}{z}}{y - t}}\]
    13. Simplified2.0

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

    if -4.009043342973146e-54 < z < 35899075.99330542

    1. Initial program 2.8

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt3.1

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

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{\frac{1}{y - t}}\right)\]
    10. Using strategy rm
    11. Applied frac-times3.1

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\frac{1 \cdot 1}{z \cdot \left(y - t\right)}}\]
    12. Applied associate-*r/2.8

      \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot \left(1 \cdot 1\right)}{z \cdot \left(y - t\right)}}\]
    13. Simplified2.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.00904334297314605 \cdot 10^{-54} \lor \neg \left(z \le 35899075.9933054224\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]

Reproduce

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

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

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