bug323 (missed optimization)

Percentage Accurate: 7.1% → 10.6%
Time: 22.9s
Alternatives: 11
Speedup: 1.0×

Specification

?
\[0 \leq x \land x \leq 0.5\]
\[\begin{array}{l} \\ \cos^{-1} \left(1 - x\right) \end{array} \]
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
double code(double x) {
	return acos((1.0 - x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = acos((1.0d0 - x))
end function
public static double code(double x) {
	return Math.acos((1.0 - x));
}
def code(x):
	return math.acos((1.0 - x))
function code(x)
	return acos(Float64(1.0 - x))
end
function tmp = code(x)
	tmp = acos((1.0 - x));
end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(1 - x\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 7.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(1 - x\right) \end{array} \]
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
double code(double x) {
	return acos((1.0 - x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = acos((1.0d0 - x))
end function
public static double code(double x) {
	return Math.acos((1.0 - x));
}
def code(x):
	return math.acos((1.0 - x))
function code(x)
	return acos(Float64(1.0 - x))
end
function tmp = code(x)
	tmp = acos((1.0 - x));
end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(1 - x\right)
\end{array}

Alternative 1: 10.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\pi \cdot 0.5}\\ t_1 := \sin^{-1} \left(1 - x\right)\\ t_2 := {t_1}^{0.16666666666666666}\\ t_3 := -t_2\\ t_4 := t_2 \cdot {\left(\sqrt[3]{t_1}\right)}^{2}\\ \mathsf{fma}\left(t_0, t_0, t_4 \cdot t_3\right) + \mathsf{fma}\left(t_3, t_4, t_2 \cdot t_4\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (* PI 0.5)))
        (t_1 (asin (- 1.0 x)))
        (t_2 (pow t_1 0.16666666666666666))
        (t_3 (- t_2))
        (t_4 (* t_2 (pow (cbrt t_1) 2.0))))
   (+ (fma t_0 t_0 (* t_4 t_3)) (fma t_3 t_4 (* t_2 t_4)))))
double code(double x) {
	double t_0 = sqrt((((double) M_PI) * 0.5));
	double t_1 = asin((1.0 - x));
	double t_2 = pow(t_1, 0.16666666666666666);
	double t_3 = -t_2;
	double t_4 = t_2 * pow(cbrt(t_1), 2.0);
	return fma(t_0, t_0, (t_4 * t_3)) + fma(t_3, t_4, (t_2 * t_4));
}
function code(x)
	t_0 = sqrt(Float64(pi * 0.5))
	t_1 = asin(Float64(1.0 - x))
	t_2 = t_1 ^ 0.16666666666666666
	t_3 = Float64(-t_2)
	t_4 = Float64(t_2 * (cbrt(t_1) ^ 2.0))
	return Float64(fma(t_0, t_0, Float64(t_4 * t_3)) + fma(t_3, t_4, Float64(t_2 * t_4)))
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(Pi * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 0.16666666666666666], $MachinePrecision]}, Block[{t$95$3 = (-t$95$2)}, Block[{t$95$4 = N[(t$95$2 * N[Power[N[Power[t$95$1, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * t$95$0 + N[(t$95$4 * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(t$95$3 * t$95$4 + N[(t$95$2 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\pi \cdot 0.5}\\
t_1 := \sin^{-1} \left(1 - x\right)\\
t_2 := {t_1}^{0.16666666666666666}\\
t_3 := -t_2\\
t_4 := t_2 \cdot {\left(\sqrt[3]{t_1}\right)}^{2}\\
\mathsf{fma}\left(t_0, t_0, t_4 \cdot t_3\right) + \mathsf{fma}\left(t_3, t_4, t_2 \cdot t_4\right)
\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 10.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\sin^{-1} \left(1 - x\right)}\\ \cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_0, t_0, {t_0}^{2}\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (asin (- 1.0 x)))))
   (+ (acos (- 1.0 x)) (fma (- t_0) t_0 (pow t_0 2.0)))))
double code(double x) {
	double t_0 = sqrt(asin((1.0 - x)));
	return acos((1.0 - x)) + fma(-t_0, t_0, pow(t_0, 2.0));
}
function code(x)
	t_0 = sqrt(asin(Float64(1.0 - x)))
	return Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_0), t_0, (t_0 ^ 2.0)))
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$0) * t$95$0 + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\sin^{-1} \left(1 - x\right)}\\
\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_0, t_0, {t_0}^{2}\right)
\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 10.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin^{-1} \left(1 - x\right)\\ t_1 := \sqrt{t_0}\\ \mathsf{fma}\left(-t_1, t_1, t_0\right) + \left(\left(1 + \cos^{-1} \left(1 - x\right)\right) + -1\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (asin (- 1.0 x))) (t_1 (sqrt t_0)))
   (+ (fma (- t_1) t_1 t_0) (+ (+ 1.0 (acos (- 1.0 x))) -1.0))))
double code(double x) {
	double t_0 = asin((1.0 - x));
	double t_1 = sqrt(t_0);
	return fma(-t_1, t_1, t_0) + ((1.0 + acos((1.0 - x))) + -1.0);
}
function code(x)
	t_0 = asin(Float64(1.0 - x))
	t_1 = sqrt(t_0)
	return Float64(fma(Float64(-t_1), t_1, t_0) + Float64(Float64(1.0 + acos(Float64(1.0 - x))) + -1.0))
end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, N[(N[((-t$95$1) * t$95$1 + t$95$0), $MachinePrecision] + N[(N[(1.0 + N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
t_1 := \sqrt{t_0}\\
\mathsf{fma}\left(-t_1, t_1, t_0\right) + \left(\left(1 + \cos^{-1} \left(1 - x\right)\right) + -1\right)
\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 10.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin^{-1} \left(1 - x\right)\\ t_1 := \sqrt{t_0}\\ \left(1 + \left(\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_1, t_1, t_0\right)\right)\right) + -1 \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (asin (- 1.0 x))) (t_1 (sqrt t_0)))
   (+ (+ 1.0 (+ (acos (- 1.0 x)) (fma (- t_1) t_1 t_0))) -1.0)))
double code(double x) {
	double t_0 = asin((1.0 - x));
	double t_1 = sqrt(t_0);
	return (1.0 + (acos((1.0 - x)) + fma(-t_1, t_1, t_0))) + -1.0;
}
function code(x)
	t_0 = asin(Float64(1.0 - x))
	t_1 = sqrt(t_0)
	return Float64(Float64(1.0 + Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_1), t_1, t_0))) + -1.0)
end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, N[(N[(1.0 + N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$1) * t$95$1 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
t_1 := \sqrt{t_0}\\
\left(1 + \left(\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_1, t_1, t_0\right)\right)\right) + -1
\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 10.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin^{-1} \left(1 - x\right)\\ t_1 := \sqrt{t_0}\\ \cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_1, t_1, t_0\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (asin (- 1.0 x))) (t_1 (sqrt t_0)))
   (+ (acos (- 1.0 x)) (fma (- t_1) t_1 t_0))))
double code(double x) {
	double t_0 = asin((1.0 - x));
	double t_1 = sqrt(t_0);
	return acos((1.0 - x)) + fma(-t_1, t_1, t_0);
}
function code(x)
	t_0 = asin(Float64(1.0 - x))
	t_1 = sqrt(t_0)
	return Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_1), t_1, t_0))
end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$1) * t$95$1 + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
t_1 := \sqrt{t_0}\\
\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_1, t_1, t_0\right)
\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 10.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt[3]{\sin^{-1} \left(1 - x\right)}\\ \pi \cdot 0.5 - t_0 \cdot {t_0}^{2} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (cbrt (asin (- 1.0 x))))) (- (* PI 0.5) (* t_0 (pow t_0 2.0)))))
double code(double x) {
	double t_0 = cbrt(asin((1.0 - x)));
	return (((double) M_PI) * 0.5) - (t_0 * pow(t_0, 2.0));
}
public static double code(double x) {
	double t_0 = Math.cbrt(Math.asin((1.0 - x)));
	return (Math.PI * 0.5) - (t_0 * Math.pow(t_0, 2.0));
}
function code(x)
	t_0 = cbrt(asin(Float64(1.0 - x)))
	return Float64(Float64(pi * 0.5) - Float64(t_0 * (t_0 ^ 2.0)))
end
code[x_] := Block[{t$95$0 = N[Power[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[(Pi * 0.5), $MachinePrecision] - N[(t$95$0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt[3]{\sin^{-1} \left(1 - x\right)}\\
\pi \cdot 0.5 - t_0 \cdot {t_0}^{2}
\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 9.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos^{-1} \left(1 - x\right)\\ \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;1 + \sqrt{{\left(t_0 + -1\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{t_0}^{3}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (acos (- 1.0 x))))
   (if (<= x 5.5e-17)
     (+ 1.0 (sqrt (pow (+ t_0 -1.0) 2.0)))
     (cbrt (pow t_0 3.0)))))
double code(double x) {
	double t_0 = acos((1.0 - x));
	double tmp;
	if (x <= 5.5e-17) {
		tmp = 1.0 + sqrt(pow((t_0 + -1.0), 2.0));
	} else {
		tmp = cbrt(pow(t_0, 3.0));
	}
	return tmp;
}
public static double code(double x) {
	double t_0 = Math.acos((1.0 - x));
	double tmp;
	if (x <= 5.5e-17) {
		tmp = 1.0 + Math.sqrt(Math.pow((t_0 + -1.0), 2.0));
	} else {
		tmp = Math.cbrt(Math.pow(t_0, 3.0));
	}
	return tmp;
}
function code(x)
	t_0 = acos(Float64(1.0 - x))
	tmp = 0.0
	if (x <= 5.5e-17)
		tmp = Float64(1.0 + sqrt((Float64(t_0 + -1.0) ^ 2.0)));
	else
		tmp = cbrt((t_0 ^ 3.0));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5.5e-17], N[(1.0 + N[Sqrt[N[Power[N[(t$95$0 + -1.0), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos^{-1} \left(1 - x\right)\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;1 + \sqrt{{\left(t_0 + -1\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{t_0}^{3}}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 9.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\pi \cdot 0.5 + \sin^{-1} \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\cos^{-1} \left(1 - x\right)}^{3}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 5.5e-17)
   (+ (* PI 0.5) (asin (- 1.0 x)))
   (cbrt (pow (acos (- 1.0 x)) 3.0))))
double code(double x) {
	double tmp;
	if (x <= 5.5e-17) {
		tmp = (((double) M_PI) * 0.5) + asin((1.0 - x));
	} else {
		tmp = cbrt(pow(acos((1.0 - x)), 3.0));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 5.5e-17) {
		tmp = (Math.PI * 0.5) + Math.asin((1.0 - x));
	} else {
		tmp = Math.cbrt(Math.pow(Math.acos((1.0 - x)), 3.0));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 5.5e-17)
		tmp = Float64(Float64(pi * 0.5) + asin(Float64(1.0 - x)));
	else
		tmp = cbrt((acos(Float64(1.0 - x)) ^ 3.0));
	end
	return tmp
end
code[x_] := If[LessEqual[x, 5.5e-17], N[(N[(Pi * 0.5), $MachinePrecision] + N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;\pi \cdot 0.5 + \sin^{-1} \left(1 - x\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\cos^{-1} \left(1 - x\right)}^{3}}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 9.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\pi \cdot 0.5 + \sin^{-1} \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{\cos^{-1} \left(1 - x\right)}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 5.5e-17)
   (+ (* PI 0.5) (asin (- 1.0 x)))
   (/ 1.0 (/ 1.0 (acos (- 1.0 x))))))
double code(double x) {
	double tmp;
	if (x <= 5.5e-17) {
		tmp = (((double) M_PI) * 0.5) + asin((1.0 - x));
	} else {
		tmp = 1.0 / (1.0 / acos((1.0 - x)));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 5.5e-17) {
		tmp = (Math.PI * 0.5) + Math.asin((1.0 - x));
	} else {
		tmp = 1.0 / (1.0 / Math.acos((1.0 - x)));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 5.5e-17:
		tmp = (math.pi * 0.5) + math.asin((1.0 - x))
	else:
		tmp = 1.0 / (1.0 / math.acos((1.0 - x)))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 5.5e-17)
		tmp = Float64(Float64(pi * 0.5) + asin(Float64(1.0 - x)));
	else
		tmp = Float64(1.0 / Float64(1.0 / acos(Float64(1.0 - x))));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 5.5e-17)
		tmp = (pi * 0.5) + asin((1.0 - x));
	else
		tmp = 1.0 / (1.0 / acos((1.0 - x)));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 5.5e-17], N[(N[(Pi * 0.5), $MachinePrecision] + N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;\pi \cdot 0.5 + \sin^{-1} \left(1 - x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\cos^{-1} \left(1 - x\right)}}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 7.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{1}{\cos^{-1} \left(1 - x\right)}} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (/ 1.0 (acos (- 1.0 x)))))
double code(double x) {
	return 1.0 / (1.0 / acos((1.0 - x)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 / (1.0d0 / acos((1.0d0 - x)))
end function
public static double code(double x) {
	return 1.0 / (1.0 / Math.acos((1.0 - x)));
}
def code(x):
	return 1.0 / (1.0 / math.acos((1.0 - x)))
function code(x)
	return Float64(1.0 / Float64(1.0 / acos(Float64(1.0 - x))))
end
function tmp = code(x)
	tmp = 1.0 / (1.0 / acos((1.0 - x)));
end
code[x_] := N[(1.0 / N[(1.0 / N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{1}{\cos^{-1} \left(1 - x\right)}}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 11: 7.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(1 - x\right) \end{array} \]
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
double code(double x) {
	return acos((1.0 - x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = acos((1.0d0 - x))
end function
public static double code(double x) {
	return Math.acos((1.0 - x));
}
def code(x):
	return math.acos((1.0 - x))
function code(x)
	return acos(Float64(1.0 - x))
end
function tmp = code(x)
	tmp = acos((1.0 - x));
end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(1 - x\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Developer target: 100.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ 2 \cdot \sin^{-1} \left(\sqrt{\frac{x}{2}}\right) \end{array} \]
(FPCore (x) :precision binary64 (* 2.0 (asin (sqrt (/ x 2.0)))))
double code(double x) {
	return 2.0 * asin(sqrt((x / 2.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 2.0d0 * asin(sqrt((x / 2.0d0)))
end function
public static double code(double x) {
	return 2.0 * Math.asin(Math.sqrt((x / 2.0)));
}
def code(x):
	return 2.0 * math.asin(math.sqrt((x / 2.0)))
function code(x)
	return Float64(2.0 * asin(sqrt(Float64(x / 2.0))))
end
function tmp = code(x)
	tmp = 2.0 * asin(sqrt((x / 2.0)));
end
code[x_] := N[(2.0 * N[ArcSin[N[Sqrt[N[(x / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \sin^{-1} \left(\sqrt{\frac{x}{2}}\right)
\end{array}

Reproduce

?
herbie shell --seed 2023350 
(FPCore (x)
  :name "bug323 (missed optimization)"
  :precision binary64
  :pre (and (<= 0.0 x) (<= x 0.5))

  :herbie-target
  (* 2.0 (asin (sqrt (/ x 2.0))))

  (acos (- 1.0 x)))