Average Error: 1.0 → 0.0
Time: 11.0s
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 r134838 = 2.0;
        double r134839 = atan2(1.0, 0.0);
        double r134840 = r134838 * r134839;
        double r134841 = 3.0;
        double r134842 = r134840 / r134841;
        double r134843 = g;
        double r134844 = -r134843;
        double r134845 = h;
        double r134846 = r134844 / r134845;
        double r134847 = acos(r134846);
        double r134848 = r134847 / r134841;
        double r134849 = r134842 + r134848;
        double r134850 = cos(r134849);
        double r134851 = r134838 * r134850;
        return r134851;
}

double f(double g, double h) {
        double r134852 = 2.0;
        double r134853 = 1.0;
        double r134854 = atan2(1.0, 0.0);
        double r134855 = 3.0;
        double r134856 = r134852 / r134855;
        double r134857 = g;
        double r134858 = -r134857;
        double r134859 = h;
        double r134860 = r134858 / r134859;
        double r134861 = acos(r134860);
        double r134862 = r134861 / r134855;
        double r134863 = fma(r134854, r134856, r134862);
        double r134864 = cos(r134863);
        double r134865 = expm1(r134864);
        double r134866 = r134865 * r134865;
        double r134867 = r134853 - r134866;
        double r134868 = r134853 - r134865;
        double r134869 = r134867 / r134868;
        double r134870 = log(r134869);
        double r134871 = r134852 * r134870;
        return r134871;
}

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)))))