(FPCore (a b c d) :precision binary64 (* (/ (pow 2.0 a) (pow 2.0 b)) (/ c (pow 2.0 d))))
double code(double a, double b, double c, double d) { return (pow(2.0, a) / pow(2.0, b)) * (c / pow(2.0, d)); }
real(8) function code(a, b, c, d) real(8), intent (in) :: a real(8), intent (in) :: b real(8), intent (in) :: c real(8), intent (in) :: d code = ((2.0d0 ** a) / (2.0d0 ** b)) * (c / (2.0d0 ** d)) end function
public static double code(double a, double b, double c, double d) { return (Math.pow(2.0, a) / Math.pow(2.0, b)) * (c / Math.pow(2.0, d)); }
def code(a, b, c, d): return (math.pow(2.0, a) / math.pow(2.0, b)) * (c / math.pow(2.0, d))
function code(a, b, c, d) return Float64(Float64((2.0 ^ a) / (2.0 ^ b)) * Float64(c / (2.0 ^ d))) end
function tmp = code(a, b, c, d) tmp = ((2.0 ^ a) / (2.0 ^ b)) * (c / (2.0 ^ d)); end
code[a_, b_, c_, d_] := N[(N[(N[Power[2.0, a], $MachinePrecision] / N[Power[2.0, b], $MachinePrecision]), $MachinePrecision] * N[(c / N[Power[2.0, d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{{2}^{a}}{{2}^{b}} \cdot \frac{c}{{2}^{d}} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (a b c d) :precision binary64 (* (/ (pow 2.0 a) (pow 2.0 b)) (/ c (pow 2.0 d))))
double code(double a, double b, double c, double d) { return (pow(2.0, a) / pow(2.0, b)) * (c / pow(2.0, d)); }
real(8) function code(a, b, c, d) real(8), intent (in) :: a real(8), intent (in) :: b real(8), intent (in) :: c real(8), intent (in) :: d code = ((2.0d0 ** a) / (2.0d0 ** b)) * (c / (2.0d0 ** d)) end function
public static double code(double a, double b, double c, double d) { return (Math.pow(2.0, a) / Math.pow(2.0, b)) * (c / Math.pow(2.0, d)); }
def code(a, b, c, d): return (math.pow(2.0, a) / math.pow(2.0, b)) * (c / math.pow(2.0, d))
function code(a, b, c, d) return Float64(Float64((2.0 ^ a) / (2.0 ^ b)) * Float64(c / (2.0 ^ d))) end
function tmp = code(a, b, c, d) tmp = ((2.0 ^ a) / (2.0 ^ b)) * (c / (2.0 ^ d)); end
code[a_, b_, c_, d_] := N[(N[(N[Power[2.0, a], $MachinePrecision] / N[Power[2.0, b], $MachinePrecision]), $MachinePrecision] * N[(c / N[Power[2.0, d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{{2}^{a}}{{2}^{b}} \cdot \frac{c}{{2}^{d}} \end{array}
(FPCore (a b c d) :precision binary64 (* (pow 0.5 (+ b d)) (* c (pow 2.0 a))))
double code(double a, double b, double c, double d) { return pow(0.5, (b + d)) * (c * pow(2.0, a)); }
real(8) function code(a, b, c, d) real(8), intent (in) :: a real(8), intent (in) :: b real(8), intent (in) :: c real(8), intent (in) :: d code = (0.5d0 ** (b + d)) * (c * (2.0d0 ** a)) end function
public static double code(double a, double b, double c, double d) { return Math.pow(0.5, (b + d)) * (c * Math.pow(2.0, a)); }
def code(a, b, c, d): return math.pow(0.5, (b + d)) * (c * math.pow(2.0, a))
function code(a, b, c, d) return Float64((0.5 ^ Float64(b + d)) * Float64(c * (2.0 ^ a))) end
function tmp = code(a, b, c, d) tmp = (0.5 ^ (b + d)) * (c * (2.0 ^ a)); end
code[a_, b_, c_, d_] := N[(N[Power[0.5, N[(b + d), $MachinePrecision]], $MachinePrecision] * N[(c * N[Power[2.0, a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ {0.5}^{\left(b + d\right)} \cdot \left(c \cdot {2}^{a}\right) \end{array}
Initial program 99.9%
lift-*.f64
N/A
lift-/.f64
N/A
lift-/.f64
N/A
frac-times
N/A
clear-num
N/A
associate-/r/
N/A
lower-*.f64
N/A
*-commutative
N/A
associate-/r*
N/A
lift-pow.f64
N/A
pow-flip
N/A
lift-pow.f64
N/A
pow-div
N/A
lower-pow.f64
N/A
lower--.f64
N/A
lower-neg.f64
N/A
*-commutative
N/A
lower-*.f64
100.0
Applied rewrites100.0%
Taylor expanded in b around -inf
sub-neg
N/A
mul-1-neg
N/A
distribute-neg-in
N/A
distribute-rgt-neg-in
N/A
mul-1-neg
N/A
associate-*r*
N/A
exp-prod
N/A
mul-1-neg
N/A
exp-neg
N/A
rem-exp-log
N/A
metadata-eval
N/A
lower-pow.f64
N/A
lower-+.f64
100.0
Applied rewrites100.0%
(FPCore (a b c d) :precision binary64 (* (pow 2.0 (- (- a b) d)) c))
double code(double a, double b, double c, double d) { return pow(2.0, ((a - b) - d)) * c; }
real(8) function code(a, b, c, d) real(8), intent (in) :: a real(8), intent (in) :: b real(8), intent (in) :: c real(8), intent (in) :: d code = (2.0d0 ** ((a - b) - d)) * c end function
public static double code(double a, double b, double c, double d) { return Math.pow(2.0, ((a - b) - d)) * c; }
def code(a, b, c, d): return math.pow(2.0, ((a - b) - d)) * c
function code(a, b, c, d) return Float64((2.0 ^ Float64(Float64(a - b) - d)) * c) end
function tmp = code(a, b, c, d) tmp = (2.0 ^ ((a - b) - d)) * c; end
code[a_, b_, c_, d_] := N[(N[Power[2.0, N[(N[(a - b), $MachinePrecision] - d), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l} \\ {2}^{\left(\left(a - b\right) - d\right)} \cdot c \end{array}
Initial program 99.9%
lift-*.f64
N/A
*-commutative
N/A
lift-/.f64
N/A
div-inv
N/A
associate-*l*
N/A
*-commutative
N/A
lower-*.f64
N/A
associate-*l/
N/A
*-lft-identity
N/A
lift-/.f64
N/A
lift-pow.f64
N/A
lift-pow.f64
N/A
pow-div
N/A
lift-pow.f64
N/A
pow-div
N/A
lower-pow.f64
N/A
lower--.f64
N/A
lower--.f64
99.9
Applied rewrites99.9%
(FPCore (a b c d) :precision binary64 (* (pow 2.0 (- a d)) c))
double code(double a, double b, double c, double d) { return pow(2.0, (a - d)) * c; }
real(8) function code(a, b, c, d) real(8), intent (in) :: a real(8), intent (in) :: b real(8), intent (in) :: c real(8), intent (in) :: d code = (2.0d0 ** (a - d)) * c end function
public static double code(double a, double b, double c, double d) { return Math.pow(2.0, (a - d)) * c; }
def code(a, b, c, d): return math.pow(2.0, (a - d)) * c
function code(a, b, c, d) return Float64((2.0 ^ Float64(a - d)) * c) end
function tmp = code(a, b, c, d) tmp = (2.0 ^ (a - d)) * c; end
code[a_, b_, c_, d_] := N[(N[Power[2.0, N[(a - d), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l} \\ {2}^{\left(a - d\right)} \cdot c \end{array}
Initial program 99.9%
lift-*.f64
N/A
*-commutative
N/A
lift-/.f64
N/A
div-inv
N/A
associate-*l*
N/A
*-commutative
N/A
lower-*.f64
N/A
associate-*l/
N/A
*-lft-identity
N/A
lift-/.f64
N/A
lift-pow.f64
N/A
lift-pow.f64
N/A
pow-div
N/A
lift-pow.f64
N/A
pow-div
N/A
lower-pow.f64
N/A
lower--.f64
N/A
lower--.f64
99.9
Applied rewrites99.9%
Taylor expanded in b around 0
lower--.f64
98.2
Applied rewrites98.2%
herbie shell --seed 1
(FPCore (a b c d)
:name "(pow(2, a) / pow(2,b)) * (c / pow(2,d))"
:precision binary64
:pre (and (and (and (and (<= -1000.0 a) (<= a 1000.0)) (and (<= 0.0 b) (<= b 1000.0))) (and (<= -1000.0 c) (<= c 1000.0))) (and (<= 0.0 d) (<= d 1000.0)))
(* (/ (pow 2.0 a) (pow 2.0 b)) (/ c (pow 2.0 d))))