Average Error: 7.1 → 1.4
Time: 9.0s
Precision: binary64
Cost: 1736
\[ \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\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+222}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+250}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right) - y \cdot \left(z \cdot t\right)\\ \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))))
   (if (<= t_1 -1e+222)
     (* (* y t) (- x z))
     (if (<= t_1 5e+250)
       (* t (* y (- x z)))
       (- (* y (* x t)) (* y (* z t)))))))
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 tmp;
	if (t_1 <= -1e+222) {
		tmp = (y * t) * (x - z);
	} else if (t_1 <= 5e+250) {
		tmp = t * (y * (x - z));
	} else {
		tmp = (y * (x * t)) - (y * (z * 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 * y) - (z * y)) * t
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 = (x * y) - (y * z)
    if (t_1 <= (-1d+222)) then
        tmp = (y * t) * (x - z)
    else if (t_1 <= 5d+250) then
        tmp = t * (y * (x - z))
    else
        tmp = (y * (x * t)) - (y * (z * t))
    end if
    code = tmp
end function
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 tmp;
	if (t_1 <= -1e+222) {
		tmp = (y * t) * (x - z);
	} else if (t_1 <= 5e+250) {
		tmp = t * (y * (x - z));
	} else {
		tmp = (y * (x * t)) - (y * (z * t));
	}
	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)
	tmp = 0
	if t_1 <= -1e+222:
		tmp = (y * t) * (x - z)
	elif t_1 <= 5e+250:
		tmp = t * (y * (x - z))
	else:
		tmp = (y * (x * t)) - (y * (z * t))
	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))
	tmp = 0.0
	if (t_1 <= -1e+222)
		tmp = Float64(Float64(y * t) * Float64(x - z));
	elseif (t_1 <= 5e+250)
		tmp = Float64(t * Float64(y * Float64(x - z)));
	else
		tmp = Float64(Float64(y * Float64(x * t)) - Float64(y * Float64(z * t)));
	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);
	tmp = 0.0;
	if (t_1 <= -1e+222)
		tmp = (y * t) * (x - z);
	elseif (t_1 <= 5e+250)
		tmp = t * (y * (x - z));
	else
		tmp = (y * (x * t)) - (y * (z * t));
	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]}, If[LessEqual[t$95$1, -1e+222], N[(N[(y * t), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+250], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x * t), $MachinePrecision]), $MachinePrecision] - N[(y * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := x \cdot y - y \cdot z\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+222}:\\
\;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\

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

\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot t\right) - y \cdot \left(z \cdot t\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.1
Target3.4
Herbie1.4
\[\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 3 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -1e222

    1. Initial program 31.4

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

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

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

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

    if -1e222 < (-.f64 (*.f64 x y) (*.f64 z y)) < 5.0000000000000002e250

    1. Initial program 1.6

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

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

    if 5.0000000000000002e250 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 41.1

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Taylor expanded in x around 0 0.3

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

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

Alternatives

Alternative 1
Error1.8
Cost1480
\[\begin{array}{l} t_1 := x \cdot y - y \cdot z\\ t_2 := \left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+222}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+113}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error19.6
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -5.991909697799511 \cdot 10^{-35}:\\ \;\;\;\;\left(x \cdot y\right) \cdot t\\ \mathbf{elif}\;x \leq 1.5864192497251077 \cdot 10^{-74}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]
Alternative 3
Error20.0
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -5.430162021668888 \cdot 10^{-27}:\\ \;\;\;\;\left(x \cdot y\right) \cdot t\\ \mathbf{elif}\;x \leq 1.2028430043846136 \cdot 10^{-92}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]
Alternative 4
Error29.3
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 1.9042037961029946 \cdot 10^{-188}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot t\\ \end{array} \]
Alternative 5
Error28.9
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 3 \cdot 10^{-22}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 6
Error6.4
Cost448
\[\left(y \cdot t\right) \cdot \left(x - z\right) \]
Alternative 7
Error31.2
Cost320
\[\left(x \cdot y\right) \cdot t \]

Error

Reproduce

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