?

Average Error: 0.2 → 0.2
Time: 6.6s
Precision: binary64
Cost: 7680

?

\[\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right) \]
\[\frac{27 - {x}^{3} \cdot 8}{9 + x \cdot \left(x \cdot 4 + 6\right)} \cdot \left(x \cdot x\right) \]
(FPCore (x) :precision binary64 (* (* x x) (- 3.0 (* x 2.0))))
(FPCore (x)
 :precision binary64
 (* (/ (- 27.0 (* (pow x 3.0) 8.0)) (+ 9.0 (* x (+ (* x 4.0) 6.0)))) (* x x)))
double code(double x) {
	return (x * x) * (3.0 - (x * 2.0));
}
double code(double x) {
	return ((27.0 - (pow(x, 3.0) * 8.0)) / (9.0 + (x * ((x * 4.0) + 6.0)))) * (x * x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x * x) * (3.0d0 - (x * 2.0d0))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((27.0d0 - ((x ** 3.0d0) * 8.0d0)) / (9.0d0 + (x * ((x * 4.0d0) + 6.0d0)))) * (x * x)
end function
public static double code(double x) {
	return (x * x) * (3.0 - (x * 2.0));
}
public static double code(double x) {
	return ((27.0 - (Math.pow(x, 3.0) * 8.0)) / (9.0 + (x * ((x * 4.0) + 6.0)))) * (x * x);
}
def code(x):
	return (x * x) * (3.0 - (x * 2.0))
def code(x):
	return ((27.0 - (math.pow(x, 3.0) * 8.0)) / (9.0 + (x * ((x * 4.0) + 6.0)))) * (x * x)
function code(x)
	return Float64(Float64(x * x) * Float64(3.0 - Float64(x * 2.0)))
end
function code(x)
	return Float64(Float64(Float64(27.0 - Float64((x ^ 3.0) * 8.0)) / Float64(9.0 + Float64(x * Float64(Float64(x * 4.0) + 6.0)))) * Float64(x * x))
end
function tmp = code(x)
	tmp = (x * x) * (3.0 - (x * 2.0));
end
function tmp = code(x)
	tmp = ((27.0 - ((x ^ 3.0) * 8.0)) / (9.0 + (x * ((x * 4.0) + 6.0)))) * (x * x);
end
code[x_] := N[(N[(x * x), $MachinePrecision] * N[(3.0 - N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[(27.0 - N[(N[Power[x, 3.0], $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision] / N[(9.0 + N[(x * N[(N[(x * 4.0), $MachinePrecision] + 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)
\frac{27 - {x}^{3} \cdot 8}{9 + x \cdot \left(x \cdot 4 + 6\right)} \cdot \left(x \cdot x\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.2
Target0.2
Herbie0.2
\[x \cdot \left(x \cdot \left(3 - x \cdot 2\right)\right) \]

Derivation?

  1. Initial program 0.2

    \[\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right) \]
  2. Applied egg-rr6.3

    \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot \left(27 - {\left(x \cdot 2\right)}^{3}\right)}{9 + \left(\left(x \cdot x\right) \cdot 4 + 6 \cdot x\right)}} \]
  3. Simplified0.2

    \[\leadsto \color{blue}{\frac{27 - {x}^{3} \cdot 8}{9 + x \cdot \left(x \cdot 4 + 6\right)} \cdot \left(x \cdot x\right)} \]
    Proof

    [Start]6.3

    \[ \frac{\left(x \cdot x\right) \cdot \left(27 - {\left(x \cdot 2\right)}^{3}\right)}{9 + \left(\left(x \cdot x\right) \cdot 4 + 6 \cdot x\right)} \]

    *-commutative [<=]6.3

    \[ \frac{\color{blue}{\left(27 - {\left(x \cdot 2\right)}^{3}\right) \cdot \left(x \cdot x\right)}}{9 + \left(\left(x \cdot x\right) \cdot 4 + 6 \cdot x\right)} \]

    associate-*l/ [<=]0.2

    \[ \color{blue}{\frac{27 - {\left(x \cdot 2\right)}^{3}}{9 + \left(\left(x \cdot x\right) \cdot 4 + 6 \cdot x\right)} \cdot \left(x \cdot x\right)} \]

    cube-prod [=>]0.2

    \[ \frac{27 - \color{blue}{{x}^{3} \cdot {2}^{3}}}{9 + \left(\left(x \cdot x\right) \cdot 4 + 6 \cdot x\right)} \cdot \left(x \cdot x\right) \]

    metadata-eval [=>]0.2

    \[ \frac{27 - {x}^{3} \cdot \color{blue}{8}}{9 + \left(\left(x \cdot x\right) \cdot 4 + 6 \cdot x\right)} \cdot \left(x \cdot x\right) \]

    associate-*l* [=>]0.2

    \[ \frac{27 - {x}^{3} \cdot 8}{9 + \left(\color{blue}{x \cdot \left(x \cdot 4\right)} + 6 \cdot x\right)} \cdot \left(x \cdot x\right) \]

    *-commutative [=>]0.2

    \[ \frac{27 - {x}^{3} \cdot 8}{9 + \left(x \cdot \left(x \cdot 4\right) + \color{blue}{x \cdot 6}\right)} \cdot \left(x \cdot x\right) \]

    distribute-lft-out [=>]0.2

    \[ \frac{27 - {x}^{3} \cdot 8}{9 + \color{blue}{x \cdot \left(x \cdot 4 + 6\right)}} \cdot \left(x \cdot x\right) \]
  4. Final simplification0.2

    \[\leadsto \frac{27 - {x}^{3} \cdot 8}{9 + x \cdot \left(x \cdot 4 + 6\right)} \cdot \left(x \cdot x\right) \]

Alternatives

Alternative 1
Error2.2
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.5\right):\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot 3\right)\\ \end{array} \]
Alternative 2
Error0.2
Cost576
\[x \cdot \left(x \cdot \left(3 + x \cdot -2\right)\right) \]
Alternative 3
Error16.1
Cost320
\[3 \cdot \left(x \cdot x\right) \]
Alternative 4
Error16.1
Cost320
\[x \cdot \left(x \cdot 3\right) \]
Alternative 5
Error61.0
Cost192
\[x \cdot 4.5 \]

Error

Reproduce?

herbie shell --seed 2023054 
(FPCore (x)
  :name "Data.Spline.Key:interpolateKeys from smoothie-0.4.0.2"
  :precision binary64

  :herbie-target
  (* x (* x (- 3.0 (* x 2.0))))

  (* (* x x) (- 3.0 (* x 2.0))))