
(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}
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0))))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $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]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\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)
\end{array}
\end{array}
Initial program 72.7%
*-commutative72.7%
associate-*l*72.7%
unpow272.7%
hypot-1-def89.3%
*-commutative89.3%
associate-*l*89.3%
Simplified89.3%
Final simplification89.3%
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, 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]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
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)
\end{array}
\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%
Final simplification89.2%
(FPCore (J K U)
:precision binary64
(if (<= U -9e+200)
(- U)
(if (<= U 4.9e+202)
(* (* -2.0 (cos (* K 0.5))) (* J (hypot 1.0 (/ (/ U 2.0) J))))
(if (<= U 1.42e+274) U (- U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -9e+200) {
tmp = -U;
} else if (U <= 4.9e+202) {
tmp = (-2.0 * cos((K * 0.5))) * (J * hypot(1.0, ((U / 2.0) / J)));
} else if (U <= 1.42e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
public static double code(double J, double K, double U) {
double tmp;
if (U <= -9e+200) {
tmp = -U;
} else if (U <= 4.9e+202) {
tmp = (-2.0 * Math.cos((K * 0.5))) * (J * Math.hypot(1.0, ((U / 2.0) / J)));
} else if (U <= 1.42e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -9e+200: tmp = -U elif U <= 4.9e+202: tmp = (-2.0 * math.cos((K * 0.5))) * (J * math.hypot(1.0, ((U / 2.0) / J))) elif U <= 1.42e+274: tmp = U else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -9e+200) tmp = Float64(-U); elseif (U <= 4.9e+202) tmp = Float64(Float64(-2.0 * cos(Float64(K * 0.5))) * Float64(J * hypot(1.0, Float64(Float64(U / 2.0) / J)))); elseif (U <= 1.42e+274) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -9e+200) tmp = -U; elseif (U <= 4.9e+202) tmp = (-2.0 * cos((K * 0.5))) * (J * hypot(1.0, ((U / 2.0) / J))); elseif (U <= 1.42e+274) tmp = U; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -9e+200], (-U), If[LessEqual[U, 4.9e+202], N[(N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 1.42e+274], U, (-U)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -9 \cdot 10^{+200}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq 4.9 \cdot 10^{+202}:\\
\;\;\;\;\left(-2 \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J}\right)\right)\\
\mathbf{elif}\;U \leq 1.42 \cdot 10^{+274}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -8.99999999999999939e200 or 1.42e274 < U Initial program 44.2%
*-commutative44.2%
associate-*l*44.2%
associate-*r*44.2%
*-commutative44.2%
associate-*l*44.0%
*-commutative44.0%
unpow244.0%
hypot-1-def64.1%
*-commutative64.1%
associate-*l*64.1%
Simplified64.1%
Taylor expanded in J around 0 58.9%
neg-mul-158.9%
Simplified58.9%
if -8.99999999999999939e200 < U < 4.9e202Initial program 80.7%
*-commutative80.7%
associate-*l*80.7%
unpow280.7%
hypot-1-def96.0%
*-commutative96.0%
associate-*l*96.0%
Simplified96.0%
Taylor expanded in K around 0 83.4%
expm1-log1p-u50.9%
expm1-udef25.9%
*-commutative25.9%
*-commutative25.9%
div-inv25.9%
metadata-eval25.9%
*-commutative25.9%
*-commutative25.9%
Applied egg-rr25.9%
expm1-def50.9%
expm1-log1p83.4%
*-commutative83.4%
*-commutative83.4%
associate-*l*83.4%
*-commutative83.4%
*-commutative83.4%
associate-/r*83.4%
Simplified83.4%
if 4.9e202 < 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%
Final simplification79.2%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= U -4e+182)
(- U)
(if (<= U -1.16e+58)
t_0
(if (<= U -1.25e+36)
(- U)
(if (<= U -4.9e+23)
U
(if (<= U 4.8e-51)
t_0
(if (<= U 8.2e-23)
U
(if (<= U 1.7e+119) t_0 (if (<= U 9e+273) U (- U)))))))))))
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (U <= -4e+182) {
tmp = -U;
} else if (U <= -1.16e+58) {
tmp = t_0;
} else if (U <= -1.25e+36) {
tmp = -U;
} else if (U <= -4.9e+23) {
tmp = U;
} else if (U <= 4.8e-51) {
tmp = t_0;
} else if (U <= 8.2e-23) {
tmp = U;
} else if (U <= 1.7e+119) {
tmp = t_0;
} else if (U <= 9e+273) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
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 <= (-4d+182)) then
tmp = -u
else if (u <= (-1.16d+58)) then
tmp = t_0
else if (u <= (-1.25d+36)) then
tmp = -u
else if (u <= (-4.9d+23)) then
tmp = u
else if (u <= 4.8d-51) then
tmp = t_0
else if (u <= 8.2d-23) then
tmp = u
else if (u <= 1.7d+119) then
tmp = t_0
else if (u <= 9d+273) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
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 <= -4e+182) {
tmp = -U;
} else if (U <= -1.16e+58) {
tmp = t_0;
} else if (U <= -1.25e+36) {
tmp = -U;
} else if (U <= -4.9e+23) {
tmp = U;
} else if (U <= 4.8e-51) {
tmp = t_0;
} else if (U <= 8.2e-23) {
tmp = U;
} else if (U <= 1.7e+119) {
tmp = t_0;
} else if (U <= 9e+273) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if U <= -4e+182: tmp = -U elif U <= -1.16e+58: tmp = t_0 elif U <= -1.25e+36: tmp = -U elif U <= -4.9e+23: tmp = U elif U <= 4.8e-51: tmp = t_0 elif U <= 8.2e-23: tmp = U elif U <= 1.7e+119: tmp = t_0 elif U <= 9e+273: tmp = U else: tmp = -U return tmp
function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (U <= -4e+182) tmp = Float64(-U); elseif (U <= -1.16e+58) tmp = t_0; elseif (U <= -1.25e+36) tmp = Float64(-U); elseif (U <= -4.9e+23) tmp = U; elseif (U <= 4.8e-51) tmp = t_0; elseif (U <= 8.2e-23) tmp = U; elseif (U <= 1.7e+119) tmp = t_0; elseif (U <= 9e+273) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (U <= -4e+182) tmp = -U; elseif (U <= -1.16e+58) tmp = t_0; elseif (U <= -1.25e+36) tmp = -U; elseif (U <= -4.9e+23) tmp = U; elseif (U <= 4.8e-51) tmp = t_0; elseif (U <= 8.2e-23) tmp = U; elseif (U <= 1.7e+119) tmp = t_0; elseif (U <= 9e+273) tmp = U; else tmp = -U; end tmp_2 = tmp; end
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, -4e+182], (-U), If[LessEqual[U, -1.16e+58], t$95$0, If[LessEqual[U, -1.25e+36], (-U), If[LessEqual[U, -4.9e+23], U, If[LessEqual[U, 4.8e-51], t$95$0, If[LessEqual[U, 8.2e-23], U, If[LessEqual[U, 1.7e+119], t$95$0, If[LessEqual[U, 9e+273], U, (-U)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;U \leq -4 \cdot 10^{+182}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq -1.16 \cdot 10^{+58}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq -1.25 \cdot 10^{+36}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq -4.9 \cdot 10^{+23}:\\
\;\;\;\;U\\
\mathbf{elif}\;U \leq 4.8 \cdot 10^{-51}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq 8.2 \cdot 10^{-23}:\\
\;\;\;\;U\\
\mathbf{elif}\;U \leq 1.7 \cdot 10^{+119}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq 9 \cdot 10^{+273}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -4.0000000000000003e182 or -1.1600000000000001e58 < U < -1.24999999999999994e36 or 8.99999999999999987e273 < U Initial program 46.2%
*-commutative46.2%
associate-*l*46.2%
associate-*r*46.2%
*-commutative46.2%
associate-*l*45.9%
*-commutative45.9%
unpow245.9%
hypot-1-def69.0%
*-commutative69.0%
associate-*l*69.0%
Simplified69.0%
Taylor expanded in J around 0 57.0%
neg-mul-157.0%
Simplified57.0%
if -4.0000000000000003e182 < U < -1.1600000000000001e58 or -4.9000000000000003e23 < U < 4.8e-51 or 8.20000000000000059e-23 < U < 1.70000000000000007e119Initial program 87.7%
*-commutative87.7%
associate-*l*87.7%
associate-*r*87.7%
*-commutative87.7%
associate-*l*87.6%
*-commutative87.6%
unpow287.6%
hypot-1-def97.4%
*-commutative97.4%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in U around 0 75.4%
if -1.24999999999999994e36 < U < -4.9000000000000003e23 or 4.8e-51 < U < 8.20000000000000059e-23 or 1.70000000000000007e119 < U < 8.99999999999999987e273Initial program 50.7%
*-commutative50.7%
associate-*l*50.7%
associate-*r*50.7%
*-commutative50.7%
associate-*l*50.6%
*-commutative50.6%
unpow250.6%
hypot-1-def83.0%
*-commutative83.0%
associate-*l*83.0%
Simplified83.0%
Taylor expanded in U around -inf 62.8%
Final simplification69.5%
(FPCore (J K U) :precision binary64 (if (<= U -7e+36) (- U) (if (<= U 2.5e-53) (* J -2.0) (if (<= U 1.12e+274) U (- U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -7e+36) {
tmp = -U;
} else if (U <= 2.5e-53) {
tmp = J * -2.0;
} else if (U <= 1.12e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
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 (u <= (-7d+36)) then
tmp = -u
else if (u <= 2.5d-53) then
tmp = j * (-2.0d0)
else if (u <= 1.12d+274) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double tmp;
if (U <= -7e+36) {
tmp = -U;
} else if (U <= 2.5e-53) {
tmp = J * -2.0;
} else if (U <= 1.12e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -7e+36: tmp = -U elif U <= 2.5e-53: tmp = J * -2.0 elif U <= 1.12e+274: tmp = U else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -7e+36) tmp = Float64(-U); elseif (U <= 2.5e-53) tmp = Float64(J * -2.0); elseif (U <= 1.12e+274) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -7e+36) tmp = -U; elseif (U <= 2.5e-53) tmp = J * -2.0; elseif (U <= 1.12e+274) tmp = U; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -7e+36], (-U), If[LessEqual[U, 2.5e-53], N[(J * -2.0), $MachinePrecision], If[LessEqual[U, 1.12e+274], U, (-U)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -7 \cdot 10^{+36}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq 2.5 \cdot 10^{-53}:\\
\;\;\;\;J \cdot -2\\
\mathbf{elif}\;U \leq 1.12 \cdot 10^{+274}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -6.9999999999999996e36 or 1.12000000000000007e274 < U Initial program 50.0%
*-commutative50.0%
associate-*l*50.0%
associate-*r*50.0%
*-commutative50.0%
associate-*l*49.8%
*-commutative49.8%
unpow249.8%
hypot-1-def74.9%
*-commutative74.9%
associate-*l*74.9%
Simplified74.9%
Taylor expanded in J around 0 48.5%
neg-mul-148.5%
Simplified48.5%
if -6.9999999999999996e36 < U < 2.5e-53Initial program 93.7%
*-commutative93.7%
associate-*l*93.7%
associate-*r*93.7%
*-commutative93.7%
associate-*l*93.7%
*-commutative93.7%
unpow293.7%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 79.8%
Taylor expanded in K around 0 45.0%
if 2.5e-53 < U < 1.12000000000000007e274Initial program 54.7%
*-commutative54.7%
associate-*l*54.7%
associate-*r*54.7%
*-commutative54.7%
associate-*l*54.6%
*-commutative54.6%
unpow254.6%
hypot-1-def83.3%
*-commutative83.3%
associate-*l*83.3%
Simplified83.3%
Taylor expanded in U around -inf 50.4%
Final simplification47.2%
(FPCore (J K U) :precision binary64 (if (<= U -3.6e+113) (- U) (if (<= U 1.55e+274) U (- U))))
double code(double J, double K, double U) {
double tmp;
if (U <= -3.6e+113) {
tmp = -U;
} else if (U <= 1.55e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
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 (u <= (-3.6d+113)) then
tmp = -u
else if (u <= 1.55d+274) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double tmp;
if (U <= -3.6e+113) {
tmp = -U;
} else if (U <= 1.55e+274) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -3.6e+113: tmp = -U elif U <= 1.55e+274: tmp = U else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -3.6e+113) tmp = Float64(-U); elseif (U <= 1.55e+274) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -3.6e+113) tmp = -U; elseif (U <= 1.55e+274) tmp = U; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -3.6e+113], (-U), If[LessEqual[U, 1.55e+274], U, (-U)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -3.6 \cdot 10^{+113}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq 1.55 \cdot 10^{+274}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -3.59999999999999992e113 or 1.55e274 < U Initial program 49.4%
*-commutative49.4%
associate-*l*49.4%
associate-*r*49.4%
*-commutative49.4%
associate-*l*49.2%
*-commutative49.2%
unpow249.2%
hypot-1-def69.0%
*-commutative69.0%
associate-*l*69.0%
Simplified69.0%
Taylor expanded in J around 0 51.8%
neg-mul-151.8%
Simplified51.8%
if -3.59999999999999992e113 < U < 1.55e274Initial program 78.4%
*-commutative78.4%
associate-*l*78.4%
associate-*r*78.4%
*-commutative78.4%
associate-*l*78.4%
*-commutative78.4%
unpow278.4%
hypot-1-def94.3%
*-commutative94.3%
associate-*l*94.3%
Simplified94.3%
Taylor expanded in U around -inf 30.2%
Final simplification34.5%
(FPCore (J K U) :precision binary64 U)
double code(double J, double K, double U) {
return U;
}
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
public static double code(double J, double K, double U) {
return U;
}
def code(J, K, U): return U
function code(J, K, U) return U end
function tmp = code(J, K, U) tmp = U; end
code[J_, K_, U_] := U
\begin{array}{l}
\\
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)))))