Average Error: 6.6 → 2.5
Time: 3.4s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.3210023240845016 \cdot 10^{-45}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{{\left(y - t\right)}^{1}}{2}}\\ \mathbf{elif}\;z \le 2.3298143112782626 \cdot 10^{89}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x \cdot 2}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -9.3210023240845016 \cdot 10^{-45}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{{\left(y - t\right)}^{1}}{2}}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r581775 = x;
        double r581776 = 2.0;
        double r581777 = r581775 * r581776;
        double r581778 = y;
        double r581779 = z;
        double r581780 = r581778 * r581779;
        double r581781 = t;
        double r581782 = r581781 * r581779;
        double r581783 = r581780 - r581782;
        double r581784 = r581777 / r581783;
        return r581784;
}

double f(double x, double y, double z, double t) {
        double r581785 = z;
        double r581786 = -9.321002324084502e-45;
        bool r581787 = r581785 <= r581786;
        double r581788 = x;
        double r581789 = r581788 / r581785;
        double r581790 = y;
        double r581791 = t;
        double r581792 = r581790 - r581791;
        double r581793 = 1.0;
        double r581794 = pow(r581792, r581793);
        double r581795 = 2.0;
        double r581796 = r581794 / r581795;
        double r581797 = r581789 / r581796;
        double r581798 = 2.3298143112782626e+89;
        bool r581799 = r581785 <= r581798;
        double r581800 = r581795 / r581792;
        double r581801 = r581800 / r581785;
        double r581802 = r581788 * r581801;
        double r581803 = r581793 / r581785;
        double r581804 = r581788 * r581795;
        double r581805 = r581804 / r581792;
        double r581806 = r581803 * r581805;
        double r581807 = r581799 ? r581802 : r581806;
        double r581808 = r581787 ? r581797 : r581807;
        return r581808;
}

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

Original6.6
Target2.1
Herbie2.5
\[\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 < -9.321002324084502e-45

    1. Initial program 9.2

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

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

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

      \[\leadsto \frac{x}{\frac{\color{blue}{{z}^{1}} \cdot {\left(y - t\right)}^{1}}{2}}\]
    6. Applied pow-prod-down7.4

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

      \[\leadsto \frac{x}{\frac{{\left(z \cdot \left(y - t\right)\right)}^{1}}{\color{blue}{1 \cdot 2}}}\]
    9. Applied unpow-prod-down7.4

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{{z}^{1}}{1}}}{\frac{{\left(y - t\right)}^{1}}{2}}}\]
    12. Simplified1.7

      \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{{\left(y - t\right)}^{1}}{2}}\]

    if -9.321002324084502e-45 < z < 2.3298143112782626e+89

    1. Initial program 2.6

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

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

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

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

    if 2.3298143112782626e+89 < z

    1. Initial program 12.9

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

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

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

      \[\leadsto \frac{x}{\frac{\color{blue}{{z}^{1}} \cdot {\left(y - t\right)}^{1}}{2}}\]
    6. Applied pow-prod-down10.8

      \[\leadsto \frac{x}{\frac{\color{blue}{{\left(z \cdot \left(y - t\right)\right)}^{1}}}{2}}\]
    7. Using strategy rm
    8. Applied div-inv10.8

      \[\leadsto \frac{x}{\color{blue}{{\left(z \cdot \left(y - t\right)\right)}^{1} \cdot \frac{1}{2}}}\]
    9. Applied *-un-lft-identity10.8

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{z}}{y - t}} \cdot \frac{x}{\frac{1}{2}}\]
    12. Simplified10.0

      \[\leadsto \frac{\frac{1}{z}}{y - t} \cdot \color{blue}{\left(x \cdot 2\right)}\]
    13. Using strategy rm
    14. Applied div-inv10.0

      \[\leadsto \color{blue}{\left(\frac{1}{z} \cdot \frac{1}{y - t}\right)} \cdot \left(x \cdot 2\right)\]
    15. Applied associate-*l*3.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -9.3210023240845016 \cdot 10^{-45}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{{\left(y - t\right)}^{1}}{2}}\\ \mathbf{elif}\;z \le 2.3298143112782626 \cdot 10^{89}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x \cdot 2}{y - t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020003 
(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))))