Average Error: 17.2 → 0.1
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, 2 \cdot \left(\sinh \ell \cdot \cos \left(K \cdot 0.5\right)\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 (* 2.0 (* (sinh l) (cos (* K 0.5)))) 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, (2.0 * (sinh(l) * cos((K * 0.5)))), U);
}
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 fma(J, Float64(2.0 * Float64(sinh(l) * cos(Float64(K * 0.5)))), U)
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[(J * N[(2.0 * N[(N[Sinh[l], $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\mathsf{fma}\left(J, 2 \cdot \left(\sinh \ell \cdot \cos \left(K \cdot 0.5\right)\right), U\right)

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(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
  3. Applied egg-rr0.1

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

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

    \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(J, 2 \cdot \left(\sinh \ell \cdot \cos \left(K \cdot 0.5\right)\right), U\right)\right)}^{1}} \]
  6. Final simplification0.1

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

Reproduce

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