Average Error: 6.6 → 1.2
Time: 6.3s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.9602188562953434 \cdot 10^{+290}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq 1.9602188562953434 \cdot 10^{+290}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (- (* y z) (* z t)) (- INFINITY))
   (* (/ x z) (/ 2.0 (- y t)))
   (if (<= (- (* y z) (* z t)) 1.9602188562953434e+290)
     (/ (* x 2.0) (- (* y z) (* z t)))
     (/ (/ (* x 2.0) (- y t)) z))))
double code(double x, double y, double z, double t) {
	return (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z)))));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= ((double) -(((double) INFINITY))))) {
		tmp = ((double) ((x / z) * (2.0 / ((double) (y - t)))));
	} else {
		double tmp_1;
		if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= 1.9602188562953434e+290)) {
			tmp_1 = (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (z * t)))));
		} else {
			tmp_1 = ((((double) (x * 2.0)) / ((double) (y - t))) / z);
		}
		tmp = tmp_1;
	}
	return tmp;
}

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
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} < -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} < 1.0450278273301259 \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 (- (* y z) (* t z)) < -inf.0

    1. Initial program Error: 19.7 bits

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. SimplifiedError: 17.7 bits

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identityError: 17.7 bits

      \[\leadsto x \cdot \frac{\frac{2}{y - t}}{\color{blue}{1 \cdot z}}\]
    5. Applied *-un-lft-identityError: 17.7 bits

      \[\leadsto x \cdot \frac{\frac{2}{\color{blue}{1 \cdot \left(y - t\right)}}}{1 \cdot z}\]
    6. Applied add-sqr-sqrtError: 17.7 bits

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

      \[\leadsto x \cdot \frac{\color{blue}{\frac{\sqrt{2}}{1} \cdot \frac{\sqrt{2}}{y - t}}}{1 \cdot z}\]
    8. Applied times-fracError: 17.7 bits

      \[\leadsto x \cdot \color{blue}{\left(\frac{\frac{\sqrt{2}}{1}}{1} \cdot \frac{\frac{\sqrt{2}}{y - t}}{z}\right)}\]
    9. Applied associate-*r*Error: 17.7 bits

      \[\leadsto \color{blue}{\left(x \cdot \frac{\frac{\sqrt{2}}{1}}{1}\right) \cdot \frac{\frac{\sqrt{2}}{y - t}}{z}}\]
    10. SimplifiedError: 17.7 bits

      \[\leadsto \color{blue}{\left(x \cdot \sqrt{2}\right)} \cdot \frac{\frac{\sqrt{2}}{y - t}}{z}\]
    11. Using strategy rm
    12. Applied pow1Error: 17.7 bits

      \[\leadsto \left(x \cdot \sqrt{2}\right) \cdot \color{blue}{{\left(\frac{\frac{\sqrt{2}}{y - t}}{z}\right)}^{1}}\]
    13. Applied pow1Error: 17.7 bits

      \[\leadsto \left(x \cdot \color{blue}{{\left(\sqrt{2}\right)}^{1}}\right) \cdot {\left(\frac{\frac{\sqrt{2}}{y - t}}{z}\right)}^{1}\]
    14. Applied pow1Error: 17.7 bits

      \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {\left(\sqrt{2}\right)}^{1}\right) \cdot {\left(\frac{\frac{\sqrt{2}}{y - t}}{z}\right)}^{1}\]
    15. Applied pow-prod-downError: 17.7 bits

      \[\leadsto \color{blue}{{\left(x \cdot \sqrt{2}\right)}^{1}} \cdot {\left(\frac{\frac{\sqrt{2}}{y - t}}{z}\right)}^{1}\]
    16. Applied pow-prod-downError: 17.7 bits

      \[\leadsto \color{blue}{{\left(\left(x \cdot \sqrt{2}\right) \cdot \frac{\frac{\sqrt{2}}{y - t}}{z}\right)}^{1}}\]
    17. SimplifiedError: 0.1 bits

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

    if -inf.0 < (- (* y z) (* t z)) < 1.9602188562953434e290

    1. Initial program Error: 1.5 bits

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

    if 1.9602188562953434e290 < (- (* y z) (* t z))

    1. Initial program Error: 25.5 bits

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. SimplifiedError: 15.8 bits

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identityError: 15.8 bits

      \[\leadsto x \cdot \frac{\frac{2}{y - t}}{\color{blue}{1 \cdot z}}\]
    5. Applied *-un-lft-identityError: 15.8 bits

      \[\leadsto x \cdot \frac{\frac{2}{\color{blue}{1 \cdot \left(y - t\right)}}}{1 \cdot z}\]
    6. Applied add-sqr-sqrtError: 15.9 bits

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

      \[\leadsto x \cdot \frac{\color{blue}{\frac{\sqrt{2}}{1} \cdot \frac{\sqrt{2}}{y - t}}}{1 \cdot z}\]
    8. Applied times-fracError: 15.9 bits

      \[\leadsto x \cdot \color{blue}{\left(\frac{\frac{\sqrt{2}}{1}}{1} \cdot \frac{\frac{\sqrt{2}}{y - t}}{z}\right)}\]
    9. Applied associate-*r*Error: 15.9 bits

      \[\leadsto \color{blue}{\left(x \cdot \frac{\frac{\sqrt{2}}{1}}{1}\right) \cdot \frac{\frac{\sqrt{2}}{y - t}}{z}}\]
    10. SimplifiedError: 15.9 bits

      \[\leadsto \color{blue}{\left(x \cdot \sqrt{2}\right)} \cdot \frac{\frac{\sqrt{2}}{y - t}}{z}\]
    11. Using strategy rm
    12. Applied associate-*r/Error: 0.3 bits

      \[\leadsto \color{blue}{\frac{\left(x \cdot \sqrt{2}\right) \cdot \frac{\sqrt{2}}{y - t}}{z}}\]
    13. SimplifiedError: 0.1 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.9602188562953434 \cdot 10^{+290}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \end{array}\]

Reproduce

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

  :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.0450278273301259e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

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