Average Error: 7.1 → 1.4
Time: 4.4s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\begin{array}{l} t_1 := y \cdot z - z \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\ \mathbf{elif}\;t_1 \leq 1.8358957548390894 \cdot 10^{+154}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{y - t}}{\frac{z}{x}}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* y z) (* z t))))
   (if (<= t_1 (- INFINITY))
     (* (/ x (- y t)) (/ 2.0 z))
     (if (<= t_1 1.8358957548390894e+154)
       (/ (* x 2.0) (* z (- y t)))
       (/ (/ 2.0 (- y t)) (/ z x))))))
double code(double x, double y, double z, double t) {
	return (x * 2.0) / ((y * z) - (t * z));
}
double code(double x, double y, double z, double t) {
	double t_1 = (y * z) - (z * t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (x / (y - t)) * (2.0 / z);
	} else if (t_1 <= 1.8358957548390894e+154) {
		tmp = (x * 2.0) / (z * (y - t));
	} else {
		tmp = (2.0 / (y - t)) / (z / x);
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return (x * 2.0) / ((y * z) - (t * z));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (y * z) - (z * t);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = (x / (y - t)) * (2.0 / z);
	} else if (t_1 <= 1.8358957548390894e+154) {
		tmp = (x * 2.0) / (z * (y - t));
	} else {
		tmp = (2.0 / (y - t)) / (z / x);
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * 2.0) / ((y * z) - (t * z))
def code(x, y, z, t):
	t_1 = (y * z) - (z * t)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = (x / (y - t)) * (2.0 / z)
	elif t_1 <= 1.8358957548390894e+154:
		tmp = (x * 2.0) / (z * (y - t))
	else:
		tmp = (2.0 / (y - t)) / (z / x)
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z)))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(y * z) - Float64(z * t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(x / Float64(y - t)) * Float64(2.0 / z));
	elseif (t_1 <= 1.8358957548390894e+154)
		tmp = Float64(Float64(x * 2.0) / Float64(z * Float64(y - t)));
	else
		tmp = Float64(Float64(2.0 / Float64(y - t)) / Float64(z / x));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x * 2.0) / ((y * z) - (t * z));
end
function tmp_2 = code(x, y, z, t)
	t_1 = (y * z) - (z * t);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = (x / (y - t)) * (2.0 / z);
	elseif (t_1 <= 1.8358957548390894e+154)
		tmp = (x * 2.0) / (z * (y - t));
	else
		tmp = (2.0 / (y - t)) / (z / x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.8358957548390894e+154], N[(N[(x * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[(z / x), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := y \cdot z - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\

\mathbf{elif}\;t_1 \leq 1.8358957548390894 \cdot 10^{+154}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\

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


\end{array}

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.2
Herbie1.4
\[\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.045027827330126 \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 (-.f64 (*.f64 y z) (*.f64 t z)) < -inf.0

    1. Initial program 23.2

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

      \[\leadsto \color{blue}{2 \cdot \frac{\frac{x}{z}}{y - t}} \]
    3. Applied egg-rr0.6

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

      \[\leadsto \color{blue}{\frac{2}{y - t} \cdot \frac{x}{z}} \]
    5. Taylor expanded in x around 0 23.2

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

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

    if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < 1.8358957548390894e154

    1. Initial program 1.7

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

      \[\leadsto \color{blue}{2 \cdot \frac{\frac{x}{z}}{y - t}} \]
    3. Applied egg-rr1.7

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

    if 1.8358957548390894e154 < (-.f64 (*.f64 y z) (*.f64 t z))

    1. Initial program 14.9

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

      \[\leadsto \color{blue}{2 \cdot \frac{\frac{x}{z}}{y - t}} \]
    3. Applied egg-rr1.6

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

      \[\leadsto \color{blue}{\frac{2}{y - t} \cdot \frac{x}{z}} \]
    5. Applied egg-rr1.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\ \;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.8358957548390894 \cdot 10^{+154}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{y - t}}{\frac{z}{x}}\\ \end{array} \]

Reproduce

herbie shell --seed 2022153 
(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.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

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