?

Average Error: 6.8 → 0.4
Time: 21.8s
Precision: binary64
Cost: 2768

?

\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\begin{array}{l} t_1 := y \cdot z - t \cdot z\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+178}:\\ \;\;\;\;\frac{\frac{2}{\frac{z}{x}}}{y - t}\\ \mathbf{elif}\;t_1 \leq -5 \cdot 10^{-219}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-263}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+253}:\\ \;\;\;\;\frac{x \cdot 2}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \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) (* t z))))
   (if (<= t_1 -1e+178)
     (/ (/ 2.0 (/ z x)) (- y t))
     (if (<= t_1 -5e-219)
       (/ (* x 2.0) (* z (- y t)))
       (if (<= t_1 2e-263)
         (/ (/ 2.0 z) (/ (- y t) x))
         (if (<= t_1 5e+253)
           (/ (* x 2.0) t_1)
           (/ (* 2.0 (/ x z)) (- y t))))))))
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) - (t * z);
	double tmp;
	if (t_1 <= -1e+178) {
		tmp = (2.0 / (z / x)) / (y - t);
	} else if (t_1 <= -5e-219) {
		tmp = (x * 2.0) / (z * (y - t));
	} else if (t_1 <= 2e-263) {
		tmp = (2.0 / z) / ((y - t) / x);
	} else if (t_1 <= 5e+253) {
		tmp = (x * 2.0) / t_1;
	} else {
		tmp = (2.0 * (x / z)) / (y - t);
	}
	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) - (t * z)
    if (t_1 <= (-1d+178)) then
        tmp = (2.0d0 / (z / x)) / (y - t)
    else if (t_1 <= (-5d-219)) then
        tmp = (x * 2.0d0) / (z * (y - t))
    else if (t_1 <= 2d-263) then
        tmp = (2.0d0 / z) / ((y - t) / x)
    else if (t_1 <= 5d+253) then
        tmp = (x * 2.0d0) / t_1
    else
        tmp = (2.0d0 * (x / z)) / (y - t)
    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) - (t * z);
	double tmp;
	if (t_1 <= -1e+178) {
		tmp = (2.0 / (z / x)) / (y - t);
	} else if (t_1 <= -5e-219) {
		tmp = (x * 2.0) / (z * (y - t));
	} else if (t_1 <= 2e-263) {
		tmp = (2.0 / z) / ((y - t) / x);
	} else if (t_1 <= 5e+253) {
		tmp = (x * 2.0) / t_1;
	} else {
		tmp = (2.0 * (x / z)) / (y - t);
	}
	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) - (t * z)
	tmp = 0
	if t_1 <= -1e+178:
		tmp = (2.0 / (z / x)) / (y - t)
	elif t_1 <= -5e-219:
		tmp = (x * 2.0) / (z * (y - t))
	elif t_1 <= 2e-263:
		tmp = (2.0 / z) / ((y - t) / x)
	elif t_1 <= 5e+253:
		tmp = (x * 2.0) / t_1
	else:
		tmp = (2.0 * (x / z)) / (y - t)
	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(t * z))
	tmp = 0.0
	if (t_1 <= -1e+178)
		tmp = Float64(Float64(2.0 / Float64(z / x)) / Float64(y - t));
	elseif (t_1 <= -5e-219)
		tmp = Float64(Float64(x * 2.0) / Float64(z * Float64(y - t)));
	elseif (t_1 <= 2e-263)
		tmp = Float64(Float64(2.0 / z) / Float64(Float64(y - t) / x));
	elseif (t_1 <= 5e+253)
		tmp = Float64(Float64(x * 2.0) / t_1);
	else
		tmp = Float64(Float64(2.0 * Float64(x / z)) / Float64(y - t));
	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) - (t * z);
	tmp = 0.0;
	if (t_1 <= -1e+178)
		tmp = (2.0 / (z / x)) / (y - t);
	elseif (t_1 <= -5e-219)
		tmp = (x * 2.0) / (z * (y - t));
	elseif (t_1 <= 2e-263)
		tmp = (2.0 / z) / ((y - t) / x);
	elseif (t_1 <= 5e+253)
		tmp = (x * 2.0) / t_1;
	else
		tmp = (2.0 * (x / z)) / (y - t);
	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[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+178], N[(N[(2.0 / N[(z / x), $MachinePrecision]), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -5e-219], N[(N[(x * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-263], N[(N[(2.0 / z), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+253], N[(N[(x * 2.0), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(2.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := y \cdot z - t \cdot z\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+178}:\\
\;\;\;\;\frac{\frac{2}{\frac{z}{x}}}{y - t}\\

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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-263}:\\
\;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+253}:\\
\;\;\;\;\frac{x \cdot 2}{t_1}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.8
Target2.1
Herbie0.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 5 regimes
  2. if (-.f64 (*.f64 y z) (*.f64 t z)) < -1.0000000000000001e178

    1. Initial program 11.0

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

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

      [Start]11.0

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

      rational.json-simplify-2 [=>]11.0

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

      rational.json-simplify-52 [=>]11.0

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

      rational.json-simplify-46 [=>]0.8

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

      rational.json-simplify-49 [=>]0.8

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

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

    if -1.0000000000000001e178 < (-.f64 (*.f64 y z) (*.f64 t z)) < -5.0000000000000002e-219

    1. Initial program 0.3

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

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

      [Start]0.3

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

      rational.json-simplify-2 [=>]0.3

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

      rational.json-simplify-52 [=>]0.3

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

    if -5.0000000000000002e-219 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2e-263

    1. Initial program 25.0

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

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

      [Start]25.0

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

      rational.json-simplify-2 [=>]25.0

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

      rational.json-simplify-49 [=>]28.6

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

      rational.json-simplify-2 [=>]28.6

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

      rational.json-simplify-52 [=>]28.6

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

      rational.json-simplify-46 [=>]28.8

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

      rational.json-simplify-44 [=>]28.6

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

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

    if 2e-263 < (-.f64 (*.f64 y z) (*.f64 t z)) < 4.9999999999999997e253

    1. Initial program 0.3

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

    if 4.9999999999999997e253 < (-.f64 (*.f64 y z) (*.f64 t z))

    1. Initial program 21.6

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

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

      [Start]21.6

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

      rational.json-simplify-2 [=>]21.6

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

      rational.json-simplify-52 [=>]14.9

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

      rational.json-simplify-46 [=>]0.2

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

      rational.json-simplify-49 [=>]0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \leq -1 \cdot 10^{+178}:\\ \;\;\;\;\frac{\frac{2}{\frac{z}{x}}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \leq -5 \cdot 10^{-219}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \cdot z - t \cdot z \leq 2 \cdot 10^{-263}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{elif}\;y \cdot z - t \cdot z \leq 5 \cdot 10^{+253}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \end{array} \]

Alternatives

Alternative 1
Error6.2
Cost840
\[\begin{array}{l} t_1 := x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{if}\;t \leq -1 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.6 \cdot 10^{-205}:\\ \;\;\;\;\frac{\frac{\frac{x}{z}}{0.5}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error2.4
Cost840
\[\begin{array}{l} t_1 := \frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{if}\;z \leq -54:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{+80}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error2.4
Cost840
\[\begin{array}{l} t_1 := \frac{2 \cdot \frac{x}{z}}{y - t}\\ \mathbf{if}\;z \leq -400:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+80}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error2.5
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+16}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+80}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \end{array} \]
Alternative 5
Error2.5
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -400:\\ \;\;\;\;\frac{\frac{x}{\left(y - t\right) \cdot 0.5}}{z}\\ \mathbf{elif}\;z \leq 2.45 \cdot 10^{+79}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \end{array} \]
Alternative 6
Error28.5
Cost712
\[\begin{array}{l} t_1 := -2 \cdot \frac{\frac{x}{z}}{t}\\ \mathbf{if}\;z \leq -2 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-17}:\\ \;\;\;\;-2 \cdot \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error18.3
Cost712
\[\begin{array}{l} t_1 := -2 \cdot \frac{\frac{x}{z}}{t}\\ \mathbf{if}\;t \leq -5.8 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+70}:\\ \;\;\;\;x \cdot \frac{2}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error18.1
Cost712
\[\begin{array}{l} t_1 := -2 \cdot \frac{\frac{x}{z}}{t}\\ \mathbf{if}\;t \leq -3.75 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{+70}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error17.8
Cost712
\[\begin{array}{l} t_1 := -2 \cdot \frac{\frac{x}{z}}{t}\\ \mathbf{if}\;t \leq -5.7 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.04 \cdot 10^{+71}:\\ \;\;\;\;\frac{2}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error17.7
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -4.5 \cdot 10^{-44}:\\ \;\;\;\;\frac{\frac{x}{t}}{\frac{z}{-2}}\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+70}:\\ \;\;\;\;\frac{2}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{\frac{x}{z}}{t}\\ \end{array} \]
Alternative 11
Error17.7
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -5.8 \cdot 10^{-44}:\\ \;\;\;\;\frac{\frac{x}{t}}{\frac{z}{-2}}\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{+71}:\\ \;\;\;\;\frac{\frac{\frac{x}{z}}{0.5}}{y}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{\frac{x}{z}}{t}\\ \end{array} \]
Alternative 12
Error31.6
Cost448
\[-2 \cdot \frac{x}{z \cdot t} \]

Error

Reproduce?

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