
(FPCore (x) :precision binary64 (pow 2.0 (- 1.0 x)))
double code(double x) {
return pow(2.0, (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 ** (1.0d0 - x)
end function
public static double code(double x) {
return Math.pow(2.0, (1.0 - x));
}
def code(x): return math.pow(2.0, (1.0 - x))
function code(x) return 2.0 ^ Float64(1.0 - x) end
function tmp = code(x) tmp = 2.0 ^ (1.0 - x); end
code[x_] := N[Power[2.0, N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
{2}^{\left(1 - x\right)}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (pow 2.0 (- 1.0 x)))
double code(double x) {
return pow(2.0, (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 ** (1.0d0 - x)
end function
public static double code(double x) {
return Math.pow(2.0, (1.0 - x));
}
def code(x): return math.pow(2.0, (1.0 - x))
function code(x) return 2.0 ^ Float64(1.0 - x) end
function tmp = code(x) tmp = 2.0 ^ (1.0 - x); end
code[x_] := N[Power[2.0, N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
{2}^{\left(1 - x\right)}
(FPCore (x) :precision binary64 (* (pow 2.0 (- x)) 2.0))
double code(double x) {
return pow(2.0, -x) * 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (2.0d0 ** -x) * 2.0d0
end function
public static double code(double x) {
return Math.pow(2.0, -x) * 2.0;
}
def code(x): return math.pow(2.0, -x) * 2.0
function code(x) return Float64((2.0 ^ Float64(-x)) * 2.0) end
function tmp = code(x) tmp = (2.0 ^ -x) * 2.0; end
code[x_] := N[(N[Power[2.0, (-x)], $MachinePrecision] * 2.0), $MachinePrecision]
{2}^{\left(-x\right)} \cdot 2
Initial program 100.0%
lift-pow.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
pow-plus-revN/A
lower-unsound-*.f64N/A
lower-unsound-pow.f64N/A
lower-neg.f64100.0%
Applied rewrites100.0%
(FPCore (x) :precision binary64 (/ (* (fma -1.3862943611198906 x 2.0) E) E))
double code(double x) {
return (fma(-1.3862943611198906, x, 2.0) * ((double) M_E)) / ((double) M_E);
}
function code(x) return Float64(Float64(fma(-1.3862943611198906, x, 2.0) * exp(1)) / exp(1)) end
code[x_] := N[(N[(N[(-1.3862943611198906 * x + 2.0), $MachinePrecision] * E), $MachinePrecision] / E), $MachinePrecision]
\frac{\mathsf{fma}\left(-1.3862943611198906, x, 2\right) \cdot e}{e}
Initial program 100.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f6498.7%
Applied rewrites98.7%
Evaluated real constant98.7%
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
associate-+r+N/A
*-inversesN/A
add-to-fractionN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
exp-1-eN/A
lower-E.f64N/A
exp-1-eN/A
lower-E.f64N/A
exp-1-eN/A
lower-E.f6498.6%
Applied rewrites98.6%
lift-fma.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
sub-flipN/A
lift-fma.f64N/A
associate--l+N/A
metadata-evalN/A
lift-fma.f64N/A
lower-*.f6498.6%
Applied rewrites98.6%
(FPCore (x) :precision binary64 (fma x -1.3862943611198906 2.0))
double code(double x) {
return fma(x, -1.3862943611198906, 2.0);
}
function code(x) return fma(x, -1.3862943611198906, 2.0) end
code[x_] := N[(x * -1.3862943611198906 + 2.0), $MachinePrecision]
\mathsf{fma}\left(x, -1.3862943611198906, 2\right)
Initial program 100.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f6498.7%
Applied rewrites98.7%
Evaluated real constant98.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
metadata-eval98.7%
Applied rewrites98.7%
(FPCore (x) :precision binary64 2.0)
double code(double x) {
return 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0
end function
public static double code(double x) {
return 2.0;
}
def code(x): return 2.0
function code(x) return 2.0 end
function tmp = code(x) tmp = 2.0; end
code[x_] := 2.0
2
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites97.5%
herbie shell --seed 1
(FPCore (x)
:name "2^(1-x)"
:precision binary64
:pre (and (<= -1000.0 x) (<= x 2.0))
(pow 2.0 (- 1.0 x)))