Average Error: 6.2 → 1.2
Time: 12.7s
Precision: binary64
Cost: 1736
\[\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{\frac{x}{y - t}}{z \cdot 0.5}\\ \mathbf{elif}\;t_1 \leq 10^{+194}:\\ \;\;\;\;\frac{x \cdot 2}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{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)) (* z 0.5))
     (if (<= t_1 1e+194) (/ (* x 2.0) t_1) (/ (/ 2.0 z) (/ (- y t) 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)) / (z * 0.5);
	} else if (t_1 <= 1e+194) {
		tmp = (x * 2.0) / t_1;
	} else {
		tmp = (2.0 / z) / ((y - t) / 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)) / (z * 0.5);
	} else if (t_1 <= 1e+194) {
		tmp = (x * 2.0) / t_1;
	} else {
		tmp = (2.0 / z) / ((y - t) / 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)) / (z * 0.5)
	elif t_1 <= 1e+194:
		tmp = (x * 2.0) / t_1
	else:
		tmp = (2.0 / z) / ((y - t) / 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(z * 0.5));
	elseif (t_1 <= 1e+194)
		tmp = Float64(Float64(x * 2.0) / t_1);
	else
		tmp = Float64(Float64(2.0 / z) / Float64(Float64(y - t) / 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)) / (z * 0.5);
	elseif (t_1 <= 1e+194)
		tmp = (x * 2.0) / t_1;
	else
		tmp = (2.0 / z) / ((y - t) / 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[(z * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+194], N[(N[(x * 2.0), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] / 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{\frac{x}{y - t}}{z \cdot 0.5}\\

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target2.0
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)) < -inf.0

    1. Initial program 19.4

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

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

      [Start]19.4

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

      *-commutative [=>]19.4

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

      distribute-rgt-out-- [=>]19.4

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

      times-frac [=>]0.1

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

      associate-*r/ [=>]0.1

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

      associate-/l* [=>]0.1

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

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

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

      [Start]1.0

      \[ {\left(\frac{y - t}{x} \cdot \left(z \cdot 0.5\right)\right)}^{-1} \]

      unpow-1 [=>]1.0

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

      associate-/r* [=>]0.1

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

      *-lft-identity [<=]0.1

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

      associate-*r/ [=>]0.1

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

      associate-*l/ [<=]0.1

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

      associate-/r* [=>]0.1

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

      associate-/r/ [=>]0.1

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

      metadata-eval [=>]0.1

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

      associate-*r/ [<=]0.1

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

      *-lft-identity [=>]0.1

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

    if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < 9.99999999999999945e193

    1. Initial program 1.5

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

    if 9.99999999999999945e193 < (-.f64 (*.f64 y z) (*.f64 t z))

    1. Initial program 15.6

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

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

      [Start]15.6

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

      *-commutative [=>]15.6

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

      distribute-rgt-out-- [=>]10.7

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

      times-frac [=>]0.7

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

      associate-*r/ [=>]0.5

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

      associate-/l* [=>]0.7

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

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

Alternatives

Alternative 1
Error17.9
Cost978
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+17} \lor \neg \left(y \leq 2.4 \cdot 10^{-59} \lor \neg \left(y \leq 4.4 \cdot 10^{-11}\right) \land y \leq 6.8 \cdot 10^{+82}\right):\\ \;\;\;\;2 \cdot \frac{x}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \end{array} \]
Alternative 2
Error18.0
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+18}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y}\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-66} \lor \neg \left(y \leq 1.05 \cdot 10^{-9}\right) \land y \leq 1.95 \cdot 10^{+84}:\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{x}{y \cdot z}\\ \end{array} \]
Alternative 3
Error18.0
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{+18}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-59} \lor \neg \left(y \leq 2 \cdot 10^{-11}\right) \land y \leq 6.8 \cdot 10^{+82}:\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{x}{y \cdot z}\\ \end{array} \]
Alternative 4
Error18.1
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+17}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-59}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-2}{z}\\ \mathbf{elif}\;y \leq 10^{-11} \lor \neg \left(y \leq 6.8 \cdot 10^{+82}\right):\\ \;\;\;\;2 \cdot \frac{x}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \end{array} \]
Alternative 5
Error18.1
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{+17}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-59}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-2}{z}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-12} \lor \neg \left(y \leq 8.8 \cdot 10^{+86}\right):\\ \;\;\;\;2 \cdot \frac{x}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\ \end{array} \]
Alternative 6
Error18.6
Cost977
\[\begin{array}{l} t_1 := \frac{2}{y \cdot \frac{z}{x}}\\ \mathbf{if}\;y \leq -1.65 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-59}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-2}{z}\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-11} \lor \neg \left(y \leq 8.8 \cdot 10^{+86}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\ \end{array} \]
Alternative 7
Error18.6
Cost977
\[\begin{array}{l} t_1 := \frac{2}{y \cdot \frac{z}{x}}\\ \mathbf{if}\;y \leq -1.55 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-59}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-2}{z}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-10} \lor \neg \left(y \leq 4.5 \cdot 10^{+86}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t \cdot \left(z \cdot -0.5\right)}\\ \end{array} \]
Alternative 8
Error18.6
Cost976
\[\begin{array}{l} t_1 := \frac{2}{y \cdot \frac{z}{x}}\\ \mathbf{if}\;y \leq -1.6 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-59}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-2}{z}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-11}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y}\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+86}:\\ \;\;\;\;\frac{x}{t \cdot \left(z \cdot -0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error18.6
Cost976
\[\begin{array}{l} t_1 := \frac{2}{y \cdot \frac{z}{x}}\\ \mathbf{if}\;y \leq -2.9 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-59}:\\ \;\;\;\;\frac{\frac{\frac{x}{t}}{z}}{-0.5}\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+87}:\\ \;\;\;\;\frac{x}{t \cdot \left(z \cdot -0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error5.3
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq 2.6 \cdot 10^{-259} \lor \neg \left(t \leq 3.35 \cdot 10^{-189}\right):\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y}{x}}\\ \end{array} \]
Alternative 11
Error2.9
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -8.4 \cdot 10^{-75} \lor \neg \left(z \leq 2.8 \cdot 10^{+177}\right):\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \end{array} \]
Alternative 12
Error2.9
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{-75}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+175}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\ \end{array} \]
Alternative 13
Error3.6
Cost708
\[\begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+17}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \end{array} \]
Alternative 14
Error31.8
Cost448
\[2 \cdot \frac{x}{y \cdot z} \]

Error

Reproduce

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