
(FPCore (x) :precision binary64 (* (* x 2.0) x))
double code(double x) {
return (x * 2.0) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 2.0d0) * x
end function
public static double code(double x) {
return (x * 2.0) * x;
}
def code(x): return (x * 2.0) * x
function code(x) return Float64(Float64(x * 2.0) * x) end
function tmp = code(x) tmp = (x * 2.0) * x; end
code[x_] := N[(N[(x * 2.0), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 2\right) \cdot x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (* x 2.0) x))
double code(double x) {
return (x * 2.0) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 2.0d0) * x
end function
public static double code(double x) {
return (x * 2.0) * x;
}
def code(x): return (x * 2.0) * x
function code(x) return Float64(Float64(x * 2.0) * x) end
function tmp = code(x) tmp = (x * 2.0) * x; end
code[x_] := N[(N[(x * 2.0), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 2\right) \cdot x
\end{array}
(FPCore (x) :precision binary64 (* (* x 2.0) x))
double code(double x) {
return (x * 2.0) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 2.0d0) * x
end function
public static double code(double x) {
return (x * 2.0) * x;
}
def code(x): return (x * 2.0) * x
function code(x) return Float64(Float64(x * 2.0) * x) end
function tmp = code(x) tmp = (x * 2.0) * x; end
code[x_] := N[(N[(x * 2.0), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 2\right) \cdot x
\end{array}
Initial program 100.0%
(FPCore (x) :precision binary64 (+ x x))
double code(double x) {
return x + x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x + x
end function
public static double code(double x) {
return x + x;
}
def code(x): return x + x
function code(x) return Float64(x + x) end
function tmp = code(x) tmp = x + x; end
code[x_] := N[(x + x), $MachinePrecision]
\begin{array}{l}
\\
x + x
\end{array}
Initial program 100.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
count-2-revN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
+-inversesN/A
flip-+N/A
lower-+.f644.9
Applied rewrites4.9%
(FPCore (x) :precision binary64 (* (* 2.0 x) x))
double code(double x) {
return (2.0 * x) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (2.0d0 * x) * x
end function
public static double code(double x) {
return (2.0 * x) * x;
}
def code(x): return (2.0 * x) * x
function code(x) return Float64(Float64(2.0 * x) * x) end
function tmp = code(x) tmp = (2.0 * x) * x; end
code[x_] := N[(N[(2.0 * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(2 \cdot x\right) \cdot x
\end{array}
herbie shell --seed 2024344
(FPCore (x)
:name "Numeric.Log:$cexpm1 from log-domain-0.10.2.1, A"
:precision binary64
:alt
(! :herbie-platform default (* (* 2 x) x))
(* (* x 2.0) x))