
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t_0}\right)}^{2}}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t_0}\right)}^{2}}
\end{array}
\end{array}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 1e+304)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U;
} else if (t_1 <= 1e+304) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U;
} else if (t_1 <= 1e+304) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U elif t_1 <= 1e+304: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U); elseif (t_1 <= 1e+304) 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
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 1e+304) tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U), If[LessEqual[t$95$1, 1e+304], 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]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 10^{+304}:\\
\;\;\;\;\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}
\end{array}
if (*.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)))) < -inf.0Initial program 6.1%
*-commutative6.1%
associate-*l*6.1%
associate-*r*6.1%
*-commutative6.1%
associate-*l*6.1%
*-commutative6.1%
unpow26.1%
hypot-1-def59.3%
*-commutative59.3%
associate-*l*59.3%
Simplified59.3%
Taylor expanded in J around 0 44.2%
neg-mul-144.2%
Simplified44.2%
if -inf.0 < (*.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)))) < 9.9999999999999994e303Initial program 99.9%
*-commutative99.9%
associate-*l*99.9%
unpow299.9%
hypot-1-def99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
if 9.9999999999999994e303 < (*.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)))) Initial program 5.5%
*-commutative5.5%
associate-*l*5.5%
associate-*r*5.5%
*-commutative5.5%
associate-*l*5.5%
*-commutative5.5%
unpow25.5%
hypot-1-def66.5%
*-commutative66.5%
associate-*l*66.5%
Simplified66.5%
Taylor expanded in U around -inf 52.7%
Final simplification85.2%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U 1.15e+288)
(* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))
(- U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (U <= 1.15e+288) {
tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
} else {
tmp = -U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (U <= 1.15e+288) {
tmp = J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if U <= 1.15e+288: tmp = J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0)))))) else: tmp = -U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U <= 1.15e+288) tmp = Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))); else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (U <= 1.15e+288) tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[U, 1.15e+288], N[(J * N[(t$95$0 * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U)]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U \leq 1.15 \cdot 10^{+288}:\\
\;\;\;\;J \cdot \left(t_0 \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 1.14999999999999997e288Initial program 73.3%
*-commutative73.3%
associate-*l*73.3%
associate-*r*73.3%
*-commutative73.3%
associate-*l*73.2%
*-commutative73.2%
unpow273.2%
hypot-1-def90.1%
*-commutative90.1%
associate-*l*90.1%
Simplified90.1%
if 1.14999999999999997e288 < U Initial program 33.2%
*-commutative33.2%
associate-*l*33.2%
associate-*r*33.2%
*-commutative33.2%
associate-*l*32.8%
*-commutative32.8%
unpow232.8%
hypot-1-def32.8%
*-commutative32.8%
associate-*l*32.8%
Simplified32.8%
Taylor expanded in J around 0 75.0%
neg-mul-175.0%
Simplified75.0%
Final simplification89.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 5e+200) (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ U (* J 2.0)))) (if (<= U 1.42e+274) U (- U))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 5e+200) {
tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0)));
} else if (U <= 1.42e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 5e+200) {
tmp = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U / (J * 2.0)));
} else if (U <= 1.42e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 5e+200: tmp = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U / (J * 2.0))) elif U <= 1.42e+274: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 5e+200) tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U / Float64(J * 2.0)))); elseif (U <= 1.42e+274) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 5e+200) tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0))); elseif (U <= 1.42e+274) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 5e+200], N[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 1.42e+274], U, (-U)]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 5 \cdot 10^{+200}:\\
\;\;\;\;\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{elif}\;U \leq 1.42 \cdot 10^{+274}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 5.00000000000000019e200Initial program 76.2%
*-commutative76.2%
associate-*l*76.2%
unpow276.2%
hypot-1-def92.1%
*-commutative92.1%
associate-*l*92.1%
Simplified92.1%
Taylor expanded in K around 0 77.8%
if 5.00000000000000019e200 < U < 1.42e274Initial program 41.0%
*-commutative41.0%
associate-*l*41.0%
associate-*r*41.0%
*-commutative41.0%
associate-*l*40.9%
*-commutative40.9%
unpow240.9%
hypot-1-def65.4%
*-commutative65.4%
associate-*l*65.4%
Simplified65.4%
Taylor expanded in U around -inf 73.8%
if 1.42e274 < U Initial program 50.0%
*-commutative50.0%
associate-*l*50.0%
associate-*r*50.0%
*-commutative50.0%
associate-*l*49.5%
*-commutative49.5%
unpow249.5%
hypot-1-def69.6%
*-commutative69.6%
associate-*l*69.6%
Simplified69.6%
Taylor expanded in J around 0 68.0%
neg-mul-168.0%
Simplified68.0%
Final simplification77.1%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= U 5.4e+36)
t_0
(if (<= U 4.5e+56)
U
(if (<= U 3.4e+121)
t_0
(if (<= U 4.5e+154)
U
(if (<= U 6e+178)
t_0
(if (<= U 9.5e+200) (- U) (if (<= U 1.6e+274) U (- U))))))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (U <= 5.4e+36) {
tmp = t_0;
} else if (U <= 4.5e+56) {
tmp = U;
} else if (U <= 3.4e+121) {
tmp = t_0;
} else if (U <= 4.5e+154) {
tmp = U;
} else if (U <= 6e+178) {
tmp = t_0;
} else if (U <= 9.5e+200) {
tmp = -U;
} else if (U <= 1.6e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (u <= 5.4d+36) then
tmp = t_0
else if (u <= 4.5d+56) then
tmp = u
else if (u <= 3.4d+121) then
tmp = t_0
else if (u <= 4.5d+154) then
tmp = u
else if (u <= 6d+178) then
tmp = t_0
else if (u <= 9.5d+200) then
tmp = -u
else if (u <= 1.6d+274) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (U <= 5.4e+36) {
tmp = t_0;
} else if (U <= 4.5e+56) {
tmp = U;
} else if (U <= 3.4e+121) {
tmp = t_0;
} else if (U <= 4.5e+154) {
tmp = U;
} else if (U <= 6e+178) {
tmp = t_0;
} else if (U <= 9.5e+200) {
tmp = -U;
} else if (U <= 1.6e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if U <= 5.4e+36: tmp = t_0 elif U <= 4.5e+56: tmp = U elif U <= 3.4e+121: tmp = t_0 elif U <= 4.5e+154: tmp = U elif U <= 6e+178: tmp = t_0 elif U <= 9.5e+200: tmp = -U elif U <= 1.6e+274: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (U <= 5.4e+36) tmp = t_0; elseif (U <= 4.5e+56) tmp = U; elseif (U <= 3.4e+121) tmp = t_0; elseif (U <= 4.5e+154) tmp = U; elseif (U <= 6e+178) tmp = t_0; elseif (U <= 9.5e+200) tmp = Float64(-U); elseif (U <= 1.6e+274) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (U <= 5.4e+36) tmp = t_0; elseif (U <= 4.5e+56) tmp = U; elseif (U <= 3.4e+121) tmp = t_0; elseif (U <= 4.5e+154) tmp = U; elseif (U <= 6e+178) tmp = t_0; elseif (U <= 9.5e+200) tmp = -U; elseif (U <= 1.6e+274) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, 5.4e+36], t$95$0, If[LessEqual[U, 4.5e+56], U, If[LessEqual[U, 3.4e+121], t$95$0, If[LessEqual[U, 4.5e+154], U, If[LessEqual[U, 6e+178], t$95$0, If[LessEqual[U, 9.5e+200], (-U), If[LessEqual[U, 1.6e+274], U, (-U)]]]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;U \leq 5.4 \cdot 10^{+36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq 4.5 \cdot 10^{+56}:\\
\;\;\;\;U\\
\mathbf{elif}\;U \leq 3.4 \cdot 10^{+121}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq 4.5 \cdot 10^{+154}:\\
\;\;\;\;U\\
\mathbf{elif}\;U \leq 6 \cdot 10^{+178}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq 9.5 \cdot 10^{+200}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq 1.6 \cdot 10^{+274}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 5.4000000000000002e36 or 4.5000000000000003e56 < U < 3.4000000000000001e121 or 4.50000000000000009e154 < U < 6.00000000000000031e178Initial program 79.0%
*-commutative79.0%
associate-*l*79.0%
associate-*r*79.0%
*-commutative79.0%
associate-*l*79.0%
*-commutative79.0%
unpow279.0%
hypot-1-def92.8%
*-commutative92.8%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in U around 0 60.3%
if 5.4000000000000002e36 < U < 4.5000000000000003e56 or 3.4000000000000001e121 < U < 4.50000000000000009e154 or 9.49999999999999988e200 < U < 1.59999999999999991e274Initial program 39.1%
*-commutative39.1%
associate-*l*39.1%
associate-*r*39.1%
*-commutative39.1%
associate-*l*38.9%
*-commutative38.9%
unpow238.9%
hypot-1-def69.4%
*-commutative69.4%
associate-*l*69.4%
Simplified69.4%
Taylor expanded in U around -inf 67.9%
if 6.00000000000000031e178 < U < 9.49999999999999988e200 or 1.59999999999999991e274 < U Initial program 46.7%
*-commutative46.7%
associate-*l*46.7%
associate-*r*46.7%
*-commutative46.7%
associate-*l*46.3%
*-commutative46.3%
unpow246.3%
hypot-1-def77.2%
*-commutative77.2%
associate-*l*77.2%
Simplified77.2%
Taylor expanded in J around 0 67.7%
neg-mul-167.7%
Simplified67.7%
Final simplification61.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.55e+130) (* -2.0 J) (if (<= J 8.8e-257) U (if (<= J 3e+63) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.55e+130) {
tmp = -2.0 * J;
} else if (J <= 8.8e-257) {
tmp = U;
} else if (J <= 3e+63) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-1.55d+130)) then
tmp = (-2.0d0) * j
else if (j <= 8.8d-257) then
tmp = u
else if (j <= 3d+63) then
tmp = -u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -1.55e+130) {
tmp = -2.0 * J;
} else if (J <= 8.8e-257) {
tmp = U;
} else if (J <= 3e+63) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.55e+130: tmp = -2.0 * J elif J <= 8.8e-257: tmp = U elif J <= 3e+63: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.55e+130) tmp = Float64(-2.0 * J); elseif (J <= 8.8e-257) tmp = U; elseif (J <= 3e+63) tmp = Float64(-U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -1.55e+130) tmp = -2.0 * J; elseif (J <= 8.8e-257) tmp = U; elseif (J <= 3e+63) tmp = -U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -1.55e+130], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 8.8e-257], U, If[LessEqual[J, 3e+63], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.55 \cdot 10^{+130}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 8.8 \cdot 10^{-257}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 3 \cdot 10^{+63}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.55e130 or 2.99999999999999999e63 < J Initial program 98.8%
*-commutative98.8%
associate-*l*98.8%
associate-*r*98.8%
*-commutative98.8%
associate-*l*98.7%
*-commutative98.7%
unpow298.7%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in U around 0 79.4%
Taylor expanded in K around 0 44.4%
if -1.55e130 < J < 8.7999999999999995e-257Initial program 59.7%
*-commutative59.7%
associate-*l*59.7%
associate-*r*59.7%
*-commutative59.7%
associate-*l*59.7%
*-commutative59.7%
unpow259.7%
hypot-1-def84.8%
*-commutative84.8%
associate-*l*84.8%
Simplified84.8%
Taylor expanded in U around -inf 45.1%
if 8.7999999999999995e-257 < J < 2.99999999999999999e63Initial program 58.6%
*-commutative58.6%
associate-*l*58.6%
associate-*r*58.6%
*-commutative58.6%
associate-*l*58.6%
*-commutative58.6%
unpow258.6%
hypot-1-def82.9%
*-commutative82.9%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in J around 0 30.0%
neg-mul-130.0%
Simplified30.0%
Final simplification40.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 8.5e-257) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 8.5e-257) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= 8.5d-257) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= 8.5e-257) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 8.5e-257: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 8.5e-257) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= 8.5e-257) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, 8.5e-257], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 8.5 \cdot 10^{-257}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 8.5000000000000002e-257Initial program 71.7%
*-commutative71.7%
associate-*l*71.7%
associate-*r*71.7%
*-commutative71.7%
associate-*l*71.6%
*-commutative71.6%
unpow271.6%
hypot-1-def89.2%
*-commutative89.2%
associate-*l*89.2%
Simplified89.2%
Taylor expanded in U around -inf 34.6%
if 8.5000000000000002e-257 < J Initial program 73.6%
*-commutative73.6%
associate-*l*73.6%
associate-*r*73.6%
*-commutative73.6%
associate-*l*73.5%
*-commutative73.5%
unpow273.5%
hypot-1-def89.2%
*-commutative89.2%
associate-*l*89.2%
Simplified89.2%
Taylor expanded in J around 0 24.6%
neg-mul-124.6%
Simplified24.6%
Final simplification29.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 U)
U = abs(U);
double code(double J, double K, double U) {
return U;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return U;
}
U = abs(U) def code(J, K, U): return U
U = abs(U) function code(J, K, U) return U end
U = abs(U) function tmp = code(J, K, U) tmp = U; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := U
\begin{array}{l}
U = |U|\\
\\
U
\end{array}
Initial program 72.7%
*-commutative72.7%
associate-*l*72.7%
associate-*r*72.7%
*-commutative72.7%
associate-*l*72.6%
*-commutative72.6%
unpow272.6%
hypot-1-def89.2%
*-commutative89.2%
associate-*l*89.2%
Simplified89.2%
Taylor expanded in U around -inf 31.0%
Final simplification31.0%
herbie shell --seed 2023207
(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)))))