
(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 (- -0.5 (/ x (/ -6.0 x))))
double code(double x) {
return -0.5 - (x / (-6.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-0.5d0) - (x / ((-6.0d0) / x))
end function
public static double code(double x) {
return -0.5 - (x / (-6.0 / x));
}
def code(x): return -0.5 - (x / (-6.0 / x))
function code(x) return Float64(-0.5 - Float64(x / Float64(-6.0 / x))) end
function tmp = code(x) tmp = -0.5 - (x / (-6.0 / x)); end
code[x_] := N[(-0.5 - N[(x / N[(-6.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 - \frac{x}{\frac{-6}{x}}
\end{array}
Initial program 99.9%
flip3--N/A
clear-numN/A
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-evalN/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
sub-negN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-eval99.8%
Applied egg-rr99.8%
associate-/r/N/A
metadata-evalN/A
distribute-rgt-inN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
div-invN/A
associate-*l/N/A
associate-/r/N/A
frac-2negN/A
distribute-frac-negN/A
unsub-negN/A
--lowering--.f64N/A
metadata-evalN/A
/-lowering-/.f64N/A
distribute-neg-fracN/A
/-lowering-/.f64N/A
metadata-eval99.9%
Applied egg-rr99.9%
(FPCore (x) :precision binary64 (if (<= (* x x) 2e-13) -0.5 (/ x (/ 6.0 x))))
double code(double x) {
double tmp;
if ((x * x) <= 2e-13) {
tmp = -0.5;
} else {
tmp = x / (6.0 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x * x) <= 2d-13) then
tmp = -0.5d0
else
tmp = x / (6.0d0 / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x * x) <= 2e-13) {
tmp = -0.5;
} else {
tmp = x / (6.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 2e-13: tmp = -0.5 else: tmp = x / (6.0 / x) return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 2e-13) tmp = -0.5; else tmp = Float64(x / Float64(6.0 / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 2e-13) tmp = -0.5; else tmp = x / (6.0 / x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-13], -0.5, N[(x / N[(6.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-13}:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{6}{x}}\\
\end{array}
\end{array}
if (*.f64 x x) < 2.0000000000000001e-13Initial program 100.0%
Taylor expanded in x around 0
Simplified99.8%
if 2.0000000000000001e-13 < (*.f64 x x) Initial program 99.8%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f6498.7%
Simplified98.7%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.7%
Applied egg-rr98.7%
(FPCore (x) :precision binary64 (if (<= (* x x) 2e-13) -0.5 (* x (/ x 6.0))))
double code(double x) {
double tmp;
if ((x * x) <= 2e-13) {
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) <= 2d-13) 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) <= 2e-13) {
tmp = -0.5;
} else {
tmp = x * (x / 6.0);
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 2e-13: tmp = -0.5 else: tmp = x * (x / 6.0) return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 2e-13) tmp = -0.5; else tmp = Float64(x * Float64(x / 6.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 2e-13) tmp = -0.5; else tmp = x * (x / 6.0); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-13], -0.5, N[(x * N[(x / 6.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-13}:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{6}\\
\end{array}
\end{array}
if (*.f64 x x) < 2.0000000000000001e-13Initial program 100.0%
Taylor expanded in x around 0
Simplified99.8%
if 2.0000000000000001e-13 < (*.f64 x x) Initial program 99.8%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f6498.7%
Simplified98.7%
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f6498.7%
Applied egg-rr98.7%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (<= (* x x) 2e-13) -0.5 (* x (* x 0.16666666666666666))))
double code(double x) {
double tmp;
if ((x * x) <= 2e-13) {
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) <= 2d-13) 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) <= 2e-13) {
tmp = -0.5;
} else {
tmp = x * (x * 0.16666666666666666);
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 2e-13: tmp = -0.5 else: tmp = x * (x * 0.16666666666666666) return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 2e-13) tmp = -0.5; else tmp = Float64(x * Float64(x * 0.16666666666666666)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 2e-13) tmp = -0.5; else tmp = x * (x * 0.16666666666666666); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-13], -0.5, N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-13}:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot 0.16666666666666666\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2.0000000000000001e-13Initial program 100.0%
Taylor expanded in x around 0
Simplified99.8%
if 2.0000000000000001e-13 < (*.f64 x x) Initial program 99.8%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f6498.7%
Simplified98.7%
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f6498.7%
Applied egg-rr98.7%
div-invN/A
metadata-evalN/A
*-lowering-*.f6498.6%
Applied egg-rr98.6%
Final simplification99.2%
(FPCore (x) :precision binary64 (if (<= (* x x) 3.0) -0.5 (* (* x x) 0.16666666666666666)))
double code(double x) {
double tmp;
if ((x * x) <= 3.0) {
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) <= 3.0d0) 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) <= 3.0) {
tmp = -0.5;
} else {
tmp = (x * x) * 0.16666666666666666;
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 3.0: tmp = -0.5 else: tmp = (x * x) * 0.16666666666666666 return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 3.0) 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) <= 3.0) tmp = -0.5; else tmp = (x * x) * 0.16666666666666666; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 3.0], -0.5, N[(N[(x * x), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 3:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot 0.16666666666666666\\
\end{array}
\end{array}
if (*.f64 x x) < 3Initial program 100.0%
Taylor expanded in x around 0
Simplified99.8%
if 3 < (*.f64 x x) Initial program 99.8%
Taylor expanded in x around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.6%
Simplified98.6%
Final simplification99.2%
(FPCore (x) :precision binary64 (- -0.5 (* x (/ x -6.0))))
double code(double x) {
return -0.5 - (x * (x / -6.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-0.5d0) - (x * (x / (-6.0d0)))
end function
public static double code(double x) {
return -0.5 - (x * (x / -6.0));
}
def code(x): return -0.5 - (x * (x / -6.0))
function code(x) return Float64(-0.5 - Float64(x * Float64(x / -6.0))) end
function tmp = code(x) tmp = -0.5 - (x * (x / -6.0)); end
code[x_] := N[(-0.5 - N[(x * N[(x / -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 - x \cdot \frac{x}{-6}
\end{array}
Initial program 99.9%
flip3--N/A
clear-numN/A
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-evalN/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
sub-negN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-eval99.8%
Applied egg-rr99.8%
associate-/r/N/A
metadata-evalN/A
distribute-rgt-inN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
div-invN/A
associate-*l/N/A
associate-/r/N/A
frac-2negN/A
distribute-frac-negN/A
unsub-negN/A
--lowering--.f64N/A
metadata-evalN/A
/-lowering-/.f64N/A
distribute-neg-fracN/A
/-lowering-/.f64N/A
metadata-eval99.9%
Applied egg-rr99.9%
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f6499.9%
Applied egg-rr99.9%
Final simplification99.9%
(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
Simplified50.0%
herbie shell --seed 2024161
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, H"
:precision binary64
(/ (- (* x x) 3.0) 6.0))