
(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 2 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}
(FPCore (x) :precision binary64 (- (* x (/ x 6.0)) 0.5))
double code(double x) {
return (x * (x / 6.0)) - 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * (x / 6.0d0)) - 0.5d0
end function
public static double code(double x) {
return (x * (x / 6.0)) - 0.5;
}
def code(x): return (x * (x / 6.0)) - 0.5
function code(x) return Float64(Float64(x * Float64(x / 6.0)) - 0.5) end
function tmp = code(x) tmp = (x * (x / 6.0)) - 0.5; end
code[x_] := N[(N[(x * N[(x / 6.0), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{x}{6} - 0.5
\end{array}
Initial program 99.6%
sqr-neg99.6%
*-lft-identity99.6%
metadata-eval99.6%
associate-*r/99.6%
associate-/l*99.5%
associate-/r/99.6%
*-commutative99.6%
sqr-neg99.6%
fma-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
metadata-eval99.6%
fma-neg99.6%
metadata-eval99.6%
div-inv99.6%
div-sub99.6%
div-inv99.6%
pow299.6%
metadata-eval99.6%
metadata-eval99.6%
Applied egg-rr99.6%
rem-exp-log99.4%
add-cube-cbrt99.2%
pow399.2%
rem-exp-log99.3%
Applied egg-rr99.3%
rem-cube-cbrt99.6%
metadata-eval99.6%
div-inv99.6%
unpow299.6%
associate-/l*99.9%
Applied egg-rr99.9%
associate-/r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 -0.5)
double code(double x) {
return -0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -0.5d0
end function
public static double code(double x) {
return -0.5;
}
def code(x): return -0.5
function code(x) return -0.5 end
function tmp = code(x) tmp = -0.5; end
code[x_] := -0.5
\begin{array}{l}
\\
-0.5
\end{array}
Initial program 99.6%
sqr-neg99.6%
*-lft-identity99.6%
metadata-eval99.6%
associate-*r/99.6%
associate-/l*99.5%
associate-/r/99.6%
*-commutative99.6%
sqr-neg99.6%
fma-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 52.3%
Final simplification52.3%
herbie shell --seed 2024021
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, H"
:precision binary64
(/ (- (* x x) 3.0) 6.0))