| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 1728 |
\[\begin{array}{l}
t_0 := x \cdot \left(x \cdot x\right)\\
\frac{t_0 \cdot 0.75 + \frac{x \cdot \left(\left(x \cdot x\right) \cdot 9\right)}{4}}{4} + \frac{t_0}{4}
\end{array}
\]
(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}
Results
| Original | 0.1 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 0.1
Taylor expanded in x around 0 0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 1728 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 320 |
herbie shell --seed 2023100
(FPCore (x)
:name "math.cube on real"
:precision binary64
:herbie-target
(pow x 3.0)
(* (* x x) x))