Average Error: 16.8 → 0.4
Time: 9.8s
Precision: binary64
\[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
\[U + \left(\mathsf{fma}\left(2, \ell, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot J \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
(FPCore (J l K U)
 :precision binary64
 (+
  U
  (*
   (*
    (fma
     2.0
     l
     (fma
      0.0003968253968253968
      (pow l 7.0)
      (fma
       0.016666666666666666
       (pow l 5.0)
       (* 0.3333333333333333 (pow l 3.0)))))
    (cos (* K 0.5)))
   J)))
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 U + ((fma(2.0, l, fma(0.0003968253968253968, pow(l, 7.0), fma(0.016666666666666666, pow(l, 5.0), (0.3333333333333333 * pow(l, 3.0))))) * cos((K * 0.5))) * J);
}
function code(J, l, K, U)
	return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U)
end
function code(J, l, K, U)
	return Float64(U + Float64(Float64(fma(2.0, l, fma(0.0003968253968253968, (l ^ 7.0), fma(0.016666666666666666, (l ^ 5.0), Float64(0.3333333333333333 * (l ^ 3.0))))) * cos(Float64(K * 0.5))) * J))
end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
code[J_, l_, K_, U_] := N[(U + N[(N[(N[(2.0 * l + N[(0.0003968253968253968 * N[Power[l, 7.0], $MachinePrecision] + N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision] + N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
U + \left(\mathsf{fma}\left(2, \ell, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot J

Error

Bits error versus J

Bits error versus l

Bits error versus K

Bits error versus U

Derivation

  1. Initial program 16.8

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

    \[\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.4

    \[\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.4

    \[\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. Taylor expanded in J around 0 0.4

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

    \[\leadsto \color{blue}{U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(\ell, 2, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)\right)} \]
  7. Taylor expanded in J around 0 0.4

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

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

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

Reproduce

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