Average Error: 7.1 → 3.0
Time: 3.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.0866792333001667 \cdot 10^{24}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \mathbf{elif}\;x \le 4.59220674827240897 \cdot 10^{108}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{x}}{z} \cdot \frac{\sqrt{x}}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -4.0866792333001667 \cdot 10^{24}:\\
\;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\

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

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z))))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((x <= -4.0866792333001667e+24)) {
		VAR = ((double) (((double) (1.0 / z)) * ((double) (x / ((double) (((double) (y - t)) / 2.0))))));
	} else {
		double VAR_1;
		if ((x <= 4.592206748272409e+108)) {
			VAR_1 = ((double) (x * ((double) (((double) (2.0 / ((double) (y - t)))) / z))));
		} else {
			VAR_1 = ((double) (((double) (((double) sqrt(x)) / z)) * ((double) (((double) sqrt(x)) / ((double) (((double) (y - t)) / 2.0))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.1
Target2.1
Herbie3.0
\[\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 x < -4.0866792333001667e+24

    1. Initial program 12.5

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

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

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

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

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

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

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

    if -4.0866792333001667e+24 < x < 4.592206748272409e+108

    1. Initial program 3.7

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

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

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

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

    if 4.592206748272409e+108 < x

    1. Initial program 15.0

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied add-sqr-sqrt14.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.0866792333001667 \cdot 10^{24}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \mathbf{elif}\;x \le 4.59220674827240897 \cdot 10^{108}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{x}}{z} \cdot \frac{\sqrt{x}}{\frac{y - t}{2}}\\ \end{array}\]

Reproduce

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