
(FPCore (x) :precision binary64 (* (* x x) x))
double code(double x) {
return (x * x) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * x
end function
public static double code(double x) {
return (x * x) * x;
}
def code(x): return (x * x) * x
function code(x) return Float64(Float64(x * x) * x) end
function tmp = code(x) tmp = (x * x) * x; end
code[x_] := N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (* x x) x))
double code(double x) {
return (x * x) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * x
end function
public static double code(double x) {
return (x * x) * x;
}
def code(x): return (x * x) * x
function code(x) return Float64(Float64(x * x) * x) end
function tmp = code(x) tmp = (x * x) * x; end
code[x_] := N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot x
\end{array}
(FPCore (x) :precision binary64 (pow x 3.0))
double code(double x) {
return pow(x, 3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** 3.0d0
end function
public static double code(double x) {
return Math.pow(x, 3.0);
}
def code(x): return math.pow(x, 3.0)
function code(x) return x ^ 3.0 end
function tmp = code(x) tmp = x ^ 3.0; end
code[x_] := N[Power[x, 3.0], $MachinePrecision]
\begin{array}{l}
\\
{x}^{3}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (* x (* x x)))
double code(double x) {
return x * (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (x * x)
end function
public static double code(double x) {
return x * (x * x);
}
def code(x): return x * (x * x)
function code(x) return Float64(x * Float64(x * x)) end
function tmp = code(x) tmp = x * (x * x); end
code[x_] := N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot x\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (pow x 3.0))
double code(double x) {
return pow(x, 3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** 3.0d0
end function
public static double code(double x) {
return Math.pow(x, 3.0);
}
def code(x): return math.pow(x, 3.0)
function code(x) return x ^ 3.0 end
function tmp = code(x) tmp = x ^ 3.0; end
code[x_] := N[Power[x, 3.0], $MachinePrecision]
\begin{array}{l}
\\
{x}^{3}
\end{array}
herbie shell --seed 2023174
(FPCore (x)
:name "math.cube on real"
:precision binary64
:herbie-target
(pow x 3.0)
(* (* x x) x))