Average Error: 1.0 → 0.0
Time: 21.2s
Precision: 64
\[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
\[\sqrt[3]{\left(\left(\sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)} \cdot \sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}\right) \cdot \sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)} \cdot 2\]
2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)
\sqrt[3]{\left(\left(\sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)} \cdot \sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}\right) \cdot \sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)} \cdot 2
double f(double g, double h) {
        double r4825685 = 2.0;
        double r4825686 = atan2(1.0, 0.0);
        double r4825687 = r4825685 * r4825686;
        double r4825688 = 3.0;
        double r4825689 = r4825687 / r4825688;
        double r4825690 = g;
        double r4825691 = -r4825690;
        double r4825692 = h;
        double r4825693 = r4825691 / r4825692;
        double r4825694 = acos(r4825693);
        double r4825695 = r4825694 / r4825688;
        double r4825696 = r4825689 + r4825695;
        double r4825697 = cos(r4825696);
        double r4825698 = r4825685 * r4825697;
        return r4825698;
}

double f(double g, double h) {
        double r4825699 = 0.6666666666666666;
        double r4825700 = atan2(1.0, 0.0);
        double r4825701 = g;
        double r4825702 = h;
        double r4825703 = r4825701 / r4825702;
        double r4825704 = -r4825703;
        double r4825705 = acos(r4825704);
        double r4825706 = 3.0;
        double r4825707 = r4825705 / r4825706;
        double r4825708 = fma(r4825699, r4825700, r4825707);
        double r4825709 = cos(r4825708);
        double r4825710 = r4825709 * r4825709;
        double r4825711 = cbrt(r4825710);
        double r4825712 = r4825711 * r4825711;
        double r4825713 = r4825712 * r4825711;
        double r4825714 = r4825713 * r4825709;
        double r4825715 = cbrt(r4825714);
        double r4825716 = 2.0;
        double r4825717 = r4825715 * r4825716;
        return r4825717;
}

Error

Bits error versus g

Bits error versus h

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}{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \cdot 2}\]
  3. Using strategy rm
  4. Applied add-cbrt-cube1.5

    \[\leadsto \color{blue}{\sqrt[3]{\left(\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}} \cdot 2\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.0

    \[\leadsto \sqrt[3]{\color{blue}{\left(\left(\sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)} \cdot \sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}\right) \cdot \sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}\right)} \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)} \cdot 2\]
  7. Final simplification0.0

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

Reproduce

herbie shell --seed 2019164 +o rules:numerics
(FPCore (g h)
  :name "2-ancestry mixing, negative discriminant"
  (* 2 (cos (+ (/ (* 2 PI) 3) (/ (acos (/ (- g) h)) 3)))))