Average Error: 1.0 → 0.1
Time: 13.4s
Precision: 64
\[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
\[2 \cdot \left(\sqrt[3]{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)\right)} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)}^{2}}\right)\]
2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)
2 \cdot \left(\sqrt[3]{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)\right)} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)}^{2}}\right)
double f(double g, double h) {
        double r142512 = 2.0;
        double r142513 = atan2(1.0, 0.0);
        double r142514 = r142512 * r142513;
        double r142515 = 3.0;
        double r142516 = r142514 / r142515;
        double r142517 = g;
        double r142518 = -r142517;
        double r142519 = h;
        double r142520 = r142518 / r142519;
        double r142521 = acos(r142520);
        double r142522 = r142521 / r142515;
        double r142523 = r142516 + r142522;
        double r142524 = cos(r142523);
        double r142525 = r142512 * r142524;
        return r142525;
}

double f(double g, double h) {
        double r142526 = 2.0;
        double r142527 = 3.0;
        double r142528 = r142526 / r142527;
        double r142529 = atan2(1.0, 0.0);
        double r142530 = g;
        double r142531 = -r142530;
        double r142532 = h;
        double r142533 = r142531 / r142532;
        double r142534 = acos(r142533);
        double r142535 = r142534 / r142527;
        double r142536 = fma(r142528, r142529, r142535);
        double r142537 = cos(r142536);
        double r142538 = expm1(r142537);
        double r142539 = log1p(r142538);
        double r142540 = cbrt(r142539);
        double r142541 = 2.0;
        double r142542 = pow(r142537, r142541);
        double r142543 = cbrt(r142542);
        double r142544 = r142540 * r142543;
        double r142545 = r142526 * r142544;
        return r142545;
}

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

    \[\leadsto 2 \cdot \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)}}\]
  5. Simplified1.0

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

    \[\leadsto 2 \cdot \sqrt[3]{\color{blue}{\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right) \cdot \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)}}\]
  8. Applied cbrt-prod0.0

    \[\leadsto 2 \cdot \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) \cdot \cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)}\right)}\]
  9. Simplified0.0

    \[\leadsto 2 \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 \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)\right)}^{2}}}\right)\]
  10. Using strategy rm
  11. Applied log1p-expm1-u0.1

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

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

Reproduce

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