| Alternative 1 | |
|---|---|
| Accuracy | 62.5% |
| Cost | 585 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-10} \lor \neg \left(y \leq 1.95 \cdot 10^{-75}\right):\\
\;\;\;\;y \cdot \left(x - z\right)\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (- 1.0 y))))
(FPCore (x y z) :precision binary64 (- (+ z (* y x)) (* y z)))
double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
double code(double x, double y, double z) {
return (z + (y * x)) - (y * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + (z * (1.0d0 - y))
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (z + (y * x)) - (y * z)
end function
public static double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
public static double code(double x, double y, double z) {
return (z + (y * x)) - (y * z);
}
def code(x, y, z): return (x * y) + (z * (1.0 - y))
def code(x, y, z): return (z + (y * x)) - (y * z)
function code(x, y, z) return Float64(Float64(x * y) + Float64(z * Float64(1.0 - y))) end
function code(x, y, z) return Float64(Float64(z + Float64(y * x)) - Float64(y * z)) end
function tmp = code(x, y, z) tmp = (x * y) + (z * (1.0 - y)); end
function tmp = code(x, y, z) tmp = (z + (y * x)) - (y * z); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(z + N[(y * x), $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]
x \cdot y + z \cdot \left(1 - y\right)
\left(z + y \cdot x\right) - y \cdot z
Results
| Original | 78.7% |
|---|---|
| Target | 78.7% |
| Herbie | 78.7% |
Initial program 81.6%
Simplified81.6%
[Start]81.6 | \[ x \cdot y + z \cdot \left(1 - y\right)
\] |
|---|---|
+-commutative [=>]81.6 | \[ \color{blue}{z \cdot \left(1 - y\right) + x \cdot y}
\] |
sub-neg [=>]81.6 | \[ z \cdot \color{blue}{\left(1 + \left(-y\right)\right)} + x \cdot y
\] |
distribute-rgt-in [=>]81.6 | \[ \color{blue}{\left(1 \cdot z + \left(-y\right) \cdot z\right)} + x \cdot y
\] |
*-lft-identity [=>]81.6 | \[ \left(\color{blue}{z} + \left(-y\right) \cdot z\right) + x \cdot y
\] |
associate-+l+ [=>]81.6 | \[ \color{blue}{z + \left(\left(-y\right) \cdot z + x \cdot y\right)}
\] |
+-commutative [=>]81.6 | \[ \color{blue}{\left(\left(-y\right) \cdot z + x \cdot y\right) + z}
\] |
*-commutative [=>]81.6 | \[ \left(\color{blue}{z \cdot \left(-y\right)} + x \cdot y\right) + z
\] |
neg-mul-1 [=>]81.6 | \[ \left(z \cdot \color{blue}{\left(-1 \cdot y\right)} + x \cdot y\right) + z
\] |
associate-*r* [=>]81.6 | \[ \left(\color{blue}{\left(z \cdot -1\right) \cdot y} + x \cdot y\right) + z
\] |
distribute-rgt-out [=>]81.6 | \[ \color{blue}{y \cdot \left(z \cdot -1 + x\right)} + z
\] |
fma-def [=>]81.6 | \[ \color{blue}{\mathsf{fma}\left(y, z \cdot -1 + x, z\right)}
\] |
+-commutative [=>]81.6 | \[ \mathsf{fma}\left(y, \color{blue}{x + z \cdot -1}, z\right)
\] |
*-commutative [=>]81.6 | \[ \mathsf{fma}\left(y, x + \color{blue}{-1 \cdot z}, z\right)
\] |
neg-mul-1 [<=]81.6 | \[ \mathsf{fma}\left(y, x + \color{blue}{\left(-z\right)}, z\right)
\] |
unsub-neg [=>]81.6 | \[ \mathsf{fma}\left(y, \color{blue}{x - z}, z\right)
\] |
Taylor expanded in x around inf 81.6%
Final simplification81.6%
| Alternative 1 | |
|---|---|
| Accuracy | 62.5% |
| Cost | 585 |
| Alternative 2 | |
|---|---|
| Accuracy | 77.6% |
| Cost | 585 |
| Alternative 3 | |
|---|---|
| Accuracy | 78.7% |
| Cost | 576 |
| Alternative 4 | |
|---|---|
| Accuracy | 48.7% |
| Cost | 456 |
| Alternative 5 | |
|---|---|
| Accuracy | 48.6% |
| Cost | 456 |
| Alternative 6 | |
|---|---|
| Accuracy | 78.7% |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Accuracy | 36.3% |
| Cost | 64 |
herbie shell --seed 2023157
(FPCore (x y z)
:name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(- z (* (- z x) y))
(+ (* x y) (* z (- 1.0 y))))