Average Error: 0.6 → 0.8
Time: 30.7s
Precision: 64
\[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\]
\[\mathsf{expm1}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(v \cdot v, v \cdot v, v \cdot v\right), 4, -1\right)\right)\right)\right)\right)\right)\]
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
\mathsf{expm1}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(v \cdot v, v \cdot v, v \cdot v\right), 4, -1\right)\right)\right)\right)\right)\right)
double f(double v) {
        double r13895051 = 1.0;
        double r13895052 = 5.0;
        double r13895053 = v;
        double r13895054 = r13895053 * r13895053;
        double r13895055 = r13895052 * r13895054;
        double r13895056 = r13895051 - r13895055;
        double r13895057 = r13895054 - r13895051;
        double r13895058 = r13895056 / r13895057;
        double r13895059 = acos(r13895058);
        return r13895059;
}

double f(double v) {
        double r13895060 = v;
        double r13895061 = r13895060 * r13895060;
        double r13895062 = fma(r13895061, r13895061, r13895061);
        double r13895063 = 4.0;
        double r13895064 = -1.0;
        double r13895065 = fma(r13895062, r13895063, r13895064);
        double r13895066 = acos(r13895065);
        double r13895067 = log1p(r13895066);
        double r13895068 = log1p(r13895067);
        double r13895069 = expm1(r13895068);
        double r13895070 = expm1(r13895069);
        return r13895070;
}

Error

Bits error versus v

Derivation

  1. Initial program 0.6

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\]
  2. Simplified0.6

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(-5 \cdot v, v, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\]
  3. Taylor expanded around 0 0.8

    \[\leadsto \cos^{-1} \color{blue}{\left(\left(4 \cdot {v}^{4} + 4 \cdot {v}^{2}\right) - 1\right)}\]
  4. Simplified0.8

    \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(v \cdot v, v \cdot v, v \cdot v\right), 4, -1\right)\right)}\]
  5. Using strategy rm
  6. Applied expm1-log1p-u0.8

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(v \cdot v, v \cdot v, v \cdot v\right), 4, -1\right)\right)\right)\right)}\]
  7. Using strategy rm
  8. Applied expm1-log1p-u0.8

    \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(v \cdot v, v \cdot v, v \cdot v\right), 4, -1\right)\right)\right)\right)\right)}\right)\]
  9. Final simplification0.8

    \[\leadsto \mathsf{expm1}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(v \cdot v, v \cdot v, v \cdot v\right), 4, -1\right)\right)\right)\right)\right)\right)\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (v)
  :name "Falkner and Boettcher, Appendix B, 1"
  (acos (/ (- 1 (* 5 (* v v))) (- (* v v) 1))))