| Alternative 1 | |
|---|---|
| Error | 0.9 |
| Cost | 9672 |
(FPCore (x y z t a b) :precision binary64 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* (* y 9.0) z) t)))
(if (<= t_1 -1e+306)
(fma a (* 27.0 b) (+ (* x 2.0) (* y (* (* z t) -9.0))))
(if (<= t_1 5e+286)
(fma t (* z (* y -9.0)) (fma x 2.0 (* a (* 27.0 b))))
(* y (* z (* t -9.0)))))))double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((y * 9.0) * z) * t;
double tmp;
if (t_1 <= -1e+306) {
tmp = fma(a, (27.0 * b), ((x * 2.0) + (y * ((z * t) * -9.0))));
} else if (t_1 <= 5e+286) {
tmp = fma(t, (z * (y * -9.0)), fma(x, 2.0, (a * (27.0 * b))));
} else {
tmp = y * (z * (t * -9.0));
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b)) end
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(y * 9.0) * z) * t) tmp = 0.0 if (t_1 <= -1e+306) tmp = fma(a, Float64(27.0 * b), Float64(Float64(x * 2.0) + Float64(y * Float64(Float64(z * t) * -9.0)))); elseif (t_1 <= 5e+286) tmp = fma(t, Float64(z * Float64(y * -9.0)), fma(x, 2.0, Float64(a * Float64(27.0 * b)))); else tmp = Float64(y * Float64(z * Float64(t * -9.0))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+306], N[(a * N[(27.0 * b), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] + N[(y * N[(N[(z * t), $MachinePrecision] * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+286], N[(t * N[(z * N[(y * -9.0), $MachinePrecision]), $MachinePrecision] + N[(x * 2.0 + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
t_1 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 + y \cdot \left(\left(z \cdot t\right) \cdot -9\right)\right)\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+286}:\\
\;\;\;\;\mathsf{fma}\left(t, z \cdot \left(y \cdot -9\right), \mathsf{fma}\left(x, 2, a \cdot \left(27 \cdot b\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(t \cdot -9\right)\right)\\
\end{array}
| Original | 2.7 |
|---|---|
| Target | 2.9 |
| Herbie | 0.8 |
if (*.f64 (*.f64 (*.f64 y 9) z) t) < -1.00000000000000002e306Initial program 61.4
Simplified1.1
[Start]61.4 | \[ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\] |
|---|---|
+-commutative [=>]61.4 | \[ \color{blue}{\left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}
\] |
associate-*l* [=>]61.4 | \[ \color{blue}{a \cdot \left(27 \cdot b\right)} + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)
\] |
fma-def [=>]61.4 | \[ \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}
\] |
associate-*l* [=>]2.1 | \[ \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right)
\] |
associate-*l* [=>]1.1 | \[ \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{y \cdot \left(9 \cdot \left(z \cdot t\right)\right)}\right)
\] |
if -1.00000000000000002e306 < (*.f64 (*.f64 (*.f64 y 9) z) t) < 5.0000000000000004e286Initial program 0.5
Simplified0.4
[Start]0.5 | \[ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\] |
|---|---|
sub-neg [=>]0.5 | \[ \color{blue}{\left(x \cdot 2 + \left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27\right) \cdot b
\] |
+-commutative [=>]0.5 | \[ \color{blue}{\left(\left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + x \cdot 2\right)} + \left(a \cdot 27\right) \cdot b
\] |
associate-+l+ [=>]0.5 | \[ \color{blue}{\left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)}
\] |
distribute-lft-neg-in [=>]0.5 | \[ \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t} + \left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)
\] |
+-commutative [<=]0.5 | \[ \left(-\left(y \cdot 9\right) \cdot z\right) \cdot t + \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)}
\] |
*-commutative [=>]0.5 | \[ \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} + \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)
\] |
fma-def [=>]0.5 | \[ \color{blue}{\mathsf{fma}\left(t, -\left(y \cdot 9\right) \cdot z, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)}
\] |
*-commutative [=>]0.5 | \[ \mathsf{fma}\left(t, -\color{blue}{z \cdot \left(y \cdot 9\right)}, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)
\] |
distribute-rgt-neg-in [=>]0.5 | \[ \mathsf{fma}\left(t, \color{blue}{z \cdot \left(-y \cdot 9\right)}, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)
\] |
distribute-rgt-neg-in [=>]0.5 | \[ \mathsf{fma}\left(t, z \cdot \color{blue}{\left(y \cdot \left(-9\right)\right)}, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)
\] |
metadata-eval [=>]0.5 | \[ \mathsf{fma}\left(t, z \cdot \left(y \cdot \color{blue}{-9}\right), \left(a \cdot 27\right) \cdot b + x \cdot 2\right)
\] |
+-commutative [=>]0.5 | \[ \mathsf{fma}\left(t, z \cdot \left(y \cdot -9\right), \color{blue}{x \cdot 2 + \left(a \cdot 27\right) \cdot b}\right)
\] |
fma-def [=>]0.5 | \[ \mathsf{fma}\left(t, z \cdot \left(y \cdot -9\right), \color{blue}{\mathsf{fma}\left(x, 2, \left(a \cdot 27\right) \cdot b\right)}\right)
\] |
associate-*l* [=>]0.4 | \[ \mathsf{fma}\left(t, z \cdot \left(y \cdot -9\right), \mathsf{fma}\left(x, 2, \color{blue}{a \cdot \left(27 \cdot b\right)}\right)\right)
\] |
if 5.0000000000000004e286 < (*.f64 (*.f64 (*.f64 y 9) z) t) Initial program 41.1
Simplified4.4
[Start]41.1 | \[ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\] |
|---|---|
+-commutative [=>]41.1 | \[ \color{blue}{\left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}
\] |
associate-*l* [=>]41.1 | \[ \color{blue}{a \cdot \left(27 \cdot b\right)} + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)
\] |
fma-def [=>]41.1 | \[ \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}
\] |
associate-*l* [=>]4.7 | \[ \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right)
\] |
associate-*l* [=>]4.4 | \[ \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{y \cdot \left(9 \cdot \left(z \cdot t\right)\right)}\right)
\] |
Taylor expanded in y around inf 15.7
Simplified15.7
[Start]15.7 | \[ -9 \cdot \left(y \cdot \left(t \cdot z\right)\right)
\] |
|---|---|
*-commutative [=>]15.7 | \[ \color{blue}{\left(y \cdot \left(t \cdot z\right)\right) \cdot -9}
\] |
*-commutative [<=]15.7 | \[ \left(y \cdot \color{blue}{\left(z \cdot t\right)}\right) \cdot -9
\] |
associate-*r* [<=]15.7 | \[ \color{blue}{y \cdot \left(\left(z \cdot t\right) \cdot -9\right)}
\] |
associate-*l* [=>]15.7 | \[ y \cdot \color{blue}{\left(z \cdot \left(t \cdot -9\right)\right)}
\] |
Final simplification0.8
| Alternative 1 | |
|---|---|
| Error | 0.9 |
| Cost | 9672 |
| Alternative 2 | |
|---|---|
| Error | 1.0 |
| Cost | 3400 |
| Alternative 3 | |
|---|---|
| Error | 34.5 |
| Cost | 1508 |
| Alternative 4 | |
|---|---|
| Error | 34.4 |
| Cost | 1508 |
| Alternative 5 | |
|---|---|
| Error | 10.0 |
| Cost | 1480 |
| Alternative 6 | |
|---|---|
| Error | 11.3 |
| Cost | 1480 |
| Alternative 7 | |
|---|---|
| Error | 1.8 |
| Cost | 1220 |
| Alternative 8 | |
|---|---|
| Error | 29.9 |
| Cost | 1112 |
| Alternative 9 | |
|---|---|
| Error | 29.9 |
| Cost | 1112 |
| Alternative 10 | |
|---|---|
| Error | 17.0 |
| Cost | 1104 |
| Alternative 11 | |
|---|---|
| Error | 17.0 |
| Cost | 1104 |
| Alternative 12 | |
|---|---|
| Error | 29.3 |
| Cost | 849 |
| Alternative 13 | |
|---|---|
| Error | 29.2 |
| Cost | 849 |
| Alternative 14 | |
|---|---|
| Error | 29.2 |
| Cost | 848 |
| Alternative 15 | |
|---|---|
| Error | 36.9 |
| Cost | 192 |
herbie shell --seed 2023054
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))
(+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))