Average Error: 18.0 → 0.3
Time: 9.0s
Precision: binary64
\[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
\[\mathsf{fma}\left(J \cdot \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(2, \ell, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right), \cos \left(\frac{K}{2}\right), U\right) \]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\mathsf{fma}\left(J \cdot \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(2, \ell, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right), \cos \left(\frac{K}{2}\right), U\right)
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
(FPCore (J l K U)
 :precision binary64
 (fma
  (*
   J
   (fma
    0.0003968253968253968
    (pow l 7.0)
    (fma
     2.0
     l
     (fma
      0.3333333333333333
      (pow l 3.0)
      (* 0.016666666666666666 (pow l 5.0))))))
  (cos (/ K 2.0))
  U))
double code(double J, double l, double K, double U) {
	return ((J * (exp(l) - exp(-l))) * cos(K / 2.0)) + U;
}
double code(double J, double l, double K, double U) {
	return fma((J * fma(0.0003968253968253968, pow(l, 7.0), fma(2.0, l, fma(0.3333333333333333, pow(l, 3.0), (0.016666666666666666 * pow(l, 5.0)))))), cos(K / 2.0), U);
}

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.0

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

    \[\leadsto \mathsf{fma}\left(J \cdot \color{blue}{\left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + \left(0.016666666666666666 \cdot {\ell}^{5} + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\right)}, \cos \left(\frac{K}{2}\right), U\right) \]
  4. Simplified0.3

    \[\leadsto \mathsf{fma}\left(J \cdot \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(2, \ell, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)}, \cos \left(\frac{K}{2}\right), U\right) \]
  5. Final simplification0.3

    \[\leadsto \mathsf{fma}\left(J \cdot \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(2, \ell, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right), \cos \left(\frac{K}{2}\right), U\right) \]

Reproduce

herbie shell --seed 2021224 
(FPCore (J l K U)
  :name "Maksimov and Kolovsky, Equation (4)"
  :precision binary64
  (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))