Average Error: 7.0 → 3.6
Time: 16.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le -1.972900476191872959301707475174207697449 \cdot 10^{-131}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;x \cdot 2 \le -2.948565765774791208805121121210129224506 \cdot 10^{-308}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;x \cdot 2 \le 6.332472153388493844618311621980253613613 \cdot 10^{94}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{elif}\;x \cdot 2 \le 1.003786517631935993744496743464652455573 \cdot 10^{196}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \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}\;x \cdot 2 \le -1.972900476191872959301707475174207697449 \cdot 10^{-131}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

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

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

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

\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 r368187 = x;
        double r368188 = 2.0;
        double r368189 = r368187 * r368188;
        double r368190 = y;
        double r368191 = z;
        double r368192 = r368190 * r368191;
        double r368193 = t;
        double r368194 = r368193 * r368191;
        double r368195 = r368192 - r368194;
        double r368196 = r368189 / r368195;
        return r368196;
}

double f(double x, double y, double z, double t) {
        double r368197 = x;
        double r368198 = 2.0;
        double r368199 = r368197 * r368198;
        double r368200 = -1.972900476191873e-131;
        bool r368201 = r368199 <= r368200;
        double r368202 = y;
        double r368203 = t;
        double r368204 = r368202 - r368203;
        double r368205 = r368199 / r368204;
        double r368206 = z;
        double r368207 = r368205 / r368206;
        double r368208 = -2.948565765774791e-308;
        bool r368209 = r368199 <= r368208;
        double r368210 = r368206 * r368204;
        double r368211 = r368199 / r368210;
        double r368212 = 6.332472153388494e+94;
        bool r368213 = r368199 <= r368212;
        double r368214 = r368197 / r368206;
        double r368215 = r368214 * r368198;
        double r368216 = r368215 / r368204;
        double r368217 = 1.003786517631936e+196;
        bool r368218 = r368199 <= r368217;
        double r368219 = r368218 ? r368207 : r368211;
        double r368220 = r368213 ? r368216 : r368219;
        double r368221 = r368209 ? r368211 : r368220;
        double r368222 = r368201 ? r368207 : r368221;
        return r368222;
}

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
Herbie3.6
\[\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 3 regimes
  2. if (* x 2.0) < -1.972900476191873e-131 or 6.332472153388494e+94 < (* x 2.0) < 1.003786517631936e+196

    1. Initial program 9.1

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

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

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

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

    if -1.972900476191873e-131 < (* x 2.0) < -2.948565765774791e-308 or 1.003786517631936e+196 < (* x 2.0)

    1. Initial program 7.8

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

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

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

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

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

    if -2.948565765774791e-308 < (* x 2.0) < 6.332472153388494e+94

    1. Initial program 3.8

      \[\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 *-un-lft-identity2.0

      \[\leadsto \frac{2}{\color{blue}{1 \cdot \left(y - t\right)}} \cdot \frac{x}{z}\]
    5. Applied *-un-lft-identity2.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \le -1.972900476191872959301707475174207697449 \cdot 10^{-131}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;x \cdot 2 \le -2.948565765774791208805121121210129224506 \cdot 10^{-308}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;x \cdot 2 \le 6.332472153388493844618311621980253613613 \cdot 10^{94}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{elif}\;x \cdot 2 \le 1.003786517631935993744496743464652455573 \cdot 10^{196}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]

Reproduce

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