Average Error: 1.0 → 0.1
Time: 19.7s
Precision: 64
\[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
\[2 \cdot \left(\left(\log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}}\right) + \log \left(\sqrt[3]{e^{\sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)} \cdot \left(\sqrt[3]{\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)}\right)}}\right)\right) + \log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}}\right)\right)\]
2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)
2 \cdot \left(\left(\log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}}\right) + \log \left(\sqrt[3]{e^{\sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)} \cdot \left(\sqrt[3]{\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)}\right)}}\right)\right) + \log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}}\right)\right)
double f(double g, double h) {
        double r5755730 = 2.0;
        double r5755731 = atan2(1.0, 0.0);
        double r5755732 = r5755730 * r5755731;
        double r5755733 = 3.0;
        double r5755734 = r5755732 / r5755733;
        double r5755735 = g;
        double r5755736 = -r5755735;
        double r5755737 = h;
        double r5755738 = r5755736 / r5755737;
        double r5755739 = acos(r5755738);
        double r5755740 = r5755739 / r5755733;
        double r5755741 = r5755734 + r5755740;
        double r5755742 = cos(r5755741);
        double r5755743 = r5755730 * r5755742;
        return r5755743;
}

double f(double g, double h) {
        double r5755744 = 2.0;
        double r5755745 = 3.0;
        double r5755746 = r5755744 / r5755745;
        double r5755747 = atan2(1.0, 0.0);
        double r5755748 = g;
        double r5755749 = h;
        double r5755750 = r5755748 / r5755749;
        double r5755751 = -r5755750;
        double r5755752 = acos(r5755751);
        double r5755753 = r5755752 / r5755745;
        double r5755754 = fma(r5755746, r5755747, r5755753);
        double r5755755 = cos(r5755754);
        double r5755756 = exp(r5755755);
        double r5755757 = cbrt(r5755756);
        double r5755758 = log(r5755757);
        double r5755759 = cbrt(r5755755);
        double r5755760 = r5755759 * r5755759;
        double r5755761 = r5755759 * r5755760;
        double r5755762 = exp(r5755761);
        double r5755763 = cbrt(r5755762);
        double r5755764 = log(r5755763);
        double r5755765 = r5755758 + r5755764;
        double r5755766 = r5755765 + r5755758;
        double r5755767 = r5755744 * r5755766;
        return r5755767;
}

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-log-exp1.0

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

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

    \[\leadsto \color{blue}{\left(\log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}} \cdot \sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}}\right) + \log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}}\right)\right)} \cdot 2\]
  8. Simplified0.1

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

    \[\leadsto \left(\left(\log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}}\right) + \log \left(\sqrt[3]{e^{\color{blue}{\left(\sqrt[3]{\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)}\right) \cdot \sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}}}}\right)\right) + \log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}}\right)\right) \cdot 2\]
  11. Final simplification0.1

    \[\leadsto 2 \cdot \left(\left(\log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}}\right) + \log \left(\sqrt[3]{e^{\sqrt[3]{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)} \cdot \left(\sqrt[3]{\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)}\right)}}\right)\right) + \log \left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(-\frac{g}{h}\right)}{3}\right)\right)}}\right)\right)\]

Reproduce

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