(FPCore (x) :precision binary64 (pow 2.0 x))
double code(double x) { return pow(2.0, x); }
real(8) function code(x) real(8), intent (in) :: x code = 2.0d0 ** x end function
public static double code(double x) { return Math.pow(2.0, x); }
def code(x): return math.pow(2.0, x)
function code(x) return 2.0 ^ x end
function tmp = code(x) tmp = 2.0 ^ x; end
code[x_] := N[Power[2.0, x], $MachinePrecision]
\begin{array}{l} \\ {2}^{x} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (pow 2.0 x))
double code(double x) { return pow(2.0, x); }
real(8) function code(x) real(8), intent (in) :: x code = 2.0d0 ** x end function
public static double code(double x) { return Math.pow(2.0, x); }
def code(x): return math.pow(2.0, x)
function code(x) return 2.0 ^ x end
function tmp = code(x) tmp = 2.0 ^ x; end
code[x_] := N[Power[2.0, x], $MachinePrecision]
\begin{array}{l} \\ {2}^{x} \end{array}
(FPCore (x) :precision binary64 (pow 2.0 x))
double code(double x) { return pow(2.0, x); }
real(8) function code(x) real(8), intent (in) :: x code = 2.0d0 ** x end function
public static double code(double x) { return Math.pow(2.0, x); }
def code(x): return math.pow(2.0, x)
function code(x) return 2.0 ^ x end
function tmp = code(x) tmp = 2.0 ^ x; end
code[x_] := N[Power[2.0, x], $MachinePrecision]
\begin{array}{l} \\ {2}^{x} \end{array}
Initial program 100.0%
(FPCore (x) :precision binary64 1.0)
double code(double x) { return 1.0; }
real(8) function code(x) real(8), intent (in) :: x code = 1.0d0 end function
public static double code(double x) { return 1.0; }
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l} \\ 1 \end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites97.7%
herbie shell --seed 1
(FPCore (x)
:name "pow(2, x)"
:precision binary64
:pre (and (<= 0.0 x) (<= x 1.0))
(pow 2.0 x))