Average Error: 6.9 → 0.5
Time: 6.8s
Precision: binary64
Cost: 2512
\[ \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 := t \cdot \left(y \cdot \left(x - z\right)\right)\\ t_2 := x \cdot y - y \cdot z\\ t_3 := \left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq -1 \cdot 10^{-199}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+195}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* t (* y (- x z))))
        (t_2 (- (* x y) (* y z)))
        (t_3 (* (- x z) (* y t))))
   (if (<= t_2 (- INFINITY))
     t_3
     (if (<= t_2 -1e-199)
       t_1
       (if (<= t_2 0.0) t_3 (if (<= t_2 2e+195) t_1 t_3))))))
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 = t * (y * (x - z));
	double t_2 = (x * y) - (y * z);
	double t_3 = (x - z) * (y * t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_3;
	} else if (t_2 <= -1e-199) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 2e+195) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	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 = t * (y * (x - z));
	double t_2 = (x * y) - (y * z);
	double t_3 = (x - z) * (y * t);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_3;
	} else if (t_2 <= -1e-199) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 2e+195) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x * y) - (z * y)) * t
def code(x, y, z, t):
	t_1 = t * (y * (x - z))
	t_2 = (x * y) - (y * z)
	t_3 = (x - z) * (y * t)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_3
	elif t_2 <= -1e-199:
		tmp = t_1
	elif t_2 <= 0.0:
		tmp = t_3
	elif t_2 <= 2e+195:
		tmp = t_1
	else:
		tmp = t_3
	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(t * Float64(y * Float64(x - z)))
	t_2 = Float64(Float64(x * y) - Float64(y * z))
	t_3 = Float64(Float64(x - z) * Float64(y * t))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_3;
	elseif (t_2 <= -1e-199)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 2e+195)
		tmp = t_1;
	else
		tmp = t_3;
	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 = t * (y * (x - z));
	t_2 = (x * y) - (y * z);
	t_3 = (x - z) * (y * t);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_3;
	elseif (t_2 <= -1e-199)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 2e+195)
		tmp = t_1;
	else
		tmp = t_3;
	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[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$3, If[LessEqual[t$95$2, -1e-199], t$95$1, If[LessEqual[t$95$2, 0.0], t$95$3, If[LessEqual[t$95$2, 2e+195], t$95$1, t$95$3]]]]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := t \cdot \left(y \cdot \left(x - z\right)\right)\\
t_2 := x \cdot y - y \cdot z\\
t_3 := \left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq -1 \cdot 10^{-199}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+195}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.9
Target3.2
Herbie0.5
\[\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 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -inf.0 or -9.99999999999999982e-200 < (-.f64 (*.f64 x y) (*.f64 z y)) < 0.0 or 1.99999999999999995e195 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 28.1

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

      \[\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)): 55 points increase in error, 67 points decrease in error
      (*.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 x y) (*.f64 z y))) t): 4 points increase in error, 1 points decrease in error
    3. Applied egg-rr0.7

      \[\leadsto y \cdot \color{blue}{\left(x \cdot t + \left(-z\right) \cdot t\right)} \]
    4. Taylor expanded in y around 0 0.7

      \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \left(t \cdot z\right) + t \cdot x\right)} \]
    5. Simplified0.9

      \[\leadsto \color{blue}{\left(x - z\right) \cdot \left(y \cdot t\right)} \]
      Proof
      (*.f64 (-.f64 x z) (*.f64 y t)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= unsub-neg_binary64 (+.f64 x (neg.f64 z))) (*.f64 y t)): 0 points increase in error, 0 points decrease in error
      (*.f64 (+.f64 x (Rewrite<= mul-1-neg_binary64 (*.f64 -1 z))) (*.f64 y t)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 -1 z) x)) (*.f64 y t)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 y t) (+.f64 (*.f64 -1 z) x))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> distribute-lft-in_binary64 (+.f64 (*.f64 (*.f64 y t) (*.f64 -1 z)) (*.f64 (*.f64 y t) x))): 1 points increase in error, 2 points decrease in error
      (+.f64 (*.f64 (*.f64 y t) (*.f64 -1 z)) (Rewrite<= associate-*r*_binary64 (*.f64 y (*.f64 t x)))): 34 points increase in error, 26 points decrease in error
      (+.f64 (Rewrite=> associate-*l*_binary64 (*.f64 y (*.f64 t (*.f64 -1 z)))) (*.f64 y (*.f64 t x))): 32 points increase in error, 34 points decrease in error
      (+.f64 (*.f64 y (*.f64 t (Rewrite=> mul-1-neg_binary64 (neg.f64 z)))) (*.f64 y (*.f64 t x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 y (Rewrite=> distribute-rgt-neg-out_binary64 (neg.f64 (*.f64 t z)))) (*.f64 y (*.f64 t x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 y (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 t z)))) (*.f64 y (*.f64 t x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-lft-in_binary64 (*.f64 y (+.f64 (*.f64 -1 (*.f64 t z)) (*.f64 t x)))): 1 points increase in error, 3 points decrease in error

    if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z y)) < -9.99999999999999982e-200 or 0.0 < (-.f64 (*.f64 x y) (*.f64 z y)) < 1.99999999999999995e195

    1. Initial program 0.3

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Applied egg-rr0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - y \cdot z \leq -\infty:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq -1 \cdot 10^{-199}:\\ \;\;\;\;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^{+195}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \end{array} \]

Alternatives

Alternative 1
Error7.4
Cost712
\[\begin{array}{l} t_1 := \left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{if}\;x \leq -7.482053469765425 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.6734632054226543 \cdot 10^{-176}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error18.9
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7571248393358354 \cdot 10^{-20}:\\ \;\;\;\;\left(x \cdot y\right) \cdot t\\ \mathbf{elif}\;x \leq 6.428093599201794 \cdot 10^{-7}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 3
Error28.9
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 1:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 4
Error29.1
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq -8.4 \cdot 10^{+64}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot t\\ \end{array} \]
Alternative 5
Error31.4
Cost320
\[y \cdot \left(x \cdot t\right) \]

Error

Reproduce

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