| Alternative 1 | |
|---|---|
| Error | 29.27% |
| Cost | 520 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{-87}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+94}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (- x (* y z)))
(FPCore (x y z) :precision binary64 (fma (- z) y x))
double code(double x, double y, double z) {
return x - (y * z);
}
double code(double x, double y, double z) {
return fma(-z, y, x);
}
function code(x, y, z) return Float64(x - Float64(y * z)) end
function code(x, y, z) return fma(Float64(-z), y, x) end
code[x_, y_, z_] := N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[((-z) * y + x), $MachinePrecision]
x - y \cdot z
\mathsf{fma}\left(-z, y, x\right)
| Original | 0.01% |
|---|---|
| Target | 0.02% |
| Herbie | 0% |
Initial program 0.01
Applied egg-rr2.1
Applied egg-rr0
Taylor expanded in y around 0 0.07
Simplified0
[Start]0.07 | \[ \left(-2 \cdot z + z\right) \cdot y + x
\] |
|---|---|
distribute-lft1-in [=>]0.01 | \[ \color{blue}{\left(\left(-2 + 1\right) \cdot z\right)} \cdot y + x
\] |
metadata-eval [=>]0.01 | \[ \left(\color{blue}{-1} \cdot z\right) \cdot y + x
\] |
fma-def [=>]0 | \[ \color{blue}{\mathsf{fma}\left(-1 \cdot z, y, x\right)}
\] |
mul-1-neg [=>]0 | \[ \mathsf{fma}\left(\color{blue}{-z}, y, x\right)
\] |
Final simplification0
| Alternative 1 | |
|---|---|
| Error | 29.27% |
| Cost | 520 |
| Alternative 2 | |
|---|---|
| Error | 0.01% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Error | 42.08% |
| Cost | 64 |
herbie shell --seed 2023089
(FPCore (x y z)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, C"
:precision binary64
:herbie-target
(/ (+ x (* y z)) (/ (+ x (* y z)) (- x (* y z))))
(- x (* y z)))