Average Error: 18.1 → 17.4
Time: 18.1s
Precision: binary64
Cost: 28164
\[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}\]
\[\begin{array}{l} \mathbf{if}\;J \leq -3.2764703254569817 \cdot 10^{-226}:\\ \;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \mathbf{elif}\;J \leq 4.665136132356276 \cdot 10^{-203}:\\ \;\;\;\;U\\ \mathbf{elif}\;J \leq 1.9974033146612488 \cdot 10^{-157}:\\ \;\;\;\;-U\\ \mathbf{elif}\;J \leq 5.037250337742537 \cdot 10^{-81}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \end{array}\]
\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}
\begin{array}{l}
\mathbf{if}\;J \leq -3.2764703254569817 \cdot 10^{-226}:\\
\;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\

\mathbf{elif}\;J \leq 4.665136132356276 \cdot 10^{-203}:\\
\;\;\;\;U\\

\mathbf{elif}\;J \leq 1.9974033146612488 \cdot 10^{-157}:\\
\;\;\;\;-U\\

\mathbf{elif}\;J \leq 5.037250337742537 \cdot 10^{-81}:\\
\;\;\;\;U\\

\mathbf{else}:\\
\;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\

\end{array}
(FPCore (J K U)
 :precision binary64
 (*
  (* (* -2.0 J) (cos (/ K 2.0)))
  (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) (cos (/ K 2.0)))) 2.0)))))
(FPCore (J K U)
 :precision binary64
 (if (<= J -3.2764703254569817e-226)
   (*
    (* (* J -2.0) (cos (/ K 2.0)))
    (sqrt (+ 1.0 (pow (/ U (* (cos (/ K 2.0)) (* J 2.0))) 2.0))))
   (if (<= J 4.665136132356276e-203)
     U
     (if (<= J 1.9974033146612488e-157)
       (- U)
       (if (<= J 5.037250337742537e-81)
         U
         (*
          (* (* J -2.0) (cos (/ K 2.0)))
          (sqrt (+ 1.0 (pow (/ U (* (cos (/ K 2.0)) (* J 2.0))) 2.0)))))))))
double code(double J, double K, double U) {
	return ((-2.0 * J) * cos(K / 2.0)) * sqrt(1.0 + pow((U / ((2.0 * J) * cos(K / 2.0))), 2.0));
}
double code(double J, double K, double U) {
	double tmp;
	if (J <= -3.2764703254569817e-226) {
		tmp = ((J * -2.0) * cos(K / 2.0)) * sqrt(1.0 + pow((U / (cos(K / 2.0) * (J * 2.0))), 2.0));
	} else if (J <= 4.665136132356276e-203) {
		tmp = U;
	} else if (J <= 1.9974033146612488e-157) {
		tmp = -U;
	} else if (J <= 5.037250337742537e-81) {
		tmp = U;
	} else {
		tmp = ((J * -2.0) * cos(K / 2.0)) * sqrt(1.0 + pow((U / (cos(K / 2.0) * (J * 2.0))), 2.0));
	}
	return tmp;
}

Error

Bits error versus J

Bits error versus K

Bits error versus U

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error27.2
Cost20866
\[\begin{array}{l} \mathbf{if}\;J \leq -9.549762233492366 \cdot 10^{+85}:\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;J \leq -4.026635994422866 \cdot 10^{+44}:\\ \;\;\;\;\left(J \cdot -2\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \mathbf{elif}\;J \leq -7.371847444837888 \cdot 10^{-226}:\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;J \leq 4.344975775647229 \cdot 10^{-202}:\\ \;\;\;\;U\\ \mathbf{elif}\;J \leq 1.4928011354216868 \cdot 10^{-157}:\\ \;\;\;\;-U\\ \mathbf{elif}\;J \leq 2.9747408206806927 \cdot 10^{-36}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\ \end{array}\]
Alternative 2
Error27.0
Cost8132
\[\begin{array}{l} \mathbf{if}\;J \leq -1.3674081533166613 \cdot 10^{-225}:\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;J \leq 1.0413640422795948 \cdot 10^{-203}:\\ \;\;\;\;U\\ \mathbf{elif}\;J \leq 1.9974033146612488 \cdot 10^{-157}:\\ \;\;\;\;-U\\ \mathbf{elif}\;J \leq 1.5850819538915512 \cdot 10^{-32}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\ \end{array}\]
Alternative 3
Error46.8
Cost449
\[\begin{array}{l} \mathbf{if}\;U \leq -2.8315071369987278 \cdot 10^{-96}:\\ \;\;\;\;-U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array}\]
Alternative 4
Error46.6
Cost64
\[U\]
Alternative 5
Error61.9
Cost64
\[1\]

Error

Derivation

  1. Split input into 3 regimes
  2. if J < -3.27647032545698172e-226 or 5.0372503377425366e-81 < J

    1. Initial program 11.4

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}\]
    2. Simplified11.4

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

    if -3.27647032545698172e-226 < J < 4.66513613235627618e-203 or 1.99740331466124876e-157 < J < 5.0372503377425366e-81

    1. Initial program 38.8

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}\]
    2. Taylor expanded around -inf 34.8

      \[\leadsto \color{blue}{U}\]
    3. Simplified34.8

      \[\leadsto \color{blue}{U}\]

    if 4.66513613235627618e-203 < J < 1.99740331466124876e-157

    1. Initial program 35.0

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}\]
    2. Taylor expanded around 0 39.0

      \[\leadsto \color{blue}{-1 \cdot U}\]
    3. Simplified39.0

      \[\leadsto \color{blue}{-U}\]
    4. Simplified39.0

      \[\leadsto \color{blue}{-U}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -3.2764703254569817 \cdot 10^{-226}:\\ \;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \mathbf{elif}\;J \leq 4.665136132356276 \cdot 10^{-203}:\\ \;\;\;\;U\\ \mathbf{elif}\;J \leq 1.9974033146612488 \cdot 10^{-157}:\\ \;\;\;\;-U\\ \mathbf{elif}\;J \leq 5.037250337742537 \cdot 10^{-81}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2021044 
(FPCore (J K U)
  :name "Maksimov and Kolovsky, Equation (3)"
  :precision binary64
  (* (* (* -2.0 J) (cos (/ K 2.0))) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) (cos (/ K 2.0)))) 2.0)))))