| Alternative 1 | |
|---|---|
| Error | 1.54% |
| Cost | 841 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \lor \neg \left(x \leq 1.75\right):\\
\;\;\;\;\frac{x}{\frac{y \cdot 3}{x + -4}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\
\end{array}
\]
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
(FPCore (x y) :precision binary64 (* (/ (- 1.0 x) y) (- 1.0 (/ x 3.0))))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
double code(double x, double y) {
return ((1.0 - x) / y) * (1.0 - (x / 3.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) / y) * (1.0d0 - (x / 3.0d0))
end function
public static double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
public static double code(double x, double y) {
return ((1.0 - x) / y) * (1.0 - (x / 3.0));
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
def code(x, y): return ((1.0 - x) / y) * (1.0 - (x / 3.0))
function code(x, y) return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) end
function code(x, y) return Float64(Float64(Float64(1.0 - x) / y) * Float64(1.0 - Float64(x / 3.0))) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
function tmp = code(x, y) tmp = ((1.0 - x) / y) * (1.0 - (x / 3.0)); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] * N[(1.0 - N[(x / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\frac{1 - x}{y} \cdot \left(1 - \frac{x}{3}\right)
Results
| Original | 9.34% |
|---|---|
| Target | 0.21% |
| Herbie | 0.21% |
Initial program 9.34
Simplified0.21
[Start]9.34 | \[ \frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\] |
|---|---|
times-frac [=>]0.21 | \[ \color{blue}{\frac{1 - x}{y} \cdot \frac{3 - x}{3}}
\] |
div-sub [=>]0.21 | \[ \frac{1 - x}{y} \cdot \color{blue}{\left(\frac{3}{3} - \frac{x}{3}\right)}
\] |
metadata-eval [=>]0.21 | \[ \frac{1 - x}{y} \cdot \left(\color{blue}{1} - \frac{x}{3}\right)
\] |
Final simplification0.21
| Alternative 1 | |
|---|---|
| Error | 1.54% |
| Cost | 841 |
| Alternative 2 | |
|---|---|
| Error | 2.32% |
| Cost | 840 |
| Alternative 3 | |
|---|---|
| Error | 3.01% |
| Cost | 713 |
| Alternative 4 | |
|---|---|
| Error | 2.96% |
| Cost | 712 |
| Alternative 5 | |
|---|---|
| Error | 2.96% |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 2.33% |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 0.66% |
| Cost | 704 |
| Alternative 8 | |
|---|---|
| Error | 33.62% |
| Cost | 192 |
herbie shell --seed 2023090
(FPCore (x y)
:name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(* (/ (- 1.0 x) y) (/ (- 3.0 x) 3.0))
(/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))