Average Error: 6.7 → 2.4
Time: 15.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.785623242383369987871892505209292076841 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \mathbf{elif}\;x \le 2.564279827638175653187139986421665920809 \cdot 10^{-14}:\\ \;\;\;\;\frac{2 \cdot x}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -2.785623242383369987871892505209292076841 \cdot 10^{-67}:\\
\;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\

\mathbf{elif}\;x \le 2.564279827638175653187139986421665920809 \cdot 10^{-14}:\\
\;\;\;\;\frac{2 \cdot x}{z \cdot \left(y - t\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r24730913 = x;
        double r24730914 = 2.0;
        double r24730915 = r24730913 * r24730914;
        double r24730916 = y;
        double r24730917 = z;
        double r24730918 = r24730916 * r24730917;
        double r24730919 = t;
        double r24730920 = r24730919 * r24730917;
        double r24730921 = r24730918 - r24730920;
        double r24730922 = r24730915 / r24730921;
        return r24730922;
}

double f(double x, double y, double z, double t) {
        double r24730923 = x;
        double r24730924 = -2.78562324238337e-67;
        bool r24730925 = r24730923 <= r24730924;
        double r24730926 = 2.0;
        double r24730927 = r24730926 * r24730923;
        double r24730928 = y;
        double r24730929 = t;
        double r24730930 = r24730928 - r24730929;
        double r24730931 = r24730927 / r24730930;
        double r24730932 = z;
        double r24730933 = r24730931 / r24730932;
        double r24730934 = 2.5642798276381757e-14;
        bool r24730935 = r24730923 <= r24730934;
        double r24730936 = r24730932 * r24730930;
        double r24730937 = r24730927 / r24730936;
        double r24730938 = r24730935 ? r24730937 : r24730933;
        double r24730939 = r24730925 ? r24730933 : r24730938;
        return r24730939;
}

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.7
Target2.2
Herbie2.4
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061113708240820439530037456 \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.045027827330126029709547581125571222799 \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 x < -2.78562324238337e-67 or 2.5642798276381757e-14 < x

    1. Initial program 9.7

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

      \[\leadsto \color{blue}{\frac{2}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied associate-*r/2.6

      \[\leadsto \color{blue}{\frac{\frac{2}{y - t} \cdot x}{z}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity2.6

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

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

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

    if -2.78562324238337e-67 < x < 2.5642798276381757e-14

    1. Initial program 3.3

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

      \[\leadsto \color{blue}{\frac{2}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied frac-times2.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.785623242383369987871892505209292076841 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \mathbf{elif}\;x \le 2.564279827638175653187139986421665920809 \cdot 10^{-14}:\\ \;\;\;\;\frac{2 \cdot x}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \end{array}\]

Reproduce

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