Average Error: 7.1 → 1.2
Time: 4.6s
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 -6.014905296048345 \cdot 10^{+224}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot -2}{t - y}\\ \mathbf{elif}\;t_1 \leq 2.305918027910845 \cdot 10^{+262}:\\ \;\;\;\;2 \cdot \frac{x}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{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
 (let* ((t_1 (- (* y z) (* z t))))
   (if (<= t_1 -6.014905296048345e+224)
     (/ (* (/ x z) -2.0) (- t y))
     (if (<= t_1 2.305918027910845e+262)
       (* 2.0 (/ x (* z (- y t))))
       (/ (* x (/ 2.0 (- y t))) z)))))
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 <= -6.014905296048345e+224) {
		tmp = ((x / z) * -2.0) / (t - y);
	} else if (t_1 <= 2.305918027910845e+262) {
		tmp = 2.0 * (x / (z * (y - t)));
	} else {
		tmp = (x * (2.0 / (y - t))) / z;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x * 2.0d0) / ((y * z) - (t * z))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (y * z) - (z * t)
    if (t_1 <= (-6.014905296048345d+224)) then
        tmp = ((x / z) * (-2.0d0)) / (t - y)
    else if (t_1 <= 2.305918027910845d+262) then
        tmp = 2.0d0 * (x / (z * (y - t)))
    else
        tmp = (x * (2.0d0 / (y - t))) / z
    end if
    code = tmp
end function
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 <= -6.014905296048345e+224) {
		tmp = ((x / z) * -2.0) / (t - y);
	} else if (t_1 <= 2.305918027910845e+262) {
		tmp = 2.0 * (x / (z * (y - t)));
	} else {
		tmp = (x * (2.0 / (y - t))) / z;
	}
	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 <= -6.014905296048345e+224:
		tmp = ((x / z) * -2.0) / (t - y)
	elif t_1 <= 2.305918027910845e+262:
		tmp = 2.0 * (x / (z * (y - t)))
	else:
		tmp = (x * (2.0 / (y - t))) / z
	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 <= -6.014905296048345e+224)
		tmp = Float64(Float64(Float64(x / z) * -2.0) / Float64(t - y));
	elseif (t_1 <= 2.305918027910845e+262)
		tmp = Float64(2.0 * Float64(x / Float64(z * Float64(y - t))));
	else
		tmp = Float64(Float64(x * Float64(2.0 / Float64(y - t))) / z);
	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 <= -6.014905296048345e+224)
		tmp = ((x / z) * -2.0) / (t - y);
	elseif (t_1 <= 2.305918027910845e+262)
		tmp = 2.0 * (x / (z * (y - t)));
	else
		tmp = (x * (2.0 / (y - t))) / z;
	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, -6.014905296048345e+224], N[(N[(N[(x / z), $MachinePrecision] * -2.0), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.305918027910845e+262], N[(2.0 * N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $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 -6.014905296048345 \cdot 10^{+224}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot -2}{t - y}\\

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

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


\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.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.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)) < -6.01490529604834e224

    1. Initial program 13.7

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

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

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

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

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

    if -6.01490529604834e224 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2.3059180279108451e262

    1. Initial program 1.6

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

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

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

    if 2.3059180279108451e262 < (-.f64 (*.f64 y z) (*.f64 t z))

    1. Initial program 24.3

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

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

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

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

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

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

Reproduce

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