Average Error: 17.7 → 0.1
Time: 11.4s
Precision: binary64
\[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
\[\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot J - 0, \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(\left(2 \cdot \sinh \ell\right) \cdot J - 0, \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 (- (* (* 2.0 (sinh l)) J) 0.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((((2.0 * sinh(l)) * J) - 0.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 17.7

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \left(e^{\ell} - e^{-\ell}\right), \cos \left(\frac{K}{2}\right), U\right)} \]
  3. Applied egg-rr0.1

    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{2 \cdot \sinh \ell}{\frac{1}{J}}}, \cos \left(\frac{K}{2}\right), U\right) \]
  4. Applied egg-rr0.1

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \sinh \ell\right) \cdot J - 0}, \cos \left(\frac{K}{2}\right), U\right) \]
  5. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot J - 0, \cos \left(\frac{K}{2}\right), U\right) \]

Reproduce

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