Average Error: 1.0 → 0.0
Time: 12.7s
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 r118279 = 2.0;
        double r118280 = atan2(1.0, 0.0);
        double r118281 = r118279 * r118280;
        double r118282 = 3.0;
        double r118283 = r118281 / r118282;
        double r118284 = g;
        double r118285 = -r118284;
        double r118286 = h;
        double r118287 = r118285 / r118286;
        double r118288 = acos(r118287);
        double r118289 = r118288 / r118282;
        double r118290 = r118283 + r118289;
        double r118291 = cos(r118290);
        double r118292 = r118279 * r118291;
        return r118292;
}

double f(double g, double h) {
        double r118293 = 2.0;
        double r118294 = 1.0;
        double r118295 = atan2(1.0, 0.0);
        double r118296 = 3.0;
        double r118297 = r118293 / r118296;
        double r118298 = g;
        double r118299 = -r118298;
        double r118300 = h;
        double r118301 = r118299 / r118300;
        double r118302 = acos(r118301);
        double r118303 = r118302 / r118296;
        double r118304 = fma(r118295, r118297, r118303);
        double r118305 = cos(r118304);
        double r118306 = expm1(r118305);
        double r118307 = r118306 * r118306;
        double r118308 = r118294 - r118307;
        double r118309 = r118294 - r118306;
        double r118310 = r118308 / r118309;
        double r118311 = log(r118310);
        double r118312 = r118293 * r118311;
        return r118312;
}

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-cube-cbrt1.0

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

    \[\leadsto 2 \cdot \log \color{blue}{\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)}\]
  13. Using strategy rm
  14. 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)}\]
  15. 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)\]
  16. 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)))))