Average Error: 7.2 → 0.3
Time: 7.6s
Precision: binary64
Cost: 9104
\[ \begin{array}{c}[y, t] = \mathsf{sort}([y, t])\\ \end{array} \]
\[\left(x \cdot y - z \cdot y\right) \cdot t \]
\[\begin{array}{l} t_1 := x \cdot y - y \cdot z\\ t_2 := \left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{elif}\;t_1 \leq -4 \cdot 10^{-283}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+294}:\\ \;\;\;\;t_1 \cdot t\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{t_2}\right)}^{-1}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x y) (* y z))) (t_2 (* (- x z) (* y t))))
   (if (<= t_1 (- INFINITY))
     (* y (* t (- x z)))
     (if (<= t_1 -4e-283)
       (* t (* y (- x z)))
       (if (<= t_1 0.0)
         t_2
         (if (<= t_1 2e+294) (* t_1 t) (pow (/ 1.0 t_2) -1.0)))))))
double code(double x, double y, double z, double t) {
	return ((x * y) - (z * y)) * t;
}
double code(double x, double y, double z, double t) {
	double t_1 = (x * y) - (y * z);
	double t_2 = (x - z) * (y * t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = y * (t * (x - z));
	} else if (t_1 <= -4e-283) {
		tmp = t * (y * (x - z));
	} else if (t_1 <= 0.0) {
		tmp = t_2;
	} else if (t_1 <= 2e+294) {
		tmp = t_1 * t;
	} else {
		tmp = pow((1.0 / t_2), -1.0);
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return ((x * y) - (z * y)) * t;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * y) - (y * z);
	double t_2 = (x - z) * (y * t);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = y * (t * (x - z));
	} else if (t_1 <= -4e-283) {
		tmp = t * (y * (x - z));
	} else if (t_1 <= 0.0) {
		tmp = t_2;
	} else if (t_1 <= 2e+294) {
		tmp = t_1 * t;
	} else {
		tmp = Math.pow((1.0 / t_2), -1.0);
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x * y) - (z * y)) * t
def code(x, y, z, t):
	t_1 = (x * y) - (y * z)
	t_2 = (x - z) * (y * t)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = y * (t * (x - z))
	elif t_1 <= -4e-283:
		tmp = t * (y * (x - z))
	elif t_1 <= 0.0:
		tmp = t_2
	elif t_1 <= 2e+294:
		tmp = t_1 * t
	else:
		tmp = math.pow((1.0 / t_2), -1.0)
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x * y) - Float64(z * y)) * t)
end
function code(x, y, z, t)
	t_1 = Float64(Float64(x * y) - Float64(y * z))
	t_2 = Float64(Float64(x - z) * Float64(y * t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(y * Float64(t * Float64(x - z)));
	elseif (t_1 <= -4e-283)
		tmp = Float64(t * Float64(y * Float64(x - z)));
	elseif (t_1 <= 0.0)
		tmp = t_2;
	elseif (t_1 <= 2e+294)
		tmp = Float64(t_1 * t);
	else
		tmp = Float64(1.0 / t_2) ^ -1.0;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x * y) - (z * y)) * t;
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * y) - (y * z);
	t_2 = (x - z) * (y * t);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = y * (t * (x - z));
	elseif (t_1 <= -4e-283)
		tmp = t * (y * (x - z));
	elseif (t_1 <= 0.0)
		tmp = t_2;
	elseif (t_1 <= 2e+294)
		tmp = t_1 * t;
	else
		tmp = (1.0 / t_2) ^ -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -4e-283], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 2e+294], N[(t$95$1 * t), $MachinePrecision], N[Power[N[(1.0 / t$95$2), $MachinePrecision], -1.0], $MachinePrecision]]]]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := x \cdot y - y \cdot z\\
t_2 := \left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\

\mathbf{elif}\;t_1 \leq -4 \cdot 10^{-283}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+294}:\\
\;\;\;\;t_1 \cdot t\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{1}{t_2}\right)}^{-1}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.2
Target3.6
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t < 2.543067051564877 \cdot 10^{+83}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\ \end{array} \]

Derivation

  1. Split input into 5 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -inf.0

    1. Initial program 64.0

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Simplified0.2

      \[\leadsto \color{blue}{y \cdot \left(t \cdot \left(x - z\right)\right)} \]
      Proof
      (*.f64 y (*.f64 t (-.f64 x z))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 x z) t))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y (-.f64 x z)) t)): 73 points increase in error, 54 points decrease in error
      (*.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 x y) (*.f64 z y))) t): 2 points increase in error, 2 points decrease in error

    if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z y)) < -3.99999999999999979e-283

    1. Initial program 0.3

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Simplified0.2

      \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right) \cdot t} \]
      Proof
      (*.f64 (*.f64 y (-.f64 x z)) t): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 x y) (*.f64 z y))) t): 2 points increase in error, 2 points decrease in error

    if -3.99999999999999979e-283 < (-.f64 (*.f64 x y) (*.f64 z y)) < -0.0

    1. Initial program 19.1

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Simplified19.1

      \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right) \cdot t} \]
      Proof
      (*.f64 (*.f64 y (-.f64 x z)) t): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 x y) (*.f64 z y))) t): 2 points increase in error, 2 points decrease in error
    3. Applied egg-rr19.9

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

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

    if -0.0 < (-.f64 (*.f64 x y) (*.f64 z y)) < 2.00000000000000013e294

    1. Initial program 0.4

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]

    if 2.00000000000000013e294 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 57.4

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Simplified57.4

      \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right) \cdot t} \]
      Proof
      (*.f64 (*.f64 y (-.f64 x z)) t): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 x y) (*.f64 z y))) t): 2 points increase in error, 2 points decrease in error
    3. Applied egg-rr54.4

      \[\leadsto \color{blue}{\sqrt[3]{{\left(y \cdot \left(\left(x - z\right) \cdot t\right)\right)}^{3}}} \]
    4. Applied egg-rr0.3

      \[\leadsto \color{blue}{\left(x - z\right) \cdot \left(t \cdot y\right)} \]
    5. Applied egg-rr53.9

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

      \[\leadsto \color{blue}{{\left(\frac{1}{\left(x - z\right) \cdot \left(t \cdot y\right)}\right)}^{-1}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification0.3

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

Alternatives

Alternative 1
Error0.9
Cost2640
\[\begin{array}{l} t_1 := x \cdot y - y \cdot z\\ t_2 := \left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{elif}\;t_1 \leq -4 \cdot 10^{-283}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+103}:\\ \;\;\;\;t_1 \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error21.0
Cost1044
\[\begin{array}{l} t_1 := y \cdot \left(x \cdot t\right)\\ t_2 := \left(y \cdot z\right) \cdot \left(-t\right)\\ \mathbf{if}\;x \leq -9 \cdot 10^{+32}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \leq -48000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.7 \cdot 10^{-272}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{+75}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error9.1
Cost844
\[\begin{array}{l} t_1 := y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+162}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.7 \cdot 10^{-232}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error20.5
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-55}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{+75}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]
Alternative 5
Error20.6
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-59}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \leq 3.55 \cdot 10^{+75}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]
Alternative 6
Error2.6
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 3 \cdot 10^{-15}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array} \]
Alternative 7
Error2.3
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 5 \cdot 10^{-14}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 8
Error28.8
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 10^{+15}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 9
Error31.2
Cost320
\[x \cdot \left(y \cdot t\right) \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x y z t)
  :name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))

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