| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 576 |
(FPCore (x) :precision binary64 (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))
(FPCore (x) :precision binary64 (- 3.0 (- (* x 12.0) (* (* x x) 9.0))))
double code(double x) {
return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
double code(double x) {
return 3.0 - ((x * 12.0) - ((x * x) * 9.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 3.0d0 * ((((x * 3.0d0) * x) - (x * 4.0d0)) + 1.0d0)
end function
real(8) function code(x)
real(8), intent (in) :: x
code = 3.0d0 - ((x * 12.0d0) - ((x * x) * 9.0d0))
end function
public static double code(double x) {
return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
public static double code(double x) {
return 3.0 - ((x * 12.0) - ((x * x) * 9.0));
}
def code(x): return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)
def code(x): return 3.0 - ((x * 12.0) - ((x * x) * 9.0))
function code(x) return Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0)) end
function code(x) return Float64(3.0 - Float64(Float64(x * 12.0) - Float64(Float64(x * x) * 9.0))) end
function tmp = code(x) tmp = 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0); end
function tmp = code(x) tmp = 3.0 - ((x * 12.0) - ((x * x) * 9.0)); end
code[x_] := N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(3.0 - N[(N[(x * 12.0), $MachinePrecision] - N[(N[(x * x), $MachinePrecision] * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 - \left(x \cdot 12 - \left(x \cdot x\right) \cdot 9\right)
Results
| Original | 0.1 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ 3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-11 [=>]0.1 | \[ 3 \cdot \color{blue}{\left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) - -1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-87 [=>]0.1 | \[ \color{blue}{\left(-3\right) \cdot \left(-1 - \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right)\right)}
\] |
metadata-eval [=>]0.1 | \[ \color{blue}{-3} \cdot \left(-1 - \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right)\right)
\] |
metadata-eval [<=]0.1 | \[ \color{blue}{\left(3 \cdot -1\right)} \cdot \left(-1 - \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-13 [=>]0.1 | \[ \color{blue}{-1 \cdot \left(3 \cdot -1\right) - \left(3 \cdot -1\right) \cdot \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right)}
\] |
metadata-eval [=>]0.1 | \[ -1 \cdot \color{blue}{-3} - \left(3 \cdot -1\right) \cdot \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right)
\] |
metadata-eval [=>]0.1 | \[ \color{blue}{3} - \left(3 \cdot -1\right) \cdot \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-87 [=>]0.1 | \[ 3 - \color{blue}{\left(-3 \cdot -1\right) \cdot \left(x \cdot 4 - \left(x \cdot 3\right) \cdot x\right)}
\] |
metadata-eval [=>]0.1 | \[ 3 - \left(-\color{blue}{-3}\right) \cdot \left(x \cdot 4 - \left(x \cdot 3\right) \cdot x\right)
\] |
metadata-eval [=>]0.1 | \[ 3 - \color{blue}{3} \cdot \left(x \cdot 4 - \left(x \cdot 3\right) \cdot x\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-13 [=>]0.1 | \[ 3 - \color{blue}{\left(\left(x \cdot 4\right) \cdot 3 - 3 \cdot \left(\left(x \cdot 3\right) \cdot x\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.1 | \[ 3 - \left(\color{blue}{3 \cdot \left(x \cdot 4\right)} - 3 \cdot \left(\left(x \cdot 3\right) \cdot x\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.1 | \[ 3 - \left(\color{blue}{x \cdot \left(3 \cdot 4\right)} - 3 \cdot \left(\left(x \cdot 3\right) \cdot x\right)\right)
\] |
metadata-eval [=>]0.1 | \[ 3 - \left(x \cdot \color{blue}{12} - 3 \cdot \left(\left(x \cdot 3\right) \cdot x\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ 3 - \left(x \cdot 12 - 3 \cdot \color{blue}{\left(x \cdot \left(x \cdot 3\right)\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ 3 - \left(x \cdot 12 - 3 \cdot \left(x \cdot \color{blue}{\left(3 \cdot x\right)}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.1 | \[ 3 - \left(x \cdot 12 - 3 \cdot \color{blue}{\left(3 \cdot \left(x \cdot x\right)\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ 3 - \left(x \cdot 12 - 3 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot 3\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.1 | \[ 3 - \left(x \cdot 12 - \color{blue}{\left(x \cdot x\right) \cdot \left(3 \cdot 3\right)}\right)
\] |
metadata-eval [=>]0.1 | \[ 3 - \left(x \cdot 12 - \left(x \cdot x\right) \cdot \color{blue}{9}\right)
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 576 |
| Alternative 2 | |
|---|---|
| Error | 2.0 |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Error | 20.8 |
| Cost | 320 |
| Alternative 4 | |
|---|---|
| Error | 21.0 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x)
:name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:herbie-target
(+ 3.0 (- (* (* 9.0 x) x) (* 12.0 x)))
(* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))