| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 320.00 |
\[x \cdot \frac{0.3333333333333333}{y}
\]
(FPCore (x y) :precision binary64 (/ x (* y 3.0)))
(FPCore (x y) :precision binary64 (/ (/ x 3.0) y))
double code(double x, double y) {
return x / (y * 3.0);
}
double code(double x, double y) {
return (x / 3.0) / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (y * 3.0d0)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / 3.0d0) / y
end function
public static double code(double x, double y) {
return x / (y * 3.0);
}
public static double code(double x, double y) {
return (x / 3.0) / y;
}
def code(x, y): return x / (y * 3.0)
def code(x, y): return (x / 3.0) / y
function code(x, y) return Float64(x / Float64(y * 3.0)) end
function code(x, y) return Float64(Float64(x / 3.0) / y) end
function tmp = code(x, y) tmp = x / (y * 3.0); end
function tmp = code(x, y) tmp = (x / 3.0) / y; end
code[x_, y_] := N[(x / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(x / 3.0), $MachinePrecision] / y), $MachinePrecision]
\frac{x}{y \cdot 3}
\frac{\frac{x}{3}}{y}
Results
| Original | 99.6% |
|---|---|
| Target | 99.6% |
| Herbie | 99.7% |
Initial program 99.6%
Applied egg-rr49.5%
Simplified49.5%
[Start]49.5 | \[ \frac{1}{\sqrt{y \cdot 3}} \cdot \frac{x}{\sqrt{y \cdot 3}}
\] |
|---|---|
associate-*l/ [=>]49.5 | \[ \color{blue}{\frac{1 \cdot \frac{x}{\sqrt{y \cdot 3}}}{\sqrt{y \cdot 3}}}
\] |
*-lft-identity [=>]49.5 | \[ \frac{\color{blue}{\frac{x}{\sqrt{y \cdot 3}}}}{\sqrt{y \cdot 3}}
\] |
Taylor expanded in x around 0 98.7%
Simplified99.7%
[Start]98.7 | \[ \frac{x}{y \cdot {\left(\sqrt{3}\right)}^{2}}
\] |
|---|---|
*-commutative [=>]98.7 | \[ \frac{x}{\color{blue}{{\left(\sqrt{3}\right)}^{2} \cdot y}}
\] |
*-lft-identity [<=]98.7 | \[ \frac{\color{blue}{1 \cdot x}}{{\left(\sqrt{3}\right)}^{2} \cdot y}
\] |
unpow2 [=>]98.7 | \[ \frac{1 \cdot x}{\color{blue}{\left(\sqrt{3} \cdot \sqrt{3}\right)} \cdot y}
\] |
rem-square-sqrt [=>]99.6 | \[ \frac{1 \cdot x}{\color{blue}{3} \cdot y}
\] |
associate-/r* [=>]99.7 | \[ \color{blue}{\frac{\frac{1 \cdot x}{3}}{y}}
\] |
*-lft-identity [=>]99.7 | \[ \frac{\frac{\color{blue}{x}}{3}}{y}
\] |
Final simplification99.7%
| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 320.00 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 320.00 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 320.00 |
herbie shell --seed 2023096
(FPCore (x y)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, C"
:precision binary64
:herbie-target
(/ (/ x y) 3.0)
(/ x (* y 3.0)))