math.cube on real

?

Percentage Accurate: 99.9% → 100.0%
Time: 1.8s
Precision: binary64
Cost: 6528

?

\[\left(x \cdot x\right) \cdot x \]
\[{x}^{3} \]
(FPCore (x) :precision binary64 (* (* x x) x))
(FPCore (x) :precision binary64 (pow x 3.0))
double code(double x) {
	return (x * x) * x;
}
double code(double x) {
	return pow(x, 3.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x * x) * x
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = x ** 3.0d0
end function
public static double code(double x) {
	return (x * x) * x;
}
public static double code(double x) {
	return Math.pow(x, 3.0);
}
def code(x):
	return (x * x) * x
def code(x):
	return math.pow(x, 3.0)
function code(x)
	return Float64(Float64(x * x) * x)
end
function code(x)
	return x ^ 3.0
end
function tmp = code(x)
	tmp = (x * x) * x;
end
function tmp = code(x)
	tmp = x ^ 3.0;
end
code[x_] := N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]
code[x_] := N[Power[x, 3.0], $MachinePrecision]
\left(x \cdot x\right) \cdot x
{x}^{3}

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original99.9%
Target100.0%
Herbie100.0%
\[{x}^{3} \]

Derivation?

  1. Initial program 99.8%

    \[\left(x \cdot x\right) \cdot x \]
  2. Simplified100.0%

    \[\leadsto \color{blue}{{x}^{3}} \]
    Step-by-step derivation

    [Start]99.8

    \[ \left(x \cdot x\right) \cdot x \]

    unpow3 [<=]100.0

    \[ \color{blue}{{x}^{3}} \]
  3. Final simplification100.0%

    \[\leadsto {x}^{3} \]

Alternatives

Alternative 1
Accuracy99.9%
Cost320
\[x \cdot \left(x \cdot x\right) \]

Error

Reproduce?

herbie shell --seed 2023160 
(FPCore (x)
  :name "math.cube on real"
  :precision binary64

  :herbie-target
  (pow x 3.0)

  (* (* x x) x))