Average Error: 1.0 → 1.0
Time: 16.9s
Precision: 64
\[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \left(\frac{1}{\sqrt{3}} \cdot \frac{1}{\sqrt{3}}\right) \cdot \cos^{-1} \left(-\frac{g}{h}\right)\right)\right)\right)\right) \cdot 2\]
2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)
\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(\frac{2}{3}, \pi, \left(\frac{1}{\sqrt{3}} \cdot \frac{1}{\sqrt{3}}\right) \cdot \cos^{-1} \left(-\frac{g}{h}\right)\right)\right)\right)\right) \cdot 2
double f(double g, double h) {
        double r2736370 = 2.0;
        double r2736371 = atan2(1.0, 0.0);
        double r2736372 = r2736370 * r2736371;
        double r2736373 = 3.0;
        double r2736374 = r2736372 / r2736373;
        double r2736375 = g;
        double r2736376 = -r2736375;
        double r2736377 = h;
        double r2736378 = r2736376 / r2736377;
        double r2736379 = acos(r2736378);
        double r2736380 = r2736379 / r2736373;
        double r2736381 = r2736374 + r2736380;
        double r2736382 = cos(r2736381);
        double r2736383 = r2736370 * r2736382;
        return r2736383;
}

double f(double g, double h) {
        double r2736384 = 0.6666666666666666;
        double r2736385 = atan2(1.0, 0.0);
        double r2736386 = 1.0;
        double r2736387 = 3.0;
        double r2736388 = sqrt(r2736387);
        double r2736389 = r2736386 / r2736388;
        double r2736390 = r2736389 * r2736389;
        double r2736391 = g;
        double r2736392 = h;
        double r2736393 = r2736391 / r2736392;
        double r2736394 = -r2736393;
        double r2736395 = acos(r2736394);
        double r2736396 = r2736390 * r2736395;
        double r2736397 = fma(r2736384, r2736385, r2736396);
        double r2736398 = cos(r2736397);
        double r2736399 = expm1(r2736398);
        double r2736400 = log1p(r2736399);
        double r2736401 = 2.0;
        double r2736402 = r2736400 * r2736401;
        return r2736402;
}

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

    \[\leadsto \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 2\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt1.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\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)\right)\right) \cdot 2\]
  7. Applied add-sqr-sqrt1.0

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

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

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

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

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

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

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

Reproduce

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