Average Error: 0.2 → 0.1
Time: 11.4s
Precision: binary64
Cost: 580
\[\frac{x \cdot x - 3}{6} \]
\[\begin{array}{l} \mathbf{if}\;x \ne 0:\\ \;\;\;\;\frac{x}{\frac{6}{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot 0.16666666666666666\\ \end{array} - 0.5 \]
(FPCore (x) :precision binary64 (/ (- (* x x) 3.0) 6.0))
(FPCore (x)
 :precision binary64
 (- (if (!= x 0.0) (/ x (/ 6.0 x)) (* (* x x) 0.16666666666666666)) 0.5))
double code(double x) {
	return ((x * x) - 3.0) / 6.0;
}
double code(double x) {
	double tmp;
	if (x != 0.0) {
		tmp = x / (6.0 / x);
	} else {
		tmp = (x * x) * 0.16666666666666666;
	}
	return tmp - 0.5;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((x * x) - 3.0d0) / 6.0d0
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x /= 0.0d0) then
        tmp = x / (6.0d0 / x)
    else
        tmp = (x * x) * 0.16666666666666666d0
    end if
    code = tmp - 0.5d0
end function
public static double code(double x) {
	return ((x * x) - 3.0) / 6.0;
}
public static double code(double x) {
	double tmp;
	if (x != 0.0) {
		tmp = x / (6.0 / x);
	} else {
		tmp = (x * x) * 0.16666666666666666;
	}
	return tmp - 0.5;
}
def code(x):
	return ((x * x) - 3.0) / 6.0
def code(x):
	tmp = 0
	if x != 0.0:
		tmp = x / (6.0 / x)
	else:
		tmp = (x * x) * 0.16666666666666666
	return tmp - 0.5
function code(x)
	return Float64(Float64(Float64(x * x) - 3.0) / 6.0)
end
function code(x)
	tmp = 0.0
	if (x != 0.0)
		tmp = Float64(x / Float64(6.0 / x));
	else
		tmp = Float64(Float64(x * x) * 0.16666666666666666);
	end
	return Float64(tmp - 0.5)
end
function tmp = code(x)
	tmp = ((x * x) - 3.0) / 6.0;
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x ~= 0.0)
		tmp = x / (6.0 / x);
	else
		tmp = (x * x) * 0.16666666666666666;
	end
	tmp_2 = tmp - 0.5;
end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] - 3.0), $MachinePrecision] / 6.0), $MachinePrecision]
code[x_] := N[(If[Unequal[x, 0.0], N[(x / N[(6.0 / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]] - 0.5), $MachinePrecision]
\frac{x \cdot x - 3}{6}
\begin{array}{l}
\mathbf{if}\;x \ne 0:\\
\;\;\;\;\frac{x}{\frac{6}{x}}\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot 0.16666666666666666\\


\end{array} - 0.5

Error

Derivation

  1. Initial program 0.2

    \[\frac{x \cdot x - 3}{6} \]
  2. Applied egg-rr0.2

    \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot -6 - 6 \cdot -3}{6 \cdot -6}} \]
  3. Simplified0.2

    \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot -6}{-36} - 0.5} \]
    Proof
  4. Applied egg-rr0.1

    \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;x \ne 0:\\ \;\;\;\;\frac{x}{\frac{6}{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot 0.16666666666666666\\ } \end{array}} - 0.5 \]

Alternatives

Alternative 1
Error0.2
Cost448
\[0.16666666666666666 \cdot \left(x \cdot x\right) + -0.5 \]
Alternative 2
Error0.1
Cost448
\[x \cdot \left(x \cdot 0.16666666666666666\right) - 0.5 \]
Alternative 3
Error0.2
Cost448
\[\frac{x \cdot x - 3}{6} \]
Alternative 4
Error21.8
Cost64
\[-0.5 \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, H"
  :precision binary64
  (/ (- (* x x) 3.0) 6.0))