?

Average Error: 27.24% → 0.15%
Time: 15.1s
Precision: binary64
Cost: 19776

?

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

Error?

Derivation?

  1. Initial program 27.24

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Taylor expanded in l around -inf 27.24

    \[\leadsto \left(J \cdot \color{blue}{\left(e^{\ell} - e^{-1 \cdot \ell}\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Simplified0.14

    \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \sinh \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    Proof

    [Start]27.24

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

    mul-1-neg [=>]27.24

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

    /-rgt-identity [<=]27.24

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

    metadata-eval [<=]27.24

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

    associate-/l* [<=]27.24

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

    *-commutative [=>]27.24

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

    associate-*r/ [<=]27.24

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

    sinh-def [<=]0.14

    \[ \left(J \cdot \left(2 \cdot \color{blue}{\sinh \ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  4. Applied egg-rr47.41

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)} - \left(1 - U\right)} \]
  5. Simplified0.15

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

    [Start]47.41

    \[ e^{\mathsf{log1p}\left(\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)} - \left(1 - U\right) \]

    associate--r- [=>]25.37

    \[ \color{blue}{\left(e^{\mathsf{log1p}\left(\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)} - 1\right) + U} \]

    expm1-def [=>]13.45

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)\right)} + U \]

    expm1-log1p [=>]0.14

    \[ \color{blue}{\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)} + U \]

    fma-udef [<=]0.14

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

    associate-*r* [=>]0.15

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

    *-commutative [=>]0.15

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

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

Alternatives

Alternative 1
Error0.14%
Cost13504
\[U + \left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) \]
Alternative 2
Error15.4%
Cost7504
\[\begin{array}{l} t_0 := 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\ t_1 := U + \left(J \cdot 2\right) \cdot \ell\\ \mathbf{if}\;U \leq -6.5 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;U \leq -3.3 \cdot 10^{-79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq -1.1 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;U \leq 1.9 \cdot 10^{-249}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\ \end{array} \]
Alternative 3
Error15.38%
Cost7504
\[\begin{array}{l} t_0 := \cos \left(0.5 \cdot K\right)\\ t_1 := U + \left(J \cdot 2\right) \cdot \ell\\ \mathbf{if}\;U \leq -6.5 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;U \leq -3.3 \cdot 10^{-79}:\\ \;\;\;\;\ell \cdot \left(\left(J \cdot 2\right) \cdot t_0\right)\\ \mathbf{elif}\;U \leq -1.1 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;U \leq 2.6 \cdot 10^{-248}:\\ \;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\ \end{array} \]
Alternative 4
Error0.78%
Cost7488
\[U + \cos \left(\frac{K}{2}\right) \cdot \frac{J \cdot 2}{\ell \cdot -0.16666666666666666 + \frac{1}{\ell}} \]
Alternative 5
Error0.94%
Cost7104
\[U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) \]
Alternative 6
Error13.9%
Cost6848
\[U + J \cdot \left(2 \cdot \sinh \ell\right) \]
Alternative 7
Error28.61%
Cost584
\[\begin{array}{l} \mathbf{if}\;U \leq -1.45 \cdot 10^{-189}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 9.4 \cdot 10^{-204}:\\ \;\;\;\;\ell \cdot \left(J + J\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
Alternative 8
Error14.33%
Cost448
\[U + \left(J \cdot 2\right) \cdot \ell \]
Alternative 9
Error29.13%
Cost64
\[U \]

Error

Reproduce?

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