?

Average Error: 7.1 → 0.6
Time: 12.2s
Precision: binary64
Cost: 2513

?

\[\left(x \cdot y - z \cdot y\right) \cdot t \]
\[\begin{array}{l} t_1 := x \cdot y - y \cdot z\\ t_2 := y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+291}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq -4 \cdot 10^{-228}:\\ \;\;\;\;t_1 \cdot t\\ \mathbf{elif}\;t_1 \leq 3 \cdot 10^{-160} \lor \neg \left(t_1 \leq 2 \cdot 10^{+187}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\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))) (t_2 (* y (* t (- x z)))))
   (if (<= t_1 -5e+291)
     t_2
     (if (<= t_1 -4e-228)
       (* t_1 t)
       (if (or (<= t_1 3e-160) (not (<= t_1 2e+187)))
         t_2
         (* t (* y (- x z))))))))
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 = y * (t * (x - z));
	double tmp;
	if (t_1 <= -5e+291) {
		tmp = t_2;
	} else if (t_1 <= -4e-228) {
		tmp = t_1 * t;
	} else if ((t_1 <= 3e-160) || !(t_1 <= 2e+187)) {
		tmp = t_2;
	} else {
		tmp = t * (y * (x - z));
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = (x * y) - (y * z)
    t_2 = y * (t * (x - z))
    if (t_1 <= (-5d+291)) then
        tmp = t_2
    else if (t_1 <= (-4d-228)) then
        tmp = t_1 * t
    else if ((t_1 <= 3d-160) .or. (.not. (t_1 <= 2d+187))) then
        tmp = t_2
    else
        tmp = t * (y * (x - z))
    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 t_2 = y * (t * (x - z));
	double tmp;
	if (t_1 <= -5e+291) {
		tmp = t_2;
	} else if (t_1 <= -4e-228) {
		tmp = t_1 * t;
	} else if ((t_1 <= 3e-160) || !(t_1 <= 2e+187)) {
		tmp = t_2;
	} else {
		tmp = t * (y * (x - z));
	}
	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 = y * (t * (x - z))
	tmp = 0
	if t_1 <= -5e+291:
		tmp = t_2
	elif t_1 <= -4e-228:
		tmp = t_1 * t
	elif (t_1 <= 3e-160) or not (t_1 <= 2e+187):
		tmp = t_2
	else:
		tmp = t * (y * (x - z))
	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(y * Float64(t * Float64(x - z)))
	tmp = 0.0
	if (t_1 <= -5e+291)
		tmp = t_2;
	elseif (t_1 <= -4e-228)
		tmp = Float64(t_1 * t);
	elseif ((t_1 <= 3e-160) || !(t_1 <= 2e+187))
		tmp = t_2;
	else
		tmp = Float64(t * Float64(y * Float64(x - z)));
	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 = y * (t * (x - z));
	tmp = 0.0;
	if (t_1 <= -5e+291)
		tmp = t_2;
	elseif (t_1 <= -4e-228)
		tmp = t_1 * t;
	elseif ((t_1 <= 3e-160) || ~((t_1 <= 2e+187)))
		tmp = t_2;
	else
		tmp = t * (y * (x - z));
	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[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+291], t$95$2, If[LessEqual[t$95$1, -4e-228], N[(t$95$1 * t), $MachinePrecision], If[Or[LessEqual[t$95$1, 3e-160], N[Not[LessEqual[t$95$1, 2e+187]], $MachinePrecision]], t$95$2, N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := x \cdot y - y \cdot z\\
t_2 := y \cdot \left(t \cdot \left(x - z\right)\right)\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+291}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq -4 \cdot 10^{-228}:\\
\;\;\;\;t_1 \cdot t\\

\mathbf{elif}\;t_1 \leq 3 \cdot 10^{-160} \lor \neg \left(t_1 \leq 2 \cdot 10^{+187}\right):\\
\;\;\;\;t_2\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.1
Target3.1
Herbie0.6
\[\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)) < -5.0000000000000001e291 or -4.00000000000000013e-228 < (-.f64 (*.f64 x y) (*.f64 z y)) < 2.99999999999999997e-160 or 1.99999999999999981e187 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 22.1

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

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

      [Start]22.1

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

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

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

      associate-*l* [=>]1.4

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

      *-commutative [=>]1.4

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

    if -5.0000000000000001e291 < (-.f64 (*.f64 x y) (*.f64 z y)) < -4.00000000000000013e-228

    1. Initial program 0.3

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

    if 2.99999999999999997e-160 < (-.f64 (*.f64 x y) (*.f64 z y)) < 1.99999999999999981e187

    1. Initial program 0.3

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

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

      [Start]0.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - y \cdot z \leq -5 \cdot 10^{+291}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq -4 \cdot 10^{-228}:\\ \;\;\;\;\left(x \cdot y - y \cdot z\right) \cdot t\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq 3 \cdot 10^{-160} \lor \neg \left(x \cdot y - y \cdot z \leq 2 \cdot 10^{+187}\right):\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error20.0
Cost1176
\[\begin{array}{l} t_1 := y \cdot \left(x \cdot t\right)\\ t_2 := \left(y \cdot z\right) \cdot \left(-t\right)\\ t_3 := y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{-29}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-98}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-159}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-222}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error20.0
Cost913
\[\begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{-26}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-100}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{elif}\;x \leq -1.65 \cdot 10^{-108} \lor \neg \left(x \leq 1.2 \cdot 10^{+54}\right):\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y \cdot t\right)\\ \end{array} \]
Alternative 3
Error20.3
Cost912
\[\begin{array}{l} t_1 := t \cdot \left(x \cdot y\right)\\ t_2 := y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{if}\;x \leq -5 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-108}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+54}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]
Alternative 4
Error7.3
Cost845
\[\begin{array}{l} \mathbf{if}\;t \leq 1.8 \cdot 10^{+111} \lor \neg \left(t \leq 1.75 \cdot 10^{+141}\right) \land t \leq 7.5 \cdot 10^{+256}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y \cdot t\right)\\ \end{array} \]
Alternative 5
Error4.9
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 2.85 \cdot 10^{+103}:\\ \;\;\;\;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 6
Error5.1
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 3.5 \cdot 10^{+103}:\\ \;\;\;\;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 7
Error30.4
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 1.08 \cdot 10^{+95}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 8
Error31.7
Cost320
\[x \cdot \left(y \cdot t\right) \]

Error

Reproduce?

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