?

Average Accuracy: 89.0% → 97.9%
Time: 12.7s
Precision: binary64
Cost: 14728

?

\[ \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^{+283}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+231}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(x - z\right), t, t \cdot \mathsf{fma}\left(y, -z, y \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \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+283)
     (* (- x z) (* y t))
     (if (<= t_1 2e+231)
       (fma (* y (- x z)) t (* t (fma y (- z) (* y z))))
       (* y (* (- x 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+283) {
		tmp = (x - z) * (y * t);
	} else if (t_1 <= 2e+231) {
		tmp = fma((y * (x - z)), t, (t * fma(y, -z, (y * z))));
	} else {
		tmp = y * ((x - 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+283)
		tmp = Float64(Float64(x - z) * Float64(y * t));
	elseif (t_1 <= 2e+231)
		tmp = fma(Float64(y * Float64(x - z)), t, Float64(t * fma(y, Float64(-z), Float64(y * z))));
	else
		tmp = Float64(y * Float64(Float64(x - z) * t));
	end
	return 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+283], N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+231], N[(N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision] * t + N[(t * N[(y * (-z) + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(x - z), $MachinePrecision] * t), $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^{+283}:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+231}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(x - z\right), t, t \cdot \mathsf{fma}\left(y, -z, y \cdot z\right)\right)\\

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


\end{array}

Error?

Target

Original89.0%
Target94.7%
Herbie97.9%
\[\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)) < -9.99999999999999955e282

    1. Initial program 19.3%

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

      \[\leadsto \color{blue}{y \cdot \left(t \cdot x\right) + -1 \cdot \left(y \cdot \left(t \cdot z\right)\right)} \]
    3. Simplified99.6%

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

      [Start]99.5

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

      associate-*r* [=>]99.6

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

      *-commutative [<=]99.6

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

      mul-1-neg [=>]99.6

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

      associate-*r* [=>]99.6

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

      *-commutative [<=]99.6

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

      distribute-rgt-neg-in [=>]99.6

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

      distribute-lft-in [<=]99.6

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

      sub-neg [<=]99.6

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

      *-commutative [=>]99.6

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

      *-commutative [=>]99.6

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

    if -9.99999999999999955e282 < (-.f64 (*.f64 x y) (*.f64 z y)) < 2.0000000000000001e231

    1. Initial program 97.5%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Applied egg-rr97.7%

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

      [Start]97.5

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

      *-commutative [=>]97.5

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

      prod-diff [=>]97.5

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

      *-commutative [<=]97.5

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

      fma-neg [<=]97.5

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

      distribute-rgt-in [=>]97.6

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

      fma-def [=>]97.7

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

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

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

      *-commutative [<=]97.7

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

      fma-udef [=>]97.5

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

      distribute-lft-neg-in [<=]97.5

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

      distribute-rgt-neg-in [=>]97.5

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

      fma-def [=>]97.7

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

      *-commutative [=>]97.7

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

    if 2.0000000000000001e231 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 44.2%

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

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

      [Start]44.2

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

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

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

      associate-*l* [=>]98.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - y \cdot z \leq -1 \cdot 10^{+283}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq 2 \cdot 10^{+231}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(x - z\right), t, t \cdot \mathsf{fma}\left(y, -z, y \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy97.7%
Cost1864
\[\begin{array}{l} t_1 := \left(x \cdot y - y \cdot z\right) \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{elif}\;t_1 \leq 10^{+291}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 2
Accuracy68.6%
Cost1176
\[\begin{array}{l} t_1 := \left(x \cdot y\right) \cdot t\\ t_2 := y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{if}\;x \leq -2.1 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.36 \cdot 10^{-222}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{-139}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-107}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-54}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy68.9%
Cost912
\[\begin{array}{l} t_1 := \left(x \cdot y\right) \cdot t\\ t_2 := z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-107}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-52}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy68.9%
Cost912
\[\begin{array}{l} t_1 := \left(x \cdot y\right) \cdot t\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-107}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-54}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-15}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy87.5%
Cost648
\[\begin{array}{l} \mathbf{if}\;t \leq 3.1 \cdot 10^{+196}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+223}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot t\\ \end{array} \]
Alternative 6
Accuracy95.8%
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 5 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array} \]
Alternative 7
Accuracy55.0%
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 2.4 \cdot 10^{+38}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 8
Accuracy53.5%
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 4 \cdot 10^{-300}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot t\\ \end{array} \]
Alternative 9
Accuracy51.2%
Cost320
\[y \cdot \left(x \cdot t\right) \]

Error

Reproduce?

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