Average Error: 18.1 → 8.4
Time: 15.6s
Precision: binary64
Cost: 20352
\[\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}} \]
\[J \cdot \left(\mathsf{hypot}\left(1, \frac{\frac{\frac{U}{\cos \left(K \cdot 0.5\right)}}{2}}{J}\right) \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \]
(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
 (*
  J
  (*
   (hypot 1.0 (/ (/ (/ U (cos (* K 0.5))) 2.0) J))
   (* -2.0 (cos (/ K 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) {
	return J * (hypot(1.0, (((U / cos((K * 0.5))) / 2.0) / J)) * (-2.0 * cos((K / 2.0))));
}
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) {
	return J * (Math.hypot(1.0, (((U / Math.cos((K * 0.5))) / 2.0) / J)) * (-2.0 * Math.cos((K / 2.0))));
}
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):
	return J * (math.hypot(1.0, (((U / math.cos((K * 0.5))) / 2.0) / J)) * (-2.0 * math.cos((K / 2.0))))
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)
	return Float64(J * Float64(hypot(1.0, Float64(Float64(Float64(U / cos(Float64(K * 0.5))) / 2.0) / J)) * Float64(-2.0 * cos(Float64(K / 2.0)))))
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 = code(J, K, U)
	tmp = J * (hypot(1.0, (((U / cos((K * 0.5))) / 2.0) / J)) * (-2.0 * cos((K / 2.0))));
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_] := N[(J * N[(N[Sqrt[1.0 ^ 2 + N[(N[(N[(U / N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision] * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\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}}
J \cdot \left(\mathsf{hypot}\left(1, \frac{\frac{\frac{U}{\cos \left(K \cdot 0.5\right)}}{2}}{J}\right) \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 18.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. Simplified8.4

    \[\leadsto \color{blue}{J \cdot \left(\mathsf{hypot}\left(1, \frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right) \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right)} \]
    Proof
    (*.f64 J (*.f64 (hypot.f64 1 (/.f64 U (*.f64 (cos.f64 (/.f64 K 2)) (*.f64 J 2)))) (*.f64 -2 (cos.f64 (/.f64 K 2))))): 0 points increase in error, 0 points decrease in error
    (*.f64 J (*.f64 (hypot.f64 1 (/.f64 U (*.f64 (cos.f64 (/.f64 K 2)) (Rewrite<= *-commutative_binary64 (*.f64 2 J))))) (*.f64 -2 (cos.f64 (/.f64 K 2))))): 0 points increase in error, 0 points decrease in error
    (*.f64 J (*.f64 (hypot.f64 1 (/.f64 U (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))))) (*.f64 -2 (cos.f64 (/.f64 K 2))))): 0 points increase in error, 0 points decrease in error
    (*.f64 J (*.f64 (Rewrite<= hypot-1-def_binary64 (sqrt.f64 (+.f64 1 (*.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))))))) (*.f64 -2 (cos.f64 (/.f64 K 2))))): 51 points increase in error, 0 points decrease in error
    (*.f64 J (*.f64 (sqrt.f64 (+.f64 1 (Rewrite<= unpow2_binary64 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) (*.f64 -2 (cos.f64 (/.f64 K 2))))): 0 points increase in error, 0 points decrease in error
    (*.f64 J (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 -2 (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 J (Rewrite<= associate-*r*_binary64 (*.f64 -2 (*.f64 (cos.f64 (/.f64 K 2)) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2))))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 J -2) (*.f64 (cos.f64 (/.f64 K 2)) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 -2 J)) (*.f64 (cos.f64 (/.f64 K 2)) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2))))): 2 points increase in error, 10 points decrease in error
  3. Applied egg-rr8.4

    \[\leadsto J \cdot \left(\mathsf{hypot}\left(1, \color{blue}{\frac{U}{\cos \left(K \cdot 0.5\right)} \cdot \frac{1}{J + J}}\right) \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \]
  4. Applied egg-rr8.4

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

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

Alternatives

Alternative 1
Error27.0
Cost13828
\[\begin{array}{l} t_0 := \cos \left(K \cdot 0.5\right)\\ t_1 := J \cdot \left(-2 \cdot t_0\right)\\ \mathbf{if}\;U \leq -1.290061581233576 \cdot 10^{+254}:\\ \;\;\;\;\frac{{t_0}^{2}}{\frac{\frac{\frac{U}{J}}{J}}{-2}} - U\\ \mathbf{elif}\;U \leq -6.118887194377075 \cdot 10^{+126}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq -2.80879240252137 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;U \leq -4.281511099529597 \cdot 10^{-53}:\\ \;\;\;\;J \cdot \left(-0.5 \cdot \frac{\sqrt[3]{-8}}{\frac{J}{U}}\right)\\ \mathbf{elif}\;U \leq 1.7712691110195176 \cdot 10^{+148}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Error

Reproduce

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