?

Average Error: 10.52% → 2.15%
Time: 8.6s
Precision: binary64
Cost: 1481

?

\[ \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 -5 \cdot 10^{+183} \lor \neg \left(t_1 \leq 10^{+278}\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} \]
(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 (or (<= t_1 -5e+183) (not (<= t_1 1e+278)))
     (* y (* t (- x z)))
     (* 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 tmp;
	if ((t_1 <= -5e+183) || !(t_1 <= 1e+278)) {
		tmp = y * (t * (x - z));
	} 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) :: tmp
    t_1 = (x * y) - (y * z)
    if ((t_1 <= (-5d+183)) .or. (.not. (t_1 <= 1d+278))) then
        tmp = y * (t * (x - z))
    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 tmp;
	if ((t_1 <= -5e+183) || !(t_1 <= 1e+278)) {
		tmp = y * (t * (x - z));
	} 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)
	tmp = 0
	if (t_1 <= -5e+183) or not (t_1 <= 1e+278):
		tmp = y * (t * (x - z))
	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))
	tmp = 0.0
	if ((t_1 <= -5e+183) || !(t_1 <= 1e+278))
		tmp = Float64(y * Float64(t * Float64(x - z)));
	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);
	tmp = 0.0;
	if ((t_1 <= -5e+183) || ~((t_1 <= 1e+278)))
		tmp = y * (t * (x - z));
	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]}, If[Or[LessEqual[t$95$1, -5e+183], N[Not[LessEqual[t$95$1, 1e+278]], $MachinePrecision]], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+183} \lor \neg \left(t_1 \leq 10^{+278}\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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.52%
Target5.3%
Herbie2.15%
\[\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)) < -5.00000000000000009e183 or 9.99999999999999964e277 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 50.87

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

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

      [Start]50.87

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

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

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

      associate-*l* [=>]1.61

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

      *-commutative [=>]1.61

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

    if -5.00000000000000009e183 < (-.f64 (*.f64 x y) (*.f64 z y)) < 9.99999999999999964e277

    1. Initial program 2.26

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

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

      [Start]2.26

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - y \cdot z \leq -5 \cdot 10^{+183} \lor \neg \left(x \cdot y - y \cdot z \leq 10^{+278}\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
Error32.34%
Cost980
\[\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 -1.35 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 10^{+126}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 2
Error32.11%
Cost912
\[\begin{array}{l} t_1 := y \cdot \left(x \cdot t\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-142}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{+20}:\\ \;\;\;\;-y \cdot \left(z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 3
Error32.32%
Cost912
\[\begin{array}{l} t_1 := y \cdot \left(x \cdot t\right)\\ \mathbf{if}\;x \leq -2.3 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-142}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.7 \cdot 10^{+20}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 4
Error11.51%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{-266} \lor \neg \left(z \leq 3.3 \cdot 10^{-247}\right):\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 5
Error44.89%
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq -0.2:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 6
Error44.94%
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 4.5 \cdot 10^{-46}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 7
Error48.49%
Cost320
\[t \cdot \left(x \cdot y\right) \]

Error

Reproduce?

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