| Alternative 1 | |
|---|---|
| Error | 21.2 |
| Cost | 448 |
\[\frac{1 + -1.3333333333333333 \cdot x}{y}
\]
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
(FPCore (x y) :precision binary64 (* 0.3333333333333333 (/ (* (- 3.0 x) (- 1.0 x)) y)))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
double code(double x, double y) {
return 0.3333333333333333 * (((3.0 - x) * (1.0 - x)) / y);
}
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 = 0.3333333333333333d0 * (((3.0d0 - x) * (1.0d0 - x)) / y)
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 0.3333333333333333 * (((3.0 - x) * (1.0 - x)) / y);
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
def code(x, y): return 0.3333333333333333 * (((3.0 - x) * (1.0 - x)) / y)
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(0.3333333333333333 * Float64(Float64(Float64(3.0 - x) * Float64(1.0 - x)) / y)) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
function tmp = code(x, y) tmp = 0.3333333333333333 * (((3.0 - x) * (1.0 - x)) / y); 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[(0.3333333333333333 * N[(N[(N[(3.0 - x), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
0.3333333333333333 \cdot \frac{\left(3 - x\right) \cdot \left(1 - x\right)}{y}
Results
| Original | 6.0 |
|---|---|
| Target | 0.1 |
| Herbie | 6.1 |
Initial program 6.0
Taylor expanded in y around 0 6.1
Final simplification6.1
| Alternative 1 | |
|---|---|
| Error | 21.2 |
| Cost | 448 |
| Alternative 2 | |
|---|---|
| Error | 21.5 |
| 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)))