Average Error: 18.4 → 8.2
Time: 12.0s
Precision: binary64
\[\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} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := \left(-2 \cdot J\right) \cdot t_0\\ \mathbf{if}\;U \leq 1.1056860198100382 \cdot 10^{+220}:\\ \;\;\;\;t_1 \cdot \mathsf{hypot}\left(1, \frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)\\ \mathbf{elif}\;U \leq 3.069282919857268 \cdot 10^{+290}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{t_0}}{J \cdot 2}\right)\\ \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}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(-2 \cdot J\right) \cdot t_0\\
\mathbf{if}\;U \leq 1.1056860198100382 \cdot 10^{+220}:\\
\;\;\;\;t_1 \cdot \mathsf{hypot}\left(1, \frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)\\

\mathbf{elif}\;U \leq 3.069282919857268 \cdot 10^{+290}:\\
\;\;\;\;U\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{t_0}}{J \cdot 2}\right)\\


\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
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (* (* -2.0 J) t_0)))
   (if (<= U 1.1056860198100382e+220)
     (* t_1 (hypot 1.0 (/ U (* t_0 (* J 2.0)))))
     (if (<= U 3.069282919857268e+290)
       U
       (* t_1 (hypot 1.0 (/ (/ U t_0) (* J 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 t_0 = cos(K / 2.0);
	double t_1 = (-2.0 * J) * t_0;
	double tmp;
	if (U <= 1.1056860198100382e+220) {
		tmp = t_1 * hypot(1.0, (U / (t_0 * (J * 2.0))));
	} else if (U <= 3.069282919857268e+290) {
		tmp = U;
	} else {
		tmp = t_1 * hypot(1.0, ((U / t_0) / (J * 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

Derivation

  1. Split input into 3 regimes
  2. if U < 1.1056860198100382e220

    1. Initial program 16.5

      \[\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. Simplified6.6

      \[\leadsto \color{blue}{\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)} \]

    if 1.1056860198100382e220 < U < 3.0692829198572679e290

    1. Initial program 43.1

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

      \[\leadsto \color{blue}{\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)} \]
    3. Taylor expanded in U around -inf 31.9

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

    if 3.0692829198572679e290 < U

    1. Initial program 48.6

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

      \[\leadsto \color{blue}{\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)} \]
    3. Applied associate-/r*_binary6427.4

      \[\leadsto \left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{\frac{U}{\cos \left(\frac{K}{2}\right)}}{J \cdot 2}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq 1.1056860198100382 \cdot 10^{+220}:\\ \;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)\\ \mathbf{elif}\;U \leq 3.069282919857268 \cdot 10^{+290}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{\cos \left(\frac{K}{2}\right)}}{J \cdot 2}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2021215 
(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)))))