
(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 52.7%
add-cube-cbrt51.8%
pow351.8%
associate-*l*51.7%
sqrt-prod51.7%
sqrt-unprod51.1%
add-sqr-sqrt52.2%
Applied egg-rr52.2%
rem-cube-cbrt53.0%
add-sqr-sqrt52.9%
associate-*l*52.9%
pow1/252.9%
sqrt-pow152.9%
metadata-eval52.9%
pow1/252.9%
sqrt-pow152.9%
metadata-eval52.9%
Applied egg-rr52.9%
associate-*r*52.9%
add-sqr-sqrt51.8%
associate-*r*51.8%
pow-prod-up51.8%
metadata-eval51.8%
pow1/251.8%
sqrt-prod52.1%
count-252.1%
pow1/252.1%
metadata-eval52.1%
pow-sqr51.8%
associate-*r*51.9%
add-sqr-sqrt51.7%
sqrt-unprod25.9%
Applied egg-rr52.7%
distribute-lft-in52.7%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
herbie shell --seed 2023278
(FPCore (x)
:name "sqrt B (should all be same)"
:precision binary64
(sqrt (* (* 2.0 x) x)))