(FPCore (x) :precision binary64 (sin (+ x 0.001)))
double code(double x) { return sin((x + 0.001)); }
real(8) function code(x) real(8), intent (in) :: x code = sin((x + 0.001d0)) end function
public static double code(double x) { return Math.sin((x + 0.001)); }
def code(x): return math.sin((x + 0.001))
function code(x) return sin(Float64(x + 0.001)) end
function tmp = code(x) tmp = sin((x + 0.001)); end
code[x_] := N[Sin[N[(x + 0.001), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sin \left(x + 0.001\right) \end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (sin (+ x 0.001)))
double code(double x) { return sin((x + 0.001)); }
real(8) function code(x) real(8), intent (in) :: x code = sin((x + 0.001d0)) end function
public static double code(double x) { return Math.sin((x + 0.001)); }
def code(x): return math.sin((x + 0.001))
function code(x) return sin(Float64(x + 0.001)) end
function tmp = code(x) tmp = sin((x + 0.001)); end
code[x_] := N[Sin[N[(x + 0.001), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sin \left(x + 0.001\right) \end{array}
(FPCore (x) :precision binary64 (fma (cos 0.001) x (sin 0.001)))
double code(double x) { return fma(cos(0.001), x, sin(0.001)); }
function code(x) return fma(cos(0.001), x, sin(0.001)) end
code[x_] := N[(N[Cos[0.001], $MachinePrecision] * x + N[Sin[0.001], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\cos 0.001, x, \sin 0.001\right) \end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
lower-cos.f64
N/A
lower-sin.f64
100.0
Applied rewrites100.0%
(FPCore (x) :precision binary64 (sin (+ x 0.001)))
double code(double x) { return sin((x + 0.001)); }
real(8) function code(x) real(8), intent (in) :: x code = sin((x + 0.001d0)) end function
public static double code(double x) { return Math.sin((x + 0.001)); }
def code(x): return math.sin((x + 0.001))
function code(x) return sin(Float64(x + 0.001)) end
function tmp = code(x) tmp = sin((x + 0.001)); end
code[x_] := N[Sin[N[(x + 0.001), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sin \left(x + 0.001\right) \end{array}
Initial program 100.0%
(FPCore (x) :precision binary64 (sin 0.001))
double code(double x) { return sin(0.001); }
real(8) function code(x) real(8), intent (in) :: x code = sin(0.001d0) end function
public static double code(double x) { return Math.sin(0.001); }
def code(x): return math.sin(0.001)
function code(x) return sin(0.001) end
function tmp = code(x) tmp = sin(0.001); end
code[x_] := N[Sin[0.001], $MachinePrecision]
\begin{array}{l} \\ \sin 0.001 \end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites99.3%
herbie shell --seed 1
(FPCore (x)
:name "sin(x+0.001)"
:precision binary64
:pre (and (<= -1e-9 x) (<= x 0.0))
(sin (+ x 0.001)))