(FPCore (g h) :precision binary64 (* 2.0 (cos (+ (/ (* 2.0 PI) 3.0) (/ (acos (/ (- g) h)) 3.0)))))
(FPCore (g h)
:precision binary64
(let* ((t_0 (acos (- (/ g h))))
(t_1 (cos (fma PI 0.6666666666666666 (/ t_0 3.0))))
(t_2 (cbrt (* t_1 t_1))))
(*
2.0
(cbrt
(*
t_1
(*
t_2
(*
(cbrt (/ (+ (cos (* 0.6666666666666666 (fma PI 2.0 t_0))) 1.0) 2.0))
t_2)))))))double code(double g, double h) {
return 2.0 * cos((((2.0 * ((double) M_PI)) / 3.0) + (acos((-g / h)) / 3.0)));
}
double code(double g, double h) {
double t_0 = acos(-(g / h));
double t_1 = cos(fma(((double) M_PI), 0.6666666666666666, (t_0 / 3.0)));
double t_2 = cbrt((t_1 * t_1));
return 2.0 * cbrt((t_1 * (t_2 * (cbrt(((cos((0.6666666666666666 * fma(((double) M_PI), 2.0, t_0))) + 1.0) / 2.0)) * t_2))));
}
function code(g, h) return Float64(2.0 * cos(Float64(Float64(Float64(2.0 * pi) / 3.0) + Float64(acos(Float64(Float64(-g) / h)) / 3.0)))) end
function code(g, h) t_0 = acos(Float64(-Float64(g / h))) t_1 = cos(fma(pi, 0.6666666666666666, Float64(t_0 / 3.0))) t_2 = cbrt(Float64(t_1 * t_1)) return Float64(2.0 * cbrt(Float64(t_1 * Float64(t_2 * Float64(cbrt(Float64(Float64(cos(Float64(0.6666666666666666 * fma(pi, 2.0, t_0))) + 1.0) / 2.0)) * t_2))))) end
code[g_, h_] := N[(2.0 * N[Cos[N[(N[(N[(2.0 * Pi), $MachinePrecision] / 3.0), $MachinePrecision] + N[(N[ArcCos[N[((-g) / h), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[g_, h_] := Block[{t$95$0 = N[ArcCos[(-N[(g / h), $MachinePrecision])], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(Pi * 0.6666666666666666 + N[(t$95$0 / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(t$95$1 * t$95$1), $MachinePrecision], 1/3], $MachinePrecision]}, N[(2.0 * N[Power[N[(t$95$1 * N[(t$95$2 * N[(N[Power[N[(N[(N[Cos[N[(0.6666666666666666 * N[(Pi * 2.0 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 1/3], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)
\begin{array}{l}
t_0 := \cos^{-1} \left(-\frac{g}{h}\right)\\
t_1 := \cos \left(\mathsf{fma}\left(\pi, 0.6666666666666666, \frac{t_0}{3}\right)\right)\\
t_2 := \sqrt[3]{t_1 \cdot t_1}\\
2 \cdot \sqrt[3]{t_1 \cdot \left(t_2 \cdot \left(\sqrt[3]{\frac{\cos \left(0.6666666666666666 \cdot \mathsf{fma}\left(\pi, 2, t_0\right)\right) + 1}{2}} \cdot t_2\right)\right)}
\end{array}



Bits error versus g



Bits error versus h
Initial program 1.0
Simplified1.0
Applied add-cbrt-cube_binary641.5
Applied add-cube-cbrt_binary640.0
Applied cos-mult_binary640.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2022131
(FPCore (g h)
:name "2-ancestry mixing, negative discriminant"
:precision binary64
(* 2.0 (cos (+ (/ (* 2.0 PI) 3.0) (/ (acos (/ (- g) h)) 3.0)))))