(FPCore (x) :precision binary64 (- x (* 0.3 x)))
double code(double x) { return x - (0.3 * x); }
real(8) function code(x) real(8), intent (in) :: x code = x - (0.3d0 * x) end function
public static double code(double x) { return x - (0.3 * x); }
def code(x): return x - (0.3 * x)
function code(x) return Float64(x - Float64(0.3 * x)) end
function tmp = code(x) tmp = x - (0.3 * x); end
code[x_] := N[(x - N[(0.3 * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ x - 0.3 \cdot x \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (- x (* 0.3 x)))
double code(double x) { return x - (0.3 * x); }
real(8) function code(x) real(8), intent (in) :: x code = x - (0.3d0 * x) end function
public static double code(double x) { return x - (0.3 * x); }
def code(x): return x - (0.3 * x)
function code(x) return Float64(x - Float64(0.3 * x)) end
function tmp = code(x) tmp = x - (0.3 * x); end
code[x_] := N[(x - N[(0.3 * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ x - 0.3 \cdot x \end{array}
(FPCore (x) :precision binary64 (fma x -0.3 x))
double code(double x) { return fma(x, -0.3, x); }
function code(x) return fma(x, -0.3, x) end
code[x_] := N[(x * -0.3 + x), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(x, -0.3, x\right) \end{array}
Initial program 99.7%
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
lift-*.f64
N/A
*-commutative
N/A
distribute-rgt-neg-in
N/A
lower-fma.f64
N/A
metadata-eval
100.0
Applied rewrites100.0%
(FPCore (x) :precision binary64 (* x 0.7))
double code(double x) { return x * 0.7; }
real(8) function code(x) real(8), intent (in) :: x code = x * 0.7d0 end function
public static double code(double x) { return x * 0.7; }
def code(x): return x * 0.7
function code(x) return Float64(x * 0.7) end
function tmp = code(x) tmp = x * 0.7; end
code[x_] := N[(x * 0.7), $MachinePrecision]
\begin{array}{l} \\ x \cdot 0.7 \end{array}
Initial program 99.7%
lift--.f64
N/A
lift-*.f64
N/A
cancel-sign-sub-inv
N/A
distribute-rgt1-in
N/A
*-commutative
N/A
lower-*.f64
N/A
metadata-eval
N/A
metadata-eval
99.2
Applied rewrites99.2%
herbie shell --seed 1
(FPCore (x)
:name "x-0.3x"
:precision binary64
:pre (and (<= -1.0 x) (<= x 1.0))
(- x (* 0.3 x)))