| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 713 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.58 \lor \neg \left(x \leq 0.58\right):\\
\;\;\;\;x \cdot \left(x \cdot 9 + -12\right)\\
\mathbf{else}:\\
\;\;\;\;3 + x \cdot -12\\
\end{array}
\]
(FPCore (x) :precision binary64 (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))
(FPCore (x) :precision binary64 (+ 3.0 (* 3.0 (* x (+ (* 3.0 x) -4.0)))))
double code(double x) {
return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
double code(double x) {
return 3.0 + (3.0 * (x * ((3.0 * x) + -4.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 + (3.0d0 * (x * ((3.0d0 * x) + (-4.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 + (3.0 * (x * ((3.0 * x) + -4.0)));
}
def code(x): return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)
def code(x): return 3.0 + (3.0 * (x * ((3.0 * x) + -4.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(3.0 * Float64(x * Float64(Float64(3.0 * x) + -4.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 + (3.0 * (x * ((3.0 * x) + -4.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[(3.0 * N[(x * N[(N[(3.0 * x), $MachinePrecision] + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + 3 \cdot \left(x \cdot \left(3 \cdot x + -4\right)\right)
Results
| Original | 99.8% |
|---|---|
| Target | 99.9% |
| Herbie | 99.8% |
Initial program 99.8%
Applied egg-rr99.8%
[Start]99.8 | \[ 3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\] |
|---|---|
distribute-lft-in [=>]99.8 | \[ \color{blue}{3 \cdot \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 3 \cdot 1}
\] |
*-commutative [=>]99.8 | \[ 3 \cdot \left(\color{blue}{x \cdot \left(x \cdot 3\right)} - x \cdot 4\right) + 3 \cdot 1
\] |
distribute-lft-out-- [=>]99.8 | \[ 3 \cdot \color{blue}{\left(x \cdot \left(x \cdot 3 - 4\right)\right)} + 3 \cdot 1
\] |
metadata-eval [=>]99.8 | \[ 3 \cdot \left(x \cdot \left(x \cdot 3 - 4\right)\right) + \color{blue}{3}
\] |
Final simplification99.8%
| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 713 |
| Alternative 2 | |
|---|---|
| Accuracy | 96.9% |
| Cost | 585 |
| Alternative 3 | |
|---|---|
| Accuracy | 97.7% |
| Cost | 585 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 576 |
| Alternative 5 | |
|---|---|
| Accuracy | 67.2% |
| Cost | 64 |
herbie shell --seed 2023135
(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)))