Average Error: 6.7 → 2.4
Time: 3.8s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.499166101974862942698762894910012339882 \cdot 10^{-79} \lor \neg \left(x \le 2.289450428614663466195578443185558361467 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\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}\;x \le -1.499166101974862942698762894910012339882 \cdot 10^{-79} \lor \neg \left(x \le 2.289450428614663466195578443185558361467 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{1}{z} \cdot \frac{x}{\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 r538152 = x;
        double r538153 = 2.0;
        double r538154 = r538152 * r538153;
        double r538155 = y;
        double r538156 = z;
        double r538157 = r538155 * r538156;
        double r538158 = t;
        double r538159 = r538158 * r538156;
        double r538160 = r538157 - r538159;
        double r538161 = r538154 / r538160;
        return r538161;
}

double f(double x, double y, double z, double t) {
        double r538162 = x;
        double r538163 = -1.499166101974863e-79;
        bool r538164 = r538162 <= r538163;
        double r538165 = 2.2894504286146635e-11;
        bool r538166 = r538162 <= r538165;
        double r538167 = !r538166;
        bool r538168 = r538164 || r538167;
        double r538169 = 1.0;
        double r538170 = z;
        double r538171 = r538169 / r538170;
        double r538172 = y;
        double r538173 = t;
        double r538174 = r538172 - r538173;
        double r538175 = 2.0;
        double r538176 = r538174 / r538175;
        double r538177 = r538162 / r538176;
        double r538178 = r538171 * r538177;
        double r538179 = r538162 / r538170;
        double r538180 = r538179 / r538176;
        double r538181 = r538168 ? r538178 : r538180;
        return r538181;
}

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.045027827330125861587720199944080049996 \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 < -1.499166101974863e-79 or 2.2894504286146635e-11 < x

    1. Initial program 9.3

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity8.4

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{z}{1} \cdot \frac{y - t}{2}}\]
    7. Applied times-frac2.5

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

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

    if -1.499166101974863e-79 < x < 2.2894504286146635e-11

    1. Initial program 3.5

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

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

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

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

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

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

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

Reproduce

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