Average Error: 1.0 → 0.0
Time: 15.9s
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(\frac{1 - \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right) \cdot \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)}{1 - \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{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(\frac{1 - \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right) \cdot \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)}{1 - \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)}\right)
double f(double g, double h) {
        double r165665 = 2.0;
        double r165666 = atan2(1.0, 0.0);
        double r165667 = r165665 * r165666;
        double r165668 = 3.0;
        double r165669 = r165667 / r165668;
        double r165670 = g;
        double r165671 = -r165670;
        double r165672 = h;
        double r165673 = r165671 / r165672;
        double r165674 = acos(r165673);
        double r165675 = r165674 / r165668;
        double r165676 = r165669 + r165675;
        double r165677 = cos(r165676);
        double r165678 = r165665 * r165677;
        return r165678;
}

double f(double g, double h) {
        double r165679 = 2.0;
        double r165680 = 1.0;
        double r165681 = atan2(1.0, 0.0);
        double r165682 = 3.0;
        double r165683 = r165679 / r165682;
        double r165684 = g;
        double r165685 = -r165684;
        double r165686 = h;
        double r165687 = r165685 / r165686;
        double r165688 = acos(r165687);
        double r165689 = r165688 / r165682;
        double r165690 = fma(r165681, r165683, r165689);
        double r165691 = cos(r165690);
        double r165692 = expm1(r165691);
        double r165693 = r165692 * r165692;
        double r165694 = r165680 - r165693;
        double r165695 = r165680 - r165692;
        double r165696 = r165694 / r165695;
        double r165697 = log(r165696);
        double r165698 = r165679 * r165697;
        return r165698;
}

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-sqr-sqrt1.0

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

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

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

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

    \[\leadsto 2 \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)}\right)\]
  10. Using strategy rm
  11. Applied log1p-udef1.0

    \[\leadsto 2 \cdot \color{blue}{\log \left(1 + \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\pi, \frac{2}{3}, \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\right)\right)\right)}\]
  12. Using strategy rm
  13. Applied flip-+0.0

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

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

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

Reproduce

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