| Alternative 1 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 448 |
\[3 \cdot \left(y \cdot \left(y \cdot x\right)\right)
\]
(FPCore (x y) :precision binary64 (* (* (* x 3.0) y) y))
(FPCore (x y) :precision binary64 (* y (* (* 3.0 y) x)))
double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
double code(double x, double y) {
return y * ((3.0 * y) * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 3.0d0) * y) * y
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * ((3.0d0 * y) * x)
end function
public static double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
public static double code(double x, double y) {
return y * ((3.0 * y) * x);
}
def code(x, y): return ((x * 3.0) * y) * y
def code(x, y): return y * ((3.0 * y) * x)
function code(x, y) return Float64(Float64(Float64(x * 3.0) * y) * y) end
function code(x, y) return Float64(y * Float64(Float64(3.0 * y) * x)) end
function tmp = code(x, y) tmp = ((x * 3.0) * y) * y; end
function tmp = code(x, y) tmp = y * ((3.0 * y) * x); end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]
code[x_, y_] := N[(y * N[(N[(3.0 * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
y \cdot \left(\left(3 \cdot y\right) \cdot x\right)
Results
| Original | 99.5% |
|---|---|
| Target | 99.6% |
| Herbie | 99.6% |
Initial program 99.5%
Applied egg-rr69.5%
[Start]99.5 | \[ \left(\left(x \cdot 3\right) \cdot y\right) \cdot y
\] |
|---|---|
expm1-log1p-u [=>]82.1 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x \cdot 3\right) \cdot y\right)\right)} \cdot y
\] |
expm1-udef [=>]52.0 | \[ \color{blue}{\left(e^{\mathsf{log1p}\left(\left(x \cdot 3\right) \cdot y\right)} - 1\right)} \cdot y
\] |
log1p-udef [=>]52.0 | \[ \left(e^{\color{blue}{\log \left(1 + \left(x \cdot 3\right) \cdot y\right)}} - 1\right) \cdot y
\] |
add-exp-log [<=]69.4 | \[ \left(\color{blue}{\left(1 + \left(x \cdot 3\right) \cdot y\right)} - 1\right) \cdot y
\] |
associate-*l* [=>]69.5 | \[ \left(\left(1 + \color{blue}{x \cdot \left(3 \cdot y\right)}\right) - 1\right) \cdot y
\] |
Applied egg-rr99.6%
[Start]69.5 | \[ \left(\left(1 + x \cdot \left(3 \cdot y\right)\right) - 1\right) \cdot y
\] |
|---|---|
add-exp-log [=>]52.0 | \[ \left(\color{blue}{e^{\log \left(1 + x \cdot \left(3 \cdot y\right)\right)}} - 1\right) \cdot y
\] |
expm1-def [=>]52.0 | \[ \color{blue}{\mathsf{expm1}\left(\log \left(1 + x \cdot \left(3 \cdot y\right)\right)\right)} \cdot y
\] |
log1p-def [=>]82.2 | \[ \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(x \cdot \left(3 \cdot y\right)\right)}\right) \cdot y
\] |
expm1-log1p-u [<=]99.6 | \[ \color{blue}{\left(x \cdot \left(3 \cdot y\right)\right)} \cdot y
\] |
*-commutative [=>]99.6 | \[ \color{blue}{\left(\left(3 \cdot y\right) \cdot x\right)} \cdot y
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 448 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 448 |
herbie shell --seed 2023133
(FPCore (x y)
:name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, B"
:precision binary64
:herbie-target
(* (* x (* 3.0 y)) y)
(* (* (* x 3.0) y) y))