Average Error: 1.0 → 1.0
Time: 23.7s
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 r2114047 = 2.0;
        double r2114048 = atan2(1.0, 0.0);
        double r2114049 = r2114047 * r2114048;
        double r2114050 = 3.0;
        double r2114051 = r2114049 / r2114050;
        double r2114052 = g;
        double r2114053 = -r2114052;
        double r2114054 = h;
        double r2114055 = r2114053 / r2114054;
        double r2114056 = acos(r2114055);
        double r2114057 = r2114056 / r2114050;
        double r2114058 = r2114051 + r2114057;
        double r2114059 = cos(r2114058);
        double r2114060 = r2114047 * r2114059;
        return r2114060;
}

double f(double g, double h) {
        double r2114061 = 0.6666666666666666;
        double r2114062 = atan2(1.0, 0.0);
        double r2114063 = 1.0;
        double r2114064 = 3.0;
        double r2114065 = sqrt(r2114064);
        double r2114066 = r2114063 / r2114065;
        double r2114067 = r2114066 * r2114066;
        double r2114068 = g;
        double r2114069 = h;
        double r2114070 = r2114068 / r2114069;
        double r2114071 = -r2114070;
        double r2114072 = acos(r2114071);
        double r2114073 = r2114067 * r2114072;
        double r2114074 = fma(r2114061, r2114062, r2114073);
        double r2114075 = cos(r2114074);
        double r2114076 = expm1(r2114075);
        double r2114077 = log1p(r2114076);
        double r2114078 = 2.0;
        double r2114079 = r2114077 * r2114078;
        return r2114079;
}

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

    \[\leadsto \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) \cdot 2\]
  5. Applied associate-/r*1.0

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

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

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\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\]
  9. Using strategy rm
  10. 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\]
  11. 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\]
  12. 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\]
  13. Using strategy rm
  14. 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\]
  15. 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\]
  16. 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\]
  17. 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\]
  18. 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)))))