| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6976 |
\[t + \mathsf{fma}\left(z, -0.5 \cdot y, 0.125 \cdot x\right)
\]
(FPCore (x y z t) :precision binary64 (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))
(FPCore (x y z t) :precision binary64 (fma z (* -0.5 y) (fma 0.125 x t)))
double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
double code(double x, double y, double z, double t) {
return fma(z, (-0.5 * y), fma(0.125, x, t));
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) - Float64(Float64(y * z) / 2.0)) + t) end
function code(x, y, z, t) return fma(z, Float64(-0.5 * y), fma(0.125, x, t)) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(z * N[(-0.5 * y), $MachinePrecision] + N[(0.125 * x + t), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
\mathsf{fma}\left(z, -0.5 \cdot y, \mathsf{fma}\left(0.125, x, t\right)\right)
| Original | 100.0% |
|---|---|
| Target | 100.0% |
| Herbie | 100.0% |
Initial program 100.0%
Simplified100.0%
[Start]100.0 | \[ \left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
\] |
|---|---|
sub-neg [=>]100.0 | \[ \color{blue}{\left(\frac{1}{8} \cdot x + \left(-\frac{y \cdot z}{2}\right)\right)} + t
\] |
+-commutative [=>]100.0 | \[ \color{blue}{\left(\left(-\frac{y \cdot z}{2}\right) + \frac{1}{8} \cdot x\right)} + t
\] |
associate-+l+ [=>]100.0 | \[ \color{blue}{\left(-\frac{y \cdot z}{2}\right) + \left(\frac{1}{8} \cdot x + t\right)}
\] |
neg-mul-1 [=>]100.0 | \[ \color{blue}{-1 \cdot \frac{y \cdot z}{2}} + \left(\frac{1}{8} \cdot x + t\right)
\] |
associate-*l/ [<=]100.0 | \[ -1 \cdot \color{blue}{\left(\frac{y}{2} \cdot z\right)} + \left(\frac{1}{8} \cdot x + t\right)
\] |
associate-*r* [=>]100.0 | \[ \color{blue}{\left(-1 \cdot \frac{y}{2}\right) \cdot z} + \left(\frac{1}{8} \cdot x + t\right)
\] |
*-commutative [=>]100.0 | \[ \color{blue}{z \cdot \left(-1 \cdot \frac{y}{2}\right)} + \left(\frac{1}{8} \cdot x + t\right)
\] |
+-commutative [<=]100.0 | \[ z \cdot \left(-1 \cdot \frac{y}{2}\right) + \color{blue}{\left(t + \frac{1}{8} \cdot x\right)}
\] |
fma-def [=>]100.0 | \[ \color{blue}{\mathsf{fma}\left(z, -1 \cdot \frac{y}{2}, t + \frac{1}{8} \cdot x\right)}
\] |
associate-*r/ [=>]100.0 | \[ \mathsf{fma}\left(z, \color{blue}{\frac{-1 \cdot y}{2}}, t + \frac{1}{8} \cdot x\right)
\] |
associate-/l* [=>]99.9 | \[ \mathsf{fma}\left(z, \color{blue}{\frac{-1}{\frac{2}{y}}}, t + \frac{1}{8} \cdot x\right)
\] |
associate-/r/ [=>]100.0 | \[ \mathsf{fma}\left(z, \color{blue}{\frac{-1}{2} \cdot y}, t + \frac{1}{8} \cdot x\right)
\] |
metadata-eval [=>]100.0 | \[ \mathsf{fma}\left(z, \color{blue}{-0.5} \cdot y, t + \frac{1}{8} \cdot x\right)
\] |
+-commutative [=>]100.0 | \[ \mathsf{fma}\left(z, -0.5 \cdot y, \color{blue}{\frac{1}{8} \cdot x + t}\right)
\] |
fma-def [=>]100.0 | \[ \mathsf{fma}\left(z, -0.5 \cdot y, \color{blue}{\mathsf{fma}\left(\frac{1}{8}, x, t\right)}\right)
\] |
metadata-eval [=>]100.0 | \[ \mathsf{fma}\left(z, -0.5 \cdot y, \mathsf{fma}\left(\color{blue}{0.125}, x, t\right)\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Accuracy | 80.9% |
| Cost | 1362 |
| Alternative 3 | |
|---|---|
| Accuracy | 53.5% |
| Cost | 984 |
| Alternative 4 | |
|---|---|
| Accuracy | 86.6% |
| Cost | 713 |
| Alternative 5 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 704 |
| Alternative 6 | |
|---|---|
| Accuracy | 56.3% |
| Cost | 456 |
| Alternative 7 | |
|---|---|
| Accuracy | 37.2% |
| Cost | 64 |
herbie shell --seed 2023122
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, B"
:precision binary64
:herbie-target
(- (+ (/ x 8.0) t) (* (/ z 2.0) y))
(+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))