?

Average Accuracy: 71.5% → 85.9%
Time: 20.9s
Precision: binary64
Cost: 20617

?

\[\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)\\ \mathbf{if}\;J \leq -8.5 \cdot 10^{-182} \lor \neg \left(J \leq 1.45 \cdot 10^{-285}\right):\\ \;\;\;\;\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \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))))
   (if (or (<= J -8.5e-182) (not (<= J 1.45e-285)))
     (* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
     U)))
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 tmp;
	if ((J <= -8.5e-182) || !(J <= 1.45e-285)) {
		tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
	} else {
		tmp = U;
	}
	return tmp;
}
public static double code(double J, double K, double U) {
	return ((-2.0 * J) * Math.cos((K / 2.0))) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * Math.cos((K / 2.0)))), 2.0)));
}
public static double code(double J, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	double tmp;
	if ((J <= -8.5e-182) || !(J <= 1.45e-285)) {
		tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, K, U):
	return ((-2.0 * J) * math.cos((K / 2.0))) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * math.cos((K / 2.0)))), 2.0)))
def code(J, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if (J <= -8.5e-182) or not (J <= 1.45e-285):
		tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0))))
	else:
		tmp = U
	return tmp
function code(J, K, U)
	return Float64(Float64(Float64(-2.0 * J) * cos(Float64(K / 2.0))) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * cos(Float64(K / 2.0)))) ^ 2.0))))
end
function code(J, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if ((J <= -8.5e-182) || !(J <= 1.45e-285))
		tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0)))));
	else
		tmp = U;
	end
	return tmp
end
function tmp = code(J, K, U)
	tmp = ((-2.0 * J) * cos((K / 2.0))) * sqrt((1.0 + ((U / ((2.0 * J) * cos((K / 2.0)))) ^ 2.0)));
end
function tmp_2 = code(J, K, U)
	t_0 = cos((K / 2.0));
	tmp = 0.0;
	if ((J <= -8.5e-182) || ~((J <= 1.45e-285)))
		tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[J, -8.5e-182], N[Not[LessEqual[J, 1.45e-285]], $MachinePrecision]], N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], U]]
\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)\\
\mathbf{if}\;J \leq -8.5 \cdot 10^{-182} \lor \neg \left(J \leq 1.45 \cdot 10^{-285}\right):\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;U\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if J < -8.5000000000000001e-182 or 1.45e-285 < J

    1. Initial program 76.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. Simplified91.0%

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

      [Start]76.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}} \]

      *-commutative [=>]76.6

      \[ \left(\color{blue}{\left(J \cdot -2\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}} \]

      associate-*l* [=>]76.6

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

      unpow2 [=>]76.6

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

      hypot-1-def [=>]91.0

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

      *-commutative [=>]91.0

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

      associate-*l* [=>]91.0

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

    if -8.5000000000000001e-182 < J < 1.45e-285

    1. Initial program 34.2%

      \[\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. Simplified59.2%

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

      [Start]34.2

      \[ \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}} \]

      *-commutative [=>]34.2

      \[ \left(\color{blue}{\left(J \cdot -2\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}} \]

      associate-*l* [=>]34.2

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

      unpow2 [=>]34.2

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

      hypot-1-def [=>]59.2

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

      *-commutative [=>]59.2

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

      associate-*l* [=>]59.2

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

      \[\leadsto \color{blue}{U} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -8.5 \cdot 10^{-182} \lor \neg \left(J \leq 1.45 \cdot 10^{-285}\right):\\ \;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternatives

Alternative 1
Accuracy72.2%
Cost13961
\[\begin{array}{l} \mathbf{if}\;J \leq -1.1 \cdot 10^{-168} \lor \neg \left(J \leq 3.8 \cdot 10^{-174}\right):\\ \;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]
Alternative 2
Accuracy72.3%
Cost13961
\[\begin{array}{l} \mathbf{if}\;J \leq -1.3 \cdot 10^{-168} \lor \neg \left(J \leq 4.6 \cdot 10^{-175}\right):\\ \;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]
Alternative 3
Accuracy63.9%
Cost7568
\[\begin{array}{l} t_0 := -2 \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\ \mathbf{if}\;U \leq -1.75 \cdot 10^{+223}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -6 \cdot 10^{-67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq 6.8 \cdot 10^{-41}:\\ \;\;\;\;\left(J \cdot -2\right) \cdot \cos \left(K \cdot 0.5\right)\\ \mathbf{elif}\;U \leq 8.4 \cdot 10^{+130}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
Alternative 4
Accuracy57.6%
Cost7440
\[\begin{array}{l} \mathbf{if}\;U \leq -1.15 \cdot 10^{+224}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -3.2 \cdot 10^{+137}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J}{\frac{U}{J}}\right)\\ \mathbf{elif}\;U \leq 32000000000:\\ \;\;\;\;\left(J \cdot -2\right) \cdot \cos \left(K \cdot 0.5\right)\\ \mathbf{elif}\;U \leq 1.26 \cdot 10^{+132}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{J \cdot J}{U}, -U\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
Alternative 5
Accuracy57.7%
Cost7244
\[\begin{array}{l} \mathbf{if}\;U \leq -4.1 \cdot 10^{+223}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -5.6 \cdot 10^{+137}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J}{\frac{U}{J}}\right)\\ \mathbf{elif}\;U \leq 31000000000:\\ \;\;\;\;\left(J \cdot -2\right) \cdot \cos \left(K \cdot 0.5\right)\\ \mathbf{elif}\;U \leq 1.1 \cdot 10^{+132}:\\ \;\;\;\;-U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
Alternative 6
Accuracy40.7%
Cost836
\[\begin{array}{l} \mathbf{if}\;J \leq -2.4 \cdot 10^{-23}:\\ \;\;\;\;-2 \cdot \left(J + \frac{U}{J} \cdot \left(U \cdot 0.125\right)\right)\\ \mathbf{elif}\;J \leq 2.6 \cdot 10^{-291}:\\ \;\;\;\;U\\ \mathbf{elif}\;J \leq 3.8 \cdot 10^{-171}:\\ \;\;\;\;-U\\ \mathbf{elif}\;J \leq 0.0255:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;J \cdot -2\\ \end{array} \]
Alternative 7
Accuracy40.7%
Cost720
\[\begin{array}{l} \mathbf{if}\;J \leq -1.15 \cdot 10^{-26}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;J \leq 2.7 \cdot 10^{-291}:\\ \;\;\;\;U\\ \mathbf{elif}\;J \leq 3.4 \cdot 10^{-171}:\\ \;\;\;\;-U\\ \mathbf{elif}\;J \leq 4.8 \cdot 10^{-6}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;J \cdot -2\\ \end{array} \]
Alternative 8
Accuracy27.2%
Cost524
\[\begin{array}{l} \mathbf{if}\;K \leq -3.6 \cdot 10^{-152}:\\ \;\;\;\;U\\ \mathbf{elif}\;K \leq 1.8 \cdot 10^{-129}:\\ \;\;\;\;-U\\ \mathbf{elif}\;K \leq 1.2 \cdot 10^{+132}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]
Alternative 9
Accuracy27.7%
Cost64
\[U \]

Error

Reproduce?

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