(FPCore (x) :precision binary64 (- (* x 0.97) (/ 0.35 2.0)))
double code(double x) { return (x * 0.97) - (0.35 / 2.0); }
real(8) function code(x) real(8), intent (in) :: x code = (x * 0.97d0) - (0.35d0 / 2.0d0) end function
public static double code(double x) { return (x * 0.97) - (0.35 / 2.0); }
def code(x): return (x * 0.97) - (0.35 / 2.0)
function code(x) return Float64(Float64(x * 0.97) - Float64(0.35 / 2.0)) end
function tmp = code(x) tmp = (x * 0.97) - (0.35 / 2.0); end
code[x_] := N[(N[(x * 0.97), $MachinePrecision] - N[(0.35 / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ x \cdot 0.97 - \frac{0.35}{2} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (- (* x 0.97) (/ 0.35 2.0)))
double code(double x) { return (x * 0.97) - (0.35 / 2.0); }
real(8) function code(x) real(8), intent (in) :: x code = (x * 0.97d0) - (0.35d0 / 2.0d0) end function
public static double code(double x) { return (x * 0.97) - (0.35 / 2.0); }
def code(x): return (x * 0.97) - (0.35 / 2.0)
function code(x) return Float64(Float64(x * 0.97) - Float64(0.35 / 2.0)) end
function tmp = code(x) tmp = (x * 0.97) - (0.35 / 2.0); end
code[x_] := N[(N[(x * 0.97), $MachinePrecision] - N[(0.35 / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ x \cdot 0.97 - \frac{0.35}{2} \end{array}
(FPCore (x) :precision binary64 (fma x 0.97 -0.175))
double code(double x) { return fma(x, 0.97, -0.175); }
function code(x) return fma(x, 0.97, -0.175) end
code[x_] := N[(x * 0.97 + -0.175), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(x, 0.97, -0.175\right) \end{array}
Initial program 100.0%
sub-neg
N/A
accelerator-lowering-fma.f64
N/A
metadata-eval
N/A
metadata-eval
100.0
Applied egg-rr100.0%
(FPCore (x) :precision binary64 -0.175)
double code(double x) { return -0.175; }
real(8) function code(x) real(8), intent (in) :: x code = -0.175d0 end function
public static double code(double x) { return -0.175; }
def code(x): return -0.175
function code(x) return -0.175 end
function tmp = code(x) tmp = -0.175; end
code[x_] := -0.175
\begin{array}{l} \\ -0.175 \end{array}
Initial program 100.0%
Taylor expanded in x around 0
Simplified96.4%
herbie shell --seed 5
(FPCore (x)
:name "(x * 0.97) - 0.35/2"
:precision binary64
:pre (and (<= 0.0 x) (<= x 1000.0))
(- (* x 0.97) (/ 0.35 2.0)))