(FPCore (size) :precision binary64 (* (pow 2.0 (/ 1.0 4.0)) (sqrt (/ 1.0 (pow 2.0 size)))))
double code(double size) { return pow(2.0, (1.0 / 4.0)) * sqrt((1.0 / pow(2.0, size))); }
real(8) function code(size) real(8), intent (in) :: size code = (2.0d0 ** (1.0d0 / 4.0d0)) * sqrt((1.0d0 / (2.0d0 ** size))) end function
public static double code(double size) { return Math.pow(2.0, (1.0 / 4.0)) * Math.sqrt((1.0 / Math.pow(2.0, size))); }
def code(size): return math.pow(2.0, (1.0 / 4.0)) * math.sqrt((1.0 / math.pow(2.0, size)))
function code(size) return Float64((2.0 ^ Float64(1.0 / 4.0)) * sqrt(Float64(1.0 / (2.0 ^ size)))) end
function tmp = code(size) tmp = (2.0 ^ (1.0 / 4.0)) * sqrt((1.0 / (2.0 ^ size))); end
code[size_] := N[(N[Power[2.0, N[(1.0 / 4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(1.0 / N[Power[2.0, size], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ {2}^{\left(\frac{1}{4}\right)} \cdot \sqrt{\frac{1}{{2}^{size}}} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (size) :precision binary64 (* (pow 2.0 (/ 1.0 4.0)) (sqrt (/ 1.0 (pow 2.0 size)))))
double code(double size) { return pow(2.0, (1.0 / 4.0)) * sqrt((1.0 / pow(2.0, size))); }
real(8) function code(size) real(8), intent (in) :: size code = (2.0d0 ** (1.0d0 / 4.0d0)) * sqrt((1.0d0 / (2.0d0 ** size))) end function
public static double code(double size) { return Math.pow(2.0, (1.0 / 4.0)) * Math.sqrt((1.0 / Math.pow(2.0, size))); }
def code(size): return math.pow(2.0, (1.0 / 4.0)) * math.sqrt((1.0 / math.pow(2.0, size)))
function code(size) return Float64((2.0 ^ Float64(1.0 / 4.0)) * sqrt(Float64(1.0 / (2.0 ^ size)))) end
function tmp = code(size) tmp = (2.0 ^ (1.0 / 4.0)) * sqrt((1.0 / (2.0 ^ size))); end
code[size_] := N[(N[Power[2.0, N[(1.0 / 4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(1.0 / N[Power[2.0, size], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ {2}^{\left(\frac{1}{4}\right)} \cdot \sqrt{\frac{1}{{2}^{size}}} \end{array}
(FPCore (size) :precision binary64 (pow 2.0 (fma size -0.5 0.25)))
double code(double size) { return pow(2.0, fma(size, -0.5, 0.25)); }
function code(size) return 2.0 ^ fma(size, -0.5, 0.25) end
code[size_] := N[Power[2.0, N[(size * -0.5 + 0.25), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ {2}^{\left(\mathsf{fma}\left(size, -0.5, 0.25\right)\right)} \end{array}
Initial program 100.0%
lift-*.f64
N/A
*-commutative
N/A
lift-sqrt.f64
N/A
lift-/.f64
N/A
lift-pow.f64
N/A
pow-flip
N/A
sqrt-pow1
N/A
lift-pow.f64
N/A
pow-prod-up
N/A
lower-pow.f64
N/A
div-inv
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower-neg.f64
100.0
lift-/.f64
N/A
metadata-eval
100.0
Applied rewrites100.0%
metadata-eval
N/A
lift-fma.f64
N/A
lift-neg.f64
N/A
neg-mul-1
N/A
*-commutative
N/A
associate-*l*
N/A
lower-fma.f64
N/A
metadata-eval
N/A
metadata-eval
100.0
Applied rewrites100.0%
(FPCore (size) :precision binary64 (pow 2.0 0.25))
double code(double size) { return pow(2.0, 0.25); }
real(8) function code(size) real(8), intent (in) :: size code = 2.0d0 ** 0.25d0 end function
public static double code(double size) { return Math.pow(2.0, 0.25); }
def code(size): return math.pow(2.0, 0.25)
function code(size) return 2.0 ^ 0.25 end
function tmp = code(size) tmp = 2.0 ^ 0.25; end
code[size_] := N[Power[2.0, 0.25], $MachinePrecision]
\begin{array}{l} \\ {2}^{0.25} \end{array}
Initial program 100.0%
Taylor expanded in size around 0
lower-pow.f64
97.5
Applied rewrites97.5%
herbie shell --seed 1
(FPCore (size)
:name "pow(2, 1/4) * sqrt(1 / 2^size)"
:precision binary64
:pre (and (<= 0.0 size) (<= size 6.0))
(* (pow 2.0 (/ 1.0 4.0)) (sqrt (/ 1.0 (pow 2.0 size)))))