?

Average Error: 1.0 → 1.3
Time: 6.4s
Precision: binary64
Cost: 169920

?

\[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]
\[\begin{array}{l} t_0 := 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\\ t_1 := \sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin t_0\\ t_2 := \cos t_0\\ t_3 := \cos \left(0.6666666666666666 \cdot \pi\right)\\ 2 \cdot \frac{{\left(t_2 \cdot t_3\right)}^{3} - {t_1}^{3}}{\mathsf{fma}\left(t_1, \cos \left(t_0 + \pi \cdot -0.6666666666666666\right), \left(t_2 \cdot t_2\right) \cdot \left(t_3 \cdot t_3\right)\right)} \end{array} \]
(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 (* 0.3333333333333333 (acos (/ g h))))
        (t_1 (* (sin (* 0.6666666666666666 PI)) (sin t_0)))
        (t_2 (cos t_0))
        (t_3 (cos (* 0.6666666666666666 PI))))
   (*
    2.0
    (/
     (- (pow (* t_2 t_3) 3.0) (pow t_1 3.0))
     (fma
      t_1
      (cos (+ t_0 (* PI -0.6666666666666666)))
      (* (* t_2 t_2) (* t_3 t_3)))))))
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 = 0.3333333333333333 * acos((g / h));
	double t_1 = sin((0.6666666666666666 * ((double) M_PI))) * sin(t_0);
	double t_2 = cos(t_0);
	double t_3 = cos((0.6666666666666666 * ((double) M_PI)));
	return 2.0 * ((pow((t_2 * t_3), 3.0) - pow(t_1, 3.0)) / fma(t_1, cos((t_0 + (((double) M_PI) * -0.6666666666666666))), ((t_2 * t_2) * (t_3 * t_3))));
}
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 = Float64(0.3333333333333333 * acos(Float64(g / h)))
	t_1 = Float64(sin(Float64(0.6666666666666666 * pi)) * sin(t_0))
	t_2 = cos(t_0)
	t_3 = cos(Float64(0.6666666666666666 * pi))
	return Float64(2.0 * Float64(Float64((Float64(t_2 * t_3) ^ 3.0) - (t_1 ^ 3.0)) / fma(t_1, cos(Float64(t_0 + Float64(pi * -0.6666666666666666))), Float64(Float64(t_2 * t_2) * Float64(t_3 * t_3)))))
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[(0.3333333333333333 * N[ArcCos[N[(g / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(0.6666666666666666 * Pi), $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(0.6666666666666666 * Pi), $MachinePrecision]], $MachinePrecision]}, N[(2.0 * N[(N[(N[Power[N[(t$95$2 * t$95$3), $MachinePrecision], 3.0], $MachinePrecision] - N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 * N[Cos[N[(t$95$0 + N[(Pi * -0.6666666666666666), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(t$95$2 * t$95$2), $MachinePrecision] * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 := 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\\
t_1 := \sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin t_0\\
t_2 := \cos t_0\\
t_3 := \cos \left(0.6666666666666666 \cdot \pi\right)\\
2 \cdot \frac{{\left(t_2 \cdot t_3\right)}^{3} - {t_1}^{3}}{\mathsf{fma}\left(t_1, \cos \left(t_0 + \pi \cdot -0.6666666666666666\right), \left(t_2 \cdot t_2\right) \cdot \left(t_3 \cdot t_3\right)\right)}
\end{array}

Error?

Derivation?

  1. Initial program 1.0

    \[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]
  2. Simplified1.0

    \[\leadsto \color{blue}{2 \cdot \cos \left(\mathsf{fma}\left(\pi, 0.6666666666666666, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)} \]
    Proof

    [Start]1.0

    \[ 2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]

    associate-/l* [=>]1.0

    \[ 2 \cdot \cos \left(\color{blue}{\frac{2}{\frac{3}{\pi}}} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]

    associate-/r/ [=>]1.0

    \[ 2 \cdot \cos \left(\color{blue}{\frac{2}{3} \cdot \pi} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]

    *-commutative [=>]1.0

    \[ 2 \cdot \cos \left(\color{blue}{\pi \cdot \frac{2}{3}} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]

    fma-def [=>]1.0

    \[ 2 \cdot \cos \color{blue}{\left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)} \]

    metadata-eval [=>]1.0

    \[ 2 \cdot \cos \left(\mathsf{fma}\left(\pi, \color{blue}{0.6666666666666666}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \]
  3. Applied egg-rr2.2

    \[\leadsto 2 \cdot \cos \color{blue}{\left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333 + \pi \cdot 0.6666666666666666\right)} \]
  4. Applied egg-rr2.8

    \[\leadsto 2 \cdot \color{blue}{\frac{{\left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right)}^{3} - {\left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right)}^{3}}{\left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right) \cdot \left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right) + \left(\left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right) \cdot \left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right) + \left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right) \cdot \left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right)\right)}} \]
  5. Simplified2.2

    \[\leadsto 2 \cdot \color{blue}{\frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right), \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right), \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)}} \]
    Proof

    [Start]2.8

    \[ 2 \cdot \frac{{\left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right)}^{3} - {\left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right)}^{3}}{\left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right) \cdot \left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right) + \left(\left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right) \cdot \left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right) + \left(\cos \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \cos \left(\pi \cdot 0.6666666666666666\right)\right) \cdot \left(\sin \left(\cos^{-1} \left(\frac{g}{h}\right) \cdot 0.3333333333333333\right) \cdot \sin \left(\pi \cdot 0.6666666666666666\right)\right)\right)} \]
  6. Applied egg-rr2.8

    \[\leadsto 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \color{blue}{e^{\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(0.3333333333333333, \cos^{-1} \left(\frac{g}{h}\right), -0.6666666666666666 \cdot \pi\right)\right)\right)} - 1}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]
  7. Simplified1.3

    \[\leadsto 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \color{blue}{\cos \left(\mathsf{fma}\left(\pi, -0.6666666666666666, 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]
    Proof

    [Start]2.8

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), e^{\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(0.3333333333333333, \cos^{-1} \left(\frac{g}{h}\right), -0.6666666666666666 \cdot \pi\right)\right)\right)} - 1, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    expm1-def [=>]3.5

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(0.3333333333333333, \cos^{-1} \left(\frac{g}{h}\right), -0.6666666666666666 \cdot \pi\right)\right)\right)\right)}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    expm1-log1p [=>]3.5

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \color{blue}{\cos \left(\mathsf{fma}\left(0.3333333333333333, \cos^{-1} \left(\frac{g}{h}\right), -0.6666666666666666 \cdot \pi\right)\right)}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    fma-udef [=>]1.3

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \color{blue}{\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right) + \left(-0.6666666666666666 \cdot \pi\right)\right)}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    +-commutative [=>]1.3

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \color{blue}{\left(\left(-0.6666666666666666 \cdot \pi\right) + 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    distribute-lft-neg-in [=>]1.3

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \left(\color{blue}{\left(-0.6666666666666666\right) \cdot \pi} + 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    *-commutative [=>]1.3

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \left(\color{blue}{\pi \cdot \left(-0.6666666666666666\right)} + 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    fma-def [=>]1.3

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \color{blue}{\left(\mathsf{fma}\left(\pi, -0.6666666666666666, 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

    metadata-eval [=>]1.3

    \[ 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \left(\mathsf{fma}\left(\pi, \color{blue}{-0.6666666666666666}, 0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right), \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]
  8. Taylor expanded in g around 0 1.3

    \[\leadsto 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \color{blue}{\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right) + -0.6666666666666666 \cdot \pi\right)}, \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]
  9. Final simplification1.3

    \[\leadsto 2 \cdot \frac{{\left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)}^{3} - {\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\sin \left(0.6666666666666666 \cdot \pi\right) \cdot \sin \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right), \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right) + \pi \cdot -0.6666666666666666\right), \left(\cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right) \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot \left(\cos \left(0.6666666666666666 \cdot \pi\right) \cdot \cos \left(0.6666666666666666 \cdot \pi\right)\right)\right)} \]

Alternatives

Alternative 1
Error1.0
Cost26176
\[2 \cdot \cos \left(\mathsf{fma}\left(\pi, 0.6666666666666666, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \]
Alternative 2
Error1.0
Cost19904
\[2 \cdot \cos \left(0.6666666666666666 \cdot \pi + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]
Alternative 3
Error2.2
Cost19840
\[2 \cdot \cos \left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{g}{h}\right) + 0.6666666666666666 \cdot \pi\right) \]

Error

Reproduce?

herbie shell --seed 2023237 
(FPCore (g h)
  :name "2-ancestry mixing, negative discriminant"
  :precision binary64
  (* 2.0 (cos (+ (/ (* 2.0 PI) 3.0) (/ (acos (/ (- g) h)) 3.0)))))