
(FPCore (x) :precision binary64 (/ (- (* x x) 3.0) 6.0))
double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * x) - 3.0d0) / 6.0d0
end function
public static double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
def code(x): return ((x * x) - 3.0) / 6.0
function code(x) return Float64(Float64(Float64(x * x) - 3.0) / 6.0) end
function tmp = code(x) tmp = ((x * x) - 3.0) / 6.0; end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] - 3.0), $MachinePrecision] / 6.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot x - 3}{6}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (- (* x x) 3.0) 6.0))
double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * x) - 3.0d0) / 6.0d0
end function
public static double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
def code(x): return ((x * x) - 3.0) / 6.0
function code(x) return Float64(Float64(Float64(x * x) - 3.0) / 6.0) end
function tmp = code(x) tmp = ((x * x) - 3.0) / 6.0; end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] - 3.0), $MachinePrecision] / 6.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot x - 3}{6}
\end{array}
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (/ (- (* x x) 3.0) 6.0))
x = abs(x);
double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * x) - 3.0d0) / 6.0d0
end function
x = Math.abs(x);
public static double code(double x) {
return ((x * x) - 3.0) / 6.0;
}
x = abs(x) def code(x): return ((x * x) - 3.0) / 6.0
x = abs(x) function code(x) return Float64(Float64(Float64(x * x) - 3.0) / 6.0) end
x = abs(x) function tmp = code(x) tmp = ((x * x) - 3.0) / 6.0; end
NOTE: x should be positive before calling this function code[x_] := N[(N[(N[(x * x), $MachinePrecision] - 3.0), $MachinePrecision] / 6.0), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\frac{x \cdot x - 3}{6}
\end{array}
Initial program 99.9%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (/ (fma x x -3.0) 6.0))
x = abs(x);
double code(double x) {
return fma(x, x, -3.0) / 6.0;
}
x = abs(x) function code(x) return Float64(fma(x, x, -3.0) / 6.0) end
NOTE: x should be positive before calling this function code[x_] := N[(N[(x * x + -3.0), $MachinePrecision] / 6.0), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\frac{\mathsf{fma}\left(x, x, -3\right)}{6}
\end{array}
Initial program 99.9%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (fma 0.16666666666666666 (* x x) -0.5))
x = abs(x);
double code(double x) {
return fma(0.16666666666666666, (x * x), -0.5);
}
x = abs(x) function code(x) return fma(0.16666666666666666, Float64(x * x), -0.5) end
NOTE: x should be positive before calling this function code[x_] := N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + -0.5), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.5\right)
\end{array}
Initial program 99.9%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (fma (* x x) 0.16666666666666666 -0.5))
x = abs(x);
double code(double x) {
return fma((x * x), 0.16666666666666666, -0.5);
}
x = abs(x) function code(x) return fma(Float64(x * x), 0.16666666666666666, -0.5) end
NOTE: x should be positive before calling this function code[x_] := N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + -0.5), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\mathsf{fma}\left(x \cdot x, 0.16666666666666666, -0.5\right)
\end{array}
Initial program 99.9%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (* 0.16666666666666666 (fma x x -3.0)))
x = abs(x);
double code(double x) {
return 0.16666666666666666 * fma(x, x, -3.0);
}
x = abs(x) function code(x) return Float64(0.16666666666666666 * fma(x, x, -3.0)) end
NOTE: x should be positive before calling this function code[x_] := N[(0.16666666666666666 * N[(x * x + -3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
0.16666666666666666 \cdot \mathsf{fma}\left(x, x, -3\right)
\end{array}
Initial program 99.9%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (* (fma x x -3.0) 0.16666666666666666))
x = abs(x);
double code(double x) {
return fma(x, x, -3.0) * 0.16666666666666666;
}
x = abs(x) function code(x) return Float64(fma(x, x, -3.0) * 0.16666666666666666) end
NOTE: x should be positive before calling this function code[x_] := N[(N[(x * x + -3.0), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\mathsf{fma}\left(x, x, -3\right) \cdot 0.16666666666666666
\end{array}
Initial program 99.9%
herbie shell --seed 2023276
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, H"
:precision binary64
(/ (- (* x x) 3.0) 6.0))