Average Error: 18.0 → 0.7
Time: 54.6s
Precision: 64
\[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\]
\[\mathsf{fma}\left(\ell, \left(J + J\right) \cdot \cos \left(0.5 \cdot K\right), U\right)\]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\mathsf{fma}\left(\ell, \left(J + J\right) \cdot \cos \left(0.5 \cdot K\right), U\right)
double f(double J, double l, double K, double U) {
        double r5710947 = J;
        double r5710948 = l;
        double r5710949 = exp(r5710948);
        double r5710950 = -r5710948;
        double r5710951 = exp(r5710950);
        double r5710952 = r5710949 - r5710951;
        double r5710953 = r5710947 * r5710952;
        double r5710954 = K;
        double r5710955 = 2.0;
        double r5710956 = r5710954 / r5710955;
        double r5710957 = cos(r5710956);
        double r5710958 = r5710953 * r5710957;
        double r5710959 = U;
        double r5710960 = r5710958 + r5710959;
        return r5710960;
}

double f(double J, double l, double K, double U) {
        double r5710961 = l;
        double r5710962 = J;
        double r5710963 = r5710962 + r5710962;
        double r5710964 = 0.5;
        double r5710965 = K;
        double r5710966 = r5710964 * r5710965;
        double r5710967 = cos(r5710966);
        double r5710968 = r5710963 * r5710967;
        double r5710969 = U;
        double r5710970 = fma(r5710961, r5710968, r5710969);
        return r5710970;
}

Error

Bits error versus J

Bits error versus l

Bits error versus K

Bits error versus U

Derivation

  1. Initial program 18.0

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

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

    \[\leadsto \mathsf{fma}\left(\cos \left(\frac{K}{2}\right), \color{blue}{2 \cdot \left(J \cdot \ell\right)}, U\right)\]
  4. Simplified0.7

    \[\leadsto \mathsf{fma}\left(\cos \left(\frac{K}{2}\right), \color{blue}{\left(\ell + \ell\right) \cdot J}, U\right)\]
  5. Taylor expanded around inf 0.7

    \[\leadsto \color{blue}{U + 2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \ell\right)\right)}\]
  6. Simplified0.7

    \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(J + J\right), U\right)}\]
  7. Final simplification0.7

    \[\leadsto \mathsf{fma}\left(\ell, \left(J + J\right) \cdot \cos \left(0.5 \cdot K\right), U\right)\]

Reproduce

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