?

Average Accuracy: 59.8% → 87.6%
Time: 19.8s
Precision: binary64
Cost: 16713

?

\[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \]
\[\begin{array}{l} t_1 := \frac{\left(a \cdot \left(y + t\right) + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+254}\right):\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(x + y, z, t \cdot a\right)\right)}{x + \left(y + t\right)}\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (/ (- (+ (* a (+ y t)) (* z (+ x y))) (* y b)) (+ y (+ x t)))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+254)))
     (- (+ z a) b)
     (/ (fma y (- a b) (fma (+ x y) z (* t a))) (+ x (+ y t))))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (((a * (y + t)) + (z * (x + y))) - (y * b)) / (y + (x + t));
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+254)) {
		tmp = (z + a) - b;
	} else {
		tmp = fma(y, (a - b), fma((x + y), z, (t * a))) / (x + (y + t));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y))
end
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(Float64(Float64(a * Float64(y + t)) + Float64(z * Float64(x + y))) - Float64(y * b)) / Float64(y + Float64(x + t)))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+254))
		tmp = Float64(Float64(z + a) - b);
	else
		tmp = Float64(fma(y, Float64(a - b), fma(Float64(x + y), z, Float64(t * a))) / Float64(x + Float64(y + t)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(a * N[(y + t), $MachinePrecision]), $MachinePrecision] + N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+254]], $MachinePrecision]], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], N[(N[(y * N[(a - b), $MachinePrecision] + N[(N[(x + y), $MachinePrecision] * z + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\begin{array}{l}
t_1 := \frac{\left(a \cdot \left(y + t\right) + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+254}\right):\\
\;\;\;\;\left(z + a\right) - b\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(x + y, z, t \cdot a\right)\right)}{x + \left(y + t\right)}\\


\end{array}

Error?

Bogosity?

Bogosity

Target

Original59.8%
Target81.9%
Herbie87.6%
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} < -3.5813117084150564 \cdot 10^{+153}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} < 1.2285964308315609 \cdot 10^{+82}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 1.9999999999999999e254 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y))

    1. Initial program 7.2%

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \]
    2. Simplified7.4%

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

      [Start]7.2

      \[ \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \]

      fma-def [=>]7.4

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

      +-commutative [=>]7.4

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

      +-commutative [=>]7.4

      \[ \frac{\mathsf{fma}\left(x + y, z, \left(y + t\right) \cdot a\right) - y \cdot b}{\color{blue}{y + \left(x + t\right)}} \]
    3. Taylor expanded in y around inf 77.1%

      \[\leadsto \color{blue}{\left(a + z\right) - b} \]
    4. Simplified77.1%

      \[\leadsto \color{blue}{\left(z + a\right) - b} \]
      Proof

      [Start]77.1

      \[ \left(a + z\right) - b \]

      +-commutative [=>]77.1

      \[ \color{blue}{\left(z + a\right)} - b \]

    if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1.9999999999999999e254

    1. Initial program 99.7%

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \]
    2. Simplified99.7%

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

      [Start]99.7

      \[ \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \]

      *-commutative [=>]99.7

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

      distribute-rgt-in [=>]99.7

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

      associate-+r+ [=>]99.7

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

      associate--l+ [=>]99.7

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

      +-commutative [=>]99.7

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

      +-commutative [=>]99.7

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

      distribute-lft-out-- [=>]99.7

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

      fma-def [=>]99.7

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

      +-commutative [<=]99.7

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

      fma-def [=>]99.7

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

      associate-+l+ [=>]99.7

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

      +-commutative [=>]99.7

      \[ \frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(x + y, z, t \cdot a\right)\right)}{x + \color{blue}{\left(y + t\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(a \cdot \left(y + t\right) + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)} \leq -\infty \lor \neg \left(\frac{\left(a \cdot \left(y + t\right) + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)} \leq 2 \cdot 10^{+254}\right):\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(x + y, z, t \cdot a\right)\right)}{x + \left(y + t\right)}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy87.6%
Cost4297
\[\begin{array}{l} t_1 := \frac{\left(a \cdot \left(y + t\right) + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+254}\right):\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot z + \left(y \cdot \left(a - b\right) + \left(x \cdot z + t \cdot a\right)\right)}{x + \left(y + t\right)}\\ \end{array} \]
Alternative 2
Accuracy87.6%
Cost4169
\[\begin{array}{l} t_1 := \frac{\left(a \cdot \left(y + t\right) + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+254}\right):\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy57.2%
Cost2020
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := z \cdot \frac{x + y}{t_1}\\ t_3 := \left(z + a\right) - b\\ t_4 := \frac{y \cdot t_3}{t_1}\\ t_5 := \frac{t \cdot a - y \cdot b}{t_1}\\ \mathbf{if}\;y \leq -135000000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -2.6 \cdot 10^{-79}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-137}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-181}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-200}:\\ \;\;\;\;\frac{a}{\frac{t_1}{y + t}}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-274}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-115}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-63}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+41}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Accuracy58.2%
Cost1884
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := \frac{y \cdot \left(a - b\right) + t \cdot a}{t_1}\\ t_3 := \left(z + a\right) - b\\ t_4 := z \cdot \frac{x + y}{t_1}\\ \mathbf{if}\;y \leq -150000000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -1.76 \cdot 10^{-140}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{-181}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-275}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-137}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+77}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right) - y \cdot b}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Accuracy58.0%
Cost1365
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := z \cdot \frac{x + y}{t_1}\\ \mathbf{if}\;z \leq -2.15 \cdot 10^{+105}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-308}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-81} \lor \neg \left(z \leq 1.2 \cdot 10^{-47}\right) \land z \leq 2.6 \cdot 10^{+21}:\\ \;\;\;\;\frac{a}{\frac{t_1}{y + t}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Accuracy61.1%
Cost1365
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := z \cdot \frac{x + y}{t_1}\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{+105}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{-140}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;z \leq 2.65 \cdot 10^{-80}:\\ \;\;\;\;\frac{y \cdot \left(a - b\right) + t \cdot a}{t_1}\\ \mathbf{elif}\;z \leq 10^{-44} \lor \neg \left(z \leq 2.1 \cdot 10^{+21}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\frac{t_1}{y + t}}\\ \end{array} \]
Alternative 7
Accuracy54.2%
Cost1364
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := z \cdot \frac{x + y}{t_1}\\ t_3 := \left(z + a\right) - b\\ \mathbf{if}\;b \leq -7 \cdot 10^{-65}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq -3.4 \cdot 10^{-126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 1.3 \cdot 10^{+119}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{+156}:\\ \;\;\;\;\frac{a}{\frac{x + t}{t}}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{+212}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{-y}{t_1}\\ \end{array} \]
Alternative 8
Accuracy56.0%
Cost976
\[\begin{array}{l} t_1 := z \cdot \frac{x}{x + t}\\ t_2 := \left(z + a\right) - b\\ \mathbf{if}\;y \leq -3.25 \cdot 10^{-137}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{-181}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-275}:\\ \;\;\;\;a\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-232}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Accuracy57.0%
Cost976
\[\begin{array}{l} t_1 := z \cdot \frac{x}{x + t}\\ t_2 := \left(z + a\right) - b\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{-138}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-275}:\\ \;\;\;\;\frac{a}{\frac{x + t}{t}}\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-232}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Accuracy47.2%
Cost724
\[\begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+40}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-287}:\\ \;\;\;\;a - b\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-80}:\\ \;\;\;\;a\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-47}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+21}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 11
Accuracy45.3%
Cost592
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+36}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 1.12 \cdot 10^{-80}:\\ \;\;\;\;a\\ \mathbf{elif}\;z \leq 2.95 \cdot 10^{-44}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+21}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 12
Accuracy56.8%
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq -1.3 \cdot 10^{+174}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array} \]
Alternative 13
Accuracy32.4%
Cost64
\[a \]

Error

Reproduce?

herbie shell --seed 2023160 
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
  :precision binary64

  :herbie-target
  (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3.5813117084150564e+153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e+82) (/ 1.0 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b)))

  (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))