Average Error: 17.2 → 8.8
Time: 38.7s
Precision: 64
\[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\]
\[\mathsf{fma}\left(2, \left(\ell \cdot J\right), U\right)\]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\mathsf{fma}\left(2, \left(\ell \cdot J\right), U\right)
double f(double J, double l, double K, double U) {
        double r8835983 = J;
        double r8835984 = l;
        double r8835985 = exp(r8835984);
        double r8835986 = -r8835984;
        double r8835987 = exp(r8835986);
        double r8835988 = r8835985 - r8835987;
        double r8835989 = r8835983 * r8835988;
        double r8835990 = K;
        double r8835991 = 2.0;
        double r8835992 = r8835990 / r8835991;
        double r8835993 = cos(r8835992);
        double r8835994 = r8835989 * r8835993;
        double r8835995 = U;
        double r8835996 = r8835994 + r8835995;
        return r8835996;
}

double f(double J, double l, double __attribute__((unused)) K, double U) {
        double r8835997 = 2.0;
        double r8835998 = l;
        double r8835999 = J;
        double r8836000 = r8835998 * r8835999;
        double r8836001 = U;
        double r8836002 = fma(r8835997, r8836000, r8836001);
        return r8836002;
}

Error

Bits error versus J

Bits error versus l

Bits error versus K

Bits error versus U

Derivation

  1. Initial program 17.2

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\]
  2. Simplified17.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} \cdot \cos \left(\frac{K}{2}\right) - \frac{\cos \left(\frac{K}{2}\right)}{e^{\ell}}\right), J, U\right)}\]
  3. Taylor expanded around 0 8.8

    \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)}\]
  4. Simplified8.8

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, \left(J \cdot \ell\right), U\right)}\]
  5. Final simplification8.8

    \[\leadsto \mathsf{fma}\left(2, \left(\ell \cdot J\right), U\right)\]

Reproduce

herbie shell --seed 2019107 +o rules:numerics
(FPCore (J l K U)
  :name "Maksimov and Kolovsky, Equation (4)"
  (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2))) U))