Average Error: 1.0 → 0.0
Time: 4.8s
Precision: 64
\[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
\[2 \cdot \log \left({e}^{\left(\cos \left(\mathsf{fma}\left(\frac{2}{\sqrt[3]{3} \cdot \sqrt[3]{3}}, \frac{\pi}{\sqrt[3]{3}}, \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 \log \left({e}^{\left(\cos \left(\mathsf{fma}\left(\frac{2}{\sqrt[3]{3} \cdot \sqrt[3]{3}}, \frac{\pi}{\sqrt[3]{3}}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)}\right)
double f(double g, double h) {
        double r152689 = 2.0;
        double r152690 = atan2(1.0, 0.0);
        double r152691 = r152689 * r152690;
        double r152692 = 3.0;
        double r152693 = r152691 / r152692;
        double r152694 = g;
        double r152695 = -r152694;
        double r152696 = h;
        double r152697 = r152695 / r152696;
        double r152698 = acos(r152697);
        double r152699 = r152698 / r152692;
        double r152700 = r152693 + r152699;
        double r152701 = cos(r152700);
        double r152702 = r152689 * r152701;
        return r152702;
}

double f(double g, double h) {
        double r152703 = 2.0;
        double r152704 = exp(1.0);
        double r152705 = 3.0;
        double r152706 = cbrt(r152705);
        double r152707 = r152706 * r152706;
        double r152708 = r152703 / r152707;
        double r152709 = atan2(1.0, 0.0);
        double r152710 = r152709 / r152706;
        double r152711 = g;
        double r152712 = -r152711;
        double r152713 = h;
        double r152714 = r152712 / r152713;
        double r152715 = acos(r152714);
        double r152716 = r152715 / r152705;
        double r152717 = fma(r152708, r152710, r152716);
        double r152718 = cos(r152717);
        double r152719 = pow(r152704, r152718);
        double r152720 = log(r152719);
        double r152721 = r152703 * r152720;
        return r152721;
}

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. Using strategy rm
  3. Applied add-cube-cbrt1.0

    \[\leadsto 2 \cdot \cos \left(\frac{2 \cdot \pi}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
  4. Applied times-frac1.0

    \[\leadsto 2 \cdot \cos \left(\color{blue}{\frac{2}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\pi}{\sqrt[3]{3}}} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
  5. Applied fma-def1.0

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

    \[\leadsto 2 \cdot \color{blue}{\log \left(e^{\cos \left(\mathsf{fma}\left(\frac{2}{\sqrt[3]{3} \cdot \sqrt[3]{3}}, \frac{\pi}{\sqrt[3]{3}}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}\right)}\]
  8. Using strategy rm
  9. Applied *-un-lft-identity1.0

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

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

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

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

Reproduce

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