Average Error: 0.6 → 0.8
Time: 31.0s
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 r4837796 = 1.0;
        double r4837797 = 5.0;
        double r4837798 = v;
        double r4837799 = r4837798 * r4837798;
        double r4837800 = r4837797 * r4837799;
        double r4837801 = r4837796 - r4837800;
        double r4837802 = r4837799 - r4837796;
        double r4837803 = r4837801 / r4837802;
        double r4837804 = acos(r4837803);
        return r4837804;
}

double f(double v) {
        double r4837805 = v;
        double r4837806 = r4837805 * r4837805;
        double r4837807 = fma(r4837806, r4837806, r4837806);
        double r4837808 = 4.0;
        double r4837809 = -1.0;
        double r4837810 = fma(r4837807, r4837808, r4837809);
        double r4837811 = acos(r4837810);
        double r4837812 = log1p(r4837811);
        double r4837813 = log1p(r4837812);
        double r4837814 = expm1(r4837813);
        double r4837815 = expm1(r4837814);
        return r4837815;
}

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