
(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 7 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) 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}
Initial program 99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (<= (* x x) 4e-7) -0.5 (* x (/ (- x) -6.0))))
double code(double x) {
double tmp;
if ((x * x) <= 4e-7) {
tmp = -0.5;
} else {
tmp = x * (-x / -6.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x * x) <= 4d-7) then
tmp = -0.5d0
else
tmp = x * (-x / (-6.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x * x) <= 4e-7) {
tmp = -0.5;
} else {
tmp = x * (-x / -6.0);
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 4e-7: tmp = -0.5 else: tmp = x * (-x / -6.0) return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 4e-7) tmp = -0.5; else tmp = Float64(x * Float64(Float64(-x) / -6.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 4e-7) tmp = -0.5; else tmp = x * (-x / -6.0); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 4e-7], -0.5, N[(x * N[((-x) / -6.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-7}:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-x}{-6}\\
\end{array}
\end{array}
if (*.f64 x x) < 3.9999999999999998e-7Initial program 100.0%
Taylor expanded in x around 0 99.6%
if 3.9999999999999998e-7 < (*.f64 x x) Initial program 99.8%
div-sub99.8%
associate-*r/99.8%
fma-neg99.8%
*-lft-identity99.8%
metadata-eval99.8%
associate-*r/99.8%
associate-/l*99.7%
associate-/r/99.7%
*-commutative99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
metadata-eval99.7%
metadata-eval99.7%
fma-neg99.7%
associate-*r*99.7%
metadata-eval99.7%
div-inv99.8%
div-sub99.8%
clear-num99.8%
clear-num99.8%
/-rgt-identity99.8%
fma-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 98.7%
unpow298.7%
Simplified98.7%
associate-/r*98.7%
clear-num98.7%
frac-2neg98.7%
associate-/r/98.7%
metadata-eval98.7%
Applied egg-rr98.7%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= (* x x) 4e-7) -0.5 (* (* x x) 0.16666666666666666)))
double code(double x) {
double tmp;
if ((x * x) <= 4e-7) {
tmp = -0.5;
} else {
tmp = (x * x) * 0.16666666666666666;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x * x) <= 4d-7) then
tmp = -0.5d0
else
tmp = (x * x) * 0.16666666666666666d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x * x) <= 4e-7) {
tmp = -0.5;
} else {
tmp = (x * x) * 0.16666666666666666;
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 4e-7: tmp = -0.5 else: tmp = (x * x) * 0.16666666666666666 return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 4e-7) tmp = -0.5; else tmp = Float64(Float64(x * x) * 0.16666666666666666); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 4e-7) tmp = -0.5; else tmp = (x * x) * 0.16666666666666666; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 4e-7], -0.5, N[(N[(x * x), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-7}:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot 0.16666666666666666\\
\end{array}
\end{array}
if (*.f64 x x) < 3.9999999999999998e-7Initial program 100.0%
Taylor expanded in x around 0 99.6%
if 3.9999999999999998e-7 < (*.f64 x x) Initial program 99.8%
Taylor expanded in x around inf 98.7%
unpow298.7%
Simplified98.7%
Final simplification99.1%
(FPCore (x) :precision binary64 (- (* x (* x 0.16666666666666666)) 0.5))
double code(double x) {
return (x * (x * 0.16666666666666666)) - 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * (x * 0.16666666666666666d0)) - 0.5d0
end function
public static double code(double x) {
return (x * (x * 0.16666666666666666)) - 0.5;
}
def code(x): return (x * (x * 0.16666666666666666)) - 0.5
function code(x) return Float64(Float64(x * Float64(x * 0.16666666666666666)) - 0.5) end
function tmp = code(x) tmp = (x * (x * 0.16666666666666666)) - 0.5; end
code[x_] := N[(N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot 0.16666666666666666\right) - 0.5
\end{array}
Initial program 99.9%
div-sub99.9%
div-inv99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= x 1.7) -0.5 9.0))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = -0.5;
} else {
tmp = 9.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.7d0) then
tmp = -0.5d0
else
tmp = 9.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = -0.5;
} else {
tmp = 9.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = -0.5 else: tmp = 9.0 return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = -0.5; else tmp = 9.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = -0.5; else tmp = 9.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], -0.5, 9.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;9\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial program 99.9%
Taylor expanded in x around 0 64.5%
if 1.69999999999999996 < x Initial program 99.8%
div-sub99.8%
associate-*r/99.8%
fma-neg99.8%
*-lft-identity99.8%
metadata-eval99.8%
associate-*r/99.8%
associate-/l*99.7%
associate-/r/99.7%
*-commutative99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
metadata-eval99.7%
metadata-eval99.7%
fma-neg99.7%
associate-*r*99.7%
metadata-eval99.7%
div-inv99.8%
div-sub99.8%
clear-num99.7%
clear-num99.7%
/-rgt-identity99.7%
fma-neg99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 97.8%
unpow297.8%
Simplified97.8%
associate-/r*97.7%
clear-num97.9%
frac-2neg97.9%
associate-/r/97.9%
metadata-eval97.9%
Applied egg-rr97.9%
Applied egg-rr5.0%
Final simplification47.6%
(FPCore (x) :precision binary64 (if (<= x 1.7) -0.5 216.0))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = -0.5;
} else {
tmp = 216.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.7d0) then
tmp = -0.5d0
else
tmp = 216.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = -0.5;
} else {
tmp = 216.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = -0.5 else: tmp = 216.0 return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = -0.5; else tmp = 216.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = -0.5; else tmp = 216.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], -0.5, 216.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;216\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial program 99.9%
Taylor expanded in x around 0 64.5%
if 1.69999999999999996 < x Initial program 99.8%
div-sub99.8%
associate-*r/99.8%
fma-neg99.8%
*-lft-identity99.8%
metadata-eval99.8%
associate-*r/99.8%
associate-/l*99.7%
associate-/r/99.7%
*-commutative99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
metadata-eval99.7%
metadata-eval99.7%
fma-neg99.7%
associate-*r*99.7%
metadata-eval99.7%
div-inv99.8%
div-sub99.8%
clear-num99.7%
clear-num99.7%
/-rgt-identity99.7%
fma-neg99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 97.8%
unpow297.8%
Simplified97.8%
associate-/r*97.7%
clear-num97.9%
frac-2neg97.9%
associate-/r/97.9%
metadata-eval97.9%
Applied egg-rr97.9%
Applied egg-rr5.0%
Final simplification47.5%
(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.9%
Taylor expanded in x around 0 46.4%
Final simplification46.4%
herbie shell --seed 2023297
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, H"
:precision binary64
(/ (- (* x x) 3.0) 6.0))