
(FPCore (x) :precision binary64 (sqrt (* (* 2.0 x) x)))
double code(double x) {
return sqrt(((2.0 * x) * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(((2.0d0 * x) * x))
end function
public static double code(double x) {
return Math.sqrt(((2.0 * x) * x));
}
def code(x): return math.sqrt(((2.0 * x) * x))
function code(x) return sqrt(Float64(Float64(2.0 * x) * x)) end
function tmp = code(x) tmp = sqrt(((2.0 * x) * x)); end
code[x_] := N[Sqrt[N[(N[(2.0 * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left(2 \cdot x\right) \cdot x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (sqrt (* (* 2.0 x) x)))
double code(double x) {
return sqrt(((2.0 * x) * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(((2.0d0 * x) * x))
end function
public static double code(double x) {
return Math.sqrt(((2.0 * x) * x));
}
def code(x): return math.sqrt(((2.0 * x) * x))
function code(x) return sqrt(Float64(Float64(2.0 * x) * x)) end
function tmp = code(x) tmp = sqrt(((2.0 * x) * x)); end
code[x_] := N[Sqrt[N[(N[(2.0 * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left(2 \cdot x\right) \cdot x}
\end{array}
(FPCore (x) :precision binary64 (hypot x x))
double code(double x) {
return hypot(x, x);
}
public static double code(double x) {
return Math.hypot(x, x);
}
def code(x): return math.hypot(x, x)
function code(x) return hypot(x, x) end
function tmp = code(x) tmp = hypot(x, x); end
code[x_] := N[Sqrt[x ^ 2 + x ^ 2], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(x, x\right)
\end{array}
Initial program 53.0%
add-exp-log49.3%
associate-*l*49.2%
sqrt-prod49.2%
sqrt-unprod41.0%
add-sqr-sqrt41.0%
Applied egg-rr41.0%
add-exp-log45.8%
add-sqr-sqrt45.7%
associate-*l*45.8%
pow1/245.8%
sqrt-pow145.8%
metadata-eval45.8%
pow1/245.8%
sqrt-pow145.8%
metadata-eval45.8%
Applied egg-rr45.8%
add-sqr-sqrt44.4%
sqrt-unprod52.8%
associate-*r*52.7%
associate-*r*52.7%
swap-sqr52.6%
pow-prod-up53.0%
metadata-eval53.0%
pow1/253.0%
pow-prod-up52.5%
metadata-eval52.5%
pow1/252.5%
add-sqr-sqrt53.0%
Applied egg-rr53.0%
associate-*r*53.0%
count-253.0%
*-commutative53.0%
distribute-lft-in53.0%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
herbie shell --seed 2023274
(FPCore (x)
:name "sqrt B (should all be same)"
:precision binary64
(sqrt (* (* 2.0 x) x)))