
(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 9 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
(*
(* t_0 (* -2.0 J))
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 1e+305)
(* (* 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 = (t_0 * (-2.0 * J)) * 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+305) {
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 = (t_0 * (-2.0 * J)) * 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+305) {
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 = (t_0 * (-2.0 * J)) * 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+305: 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(t_0 * Float64(-2.0 * J)) * 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+305) 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 = (t_0 * (-2.0 * J)) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 1e+305) 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[(t$95$0 * N[(-2.0 * J), $MachinePrecision]), $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+305], 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(t_0 \cdot \left(-2 \cdot J\right)\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^{+305}:\\
\;\;\;\;\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 5.3%
*-commutative5.3%
associate-*l*5.3%
associate-*r*5.3%
*-commutative5.3%
associate-*l*5.3%
*-commutative5.3%
unpow25.3%
hypot-1-def67.9%
*-commutative67.9%
associate-*l*67.9%
Simplified67.9%
Taylor expanded in J around 0 38.5%
neg-mul-138.5%
Simplified38.5%
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.9999999999999994e304Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 9.9999999999999994e304 < (*.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.0%
*-commutative5.0%
associate-*l*5.0%
associate-*r*5.0%
*-commutative5.0%
associate-*l*5.0%
*-commutative5.0%
unpow25.0%
hypot-1-def64.6%
*-commutative64.6%
associate-*l*64.6%
Simplified64.6%
Taylor expanded in U around -inf 53.7%
Final simplification87.1%
NOTE: U should be positive before calling this function (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)))))))))
U = abs(U);
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))))));
}
U = Math.abs(U);
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))))));
}
U = abs(U) 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))))))
U = abs(U) 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
U = abs(U) 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
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]}, 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}
U = |U|\\
\\
\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 77.2%
*-commutative77.2%
associate-*l*77.2%
associate-*r*77.2%
*-commutative77.2%
associate-*l*77.2%
*-commutative77.2%
unpow277.2%
hypot-1-def91.8%
*-commutative91.8%
associate-*l*91.8%
Simplified91.8%
Final simplification91.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 6e+173) (* J (* (cos (/ K 2.0)) (* -2.0 (hypot 1.0 (/ U (/ J 0.5)))))) (if (<= U 3e+251) U (- U))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 6e+173) {
tmp = J * (cos((K / 2.0)) * (-2.0 * hypot(1.0, (U / (J / 0.5)))));
} else if (U <= 3e+251) {
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 <= 6e+173) {
tmp = J * (Math.cos((K / 2.0)) * (-2.0 * Math.hypot(1.0, (U / (J / 0.5)))));
} else if (U <= 3e+251) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 6e+173: tmp = J * (math.cos((K / 2.0)) * (-2.0 * math.hypot(1.0, (U / (J / 0.5))))) elif U <= 3e+251: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 6e+173) tmp = Float64(J * Float64(cos(Float64(K / 2.0)) * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J / 0.5)))))); elseif (U <= 3e+251) 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 <= 6e+173) tmp = J * (cos((K / 2.0)) * (-2.0 * hypot(1.0, (U / (J / 0.5))))); elseif (U <= 3e+251) 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, 6e+173], N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J / 0.5), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 3e+251], U, (-U)]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 6 \cdot 10^{+173}:\\
\;\;\;\;J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{\frac{J}{0.5}}\right)\right)\right)\\
\mathbf{elif}\;U \leq 3 \cdot 10^{+251}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 5.9999999999999995e173Initial program 80.1%
*-commutative80.1%
associate-*l*80.1%
associate-*r*80.1%
*-commutative80.1%
associate-*l*80.1%
*-commutative80.1%
unpow280.1%
hypot-1-def95.4%
*-commutative95.4%
associate-*l*95.4%
Simplified95.4%
Taylor expanded in K around 0 80.8%
associate-*r/80.8%
*-commutative80.8%
associate-/l*80.8%
Simplified80.8%
if 5.9999999999999995e173 < U < 2.9999999999999999e251Initial program 41.1%
*-commutative41.1%
associate-*l*41.1%
associate-*r*41.1%
*-commutative41.1%
associate-*l*41.0%
*-commutative41.0%
unpow241.0%
hypot-1-def52.8%
*-commutative52.8%
associate-*l*52.8%
Simplified52.8%
Taylor expanded in U around -inf 69.2%
if 2.9999999999999999e251 < U Initial program 65.2%
*-commutative65.2%
associate-*l*65.2%
associate-*r*65.2%
*-commutative65.2%
associate-*l*65.2%
*-commutative65.2%
unpow265.2%
hypot-1-def65.2%
*-commutative65.2%
associate-*l*65.2%
Simplified65.2%
Taylor expanded in J around 0 62.5%
neg-mul-162.5%
Simplified62.5%
Final simplification79.5%
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 (<= J -3e-29) t_0 (if (<= J -5e-310) U (if (<= J 2.8e-28) (- U) t_0)))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -3e-29) {
tmp = t_0;
} else if (J <= -5e-310) {
tmp = U;
} else if (J <= 2.8e-28) {
tmp = -U;
} else {
tmp = t_0;
}
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 (j <= (-3d-29)) then
tmp = t_0
else if (j <= (-5d-310)) then
tmp = u
else if (j <= 2.8d-28) then
tmp = -u
else
tmp = t_0
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 (J <= -3e-29) {
tmp = t_0;
} else if (J <= -5e-310) {
tmp = U;
} else if (J <= 2.8e-28) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -3e-29: tmp = t_0 elif J <= -5e-310: tmp = U elif J <= 2.8e-28: tmp = -U else: tmp = t_0 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 (J <= -3e-29) tmp = t_0; elseif (J <= -5e-310) tmp = U; elseif (J <= 2.8e-28) tmp = Float64(-U); else tmp = t_0; 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 (J <= -3e-29) tmp = t_0; elseif (J <= -5e-310) tmp = U; elseif (J <= 2.8e-28) tmp = -U; else tmp = t_0; 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[J, -3e-29], t$95$0, If[LessEqual[J, -5e-310], U, If[LessEqual[J, 2.8e-28], (-U), t$95$0]]]]
\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}\;J \leq -3 \cdot 10^{-29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -5 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.8 \cdot 10^{-28}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -3.0000000000000003e-29 or 2.7999999999999998e-28 < J Initial program 96.5%
*-commutative96.5%
associate-*l*96.5%
associate-*r*96.5%
*-commutative96.5%
associate-*l*96.5%
*-commutative96.5%
unpow296.5%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 77.9%
if -3.0000000000000003e-29 < J < -4.999999999999985e-310Initial program 48.5%
*-commutative48.5%
associate-*l*48.5%
associate-*r*48.5%
*-commutative48.5%
associate-*l*48.5%
*-commutative48.5%
unpow248.5%
hypot-1-def80.5%
*-commutative80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in U around -inf 41.3%
if -4.999999999999985e-310 < J < 2.7999999999999998e-28Initial 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-def83.7%
*-commutative83.7%
associate-*l*83.7%
Simplified83.7%
Taylor expanded in J around 0 31.1%
neg-mul-131.1%
Simplified31.1%
Final simplification59.4%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -8.5e+47)
(* J (* -2.0 (+ 1.0 (* (* U (/ U (* J J))) 0.125))))
(if (<= J 5e-310)
U
(if (<= J 5.5e-5) (- (/ (* -2.0 (* J J)) U) U) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -8.5e+47) {
tmp = J * (-2.0 * (1.0 + ((U * (U / (J * J))) * 0.125)));
} else if (J <= 5e-310) {
tmp = U;
} else if (J <= 5.5e-5) {
tmp = ((-2.0 * (J * J)) / U) - 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 <= (-8.5d+47)) then
tmp = j * ((-2.0d0) * (1.0d0 + ((u * (u / (j * j))) * 0.125d0)))
else if (j <= 5d-310) then
tmp = u
else if (j <= 5.5d-5) then
tmp = (((-2.0d0) * (j * j)) / u) - 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 <= -8.5e+47) {
tmp = J * (-2.0 * (1.0 + ((U * (U / (J * J))) * 0.125)));
} else if (J <= 5e-310) {
tmp = U;
} else if (J <= 5.5e-5) {
tmp = ((-2.0 * (J * J)) / U) - U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -8.5e+47: tmp = J * (-2.0 * (1.0 + ((U * (U / (J * J))) * 0.125))) elif J <= 5e-310: tmp = U elif J <= 5.5e-5: tmp = ((-2.0 * (J * J)) / U) - U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -8.5e+47) tmp = Float64(J * Float64(-2.0 * Float64(1.0 + Float64(Float64(U * Float64(U / Float64(J * J))) * 0.125)))); elseif (J <= 5e-310) tmp = U; elseif (J <= 5.5e-5) tmp = Float64(Float64(Float64(-2.0 * Float64(J * J)) / U) - 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 <= -8.5e+47) tmp = J * (-2.0 * (1.0 + ((U * (U / (J * J))) * 0.125))); elseif (J <= 5e-310) tmp = U; elseif (J <= 5.5e-5) tmp = ((-2.0 * (J * J)) / U) - 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, -8.5e+47], N[(J * N[(-2.0 * N[(1.0 + N[(N[(U * N[(U / N[(J * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 5e-310], U, If[LessEqual[J, 5.5e-5], N[(N[(N[(-2.0 * N[(J * J), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision] - U), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -8.5 \cdot 10^{+47}:\\
\;\;\;\;J \cdot \left(-2 \cdot \left(1 + \left(U \cdot \frac{U}{J \cdot J}\right) \cdot 0.125\right)\right)\\
\mathbf{elif}\;J \leq 5 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{-2 \cdot \left(J \cdot J\right)}{U} - U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -8.5000000000000008e47Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
*-commutative98.2%
unpow298.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 42.0%
unpow242.0%
unpow242.0%
Simplified42.0%
Taylor expanded in U around 0 42.0%
*-commutative42.0%
unpow242.0%
associate-*r/45.8%
unpow245.8%
Simplified45.8%
if -8.5000000000000008e47 < J < 4.999999999999985e-310Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*r*57.7%
*-commutative57.7%
associate-*l*57.7%
*-commutative57.7%
unpow257.7%
hypot-1-def84.4%
*-commutative84.4%
associate-*l*84.4%
Simplified84.4%
Taylor expanded in U around -inf 34.8%
if 4.999999999999985e-310 < J < 5.5000000000000002e-5Initial program 62.0%
*-commutative62.0%
associate-*l*62.0%
associate-*r*62.0%
*-commutative62.0%
associate-*l*62.0%
*-commutative62.0%
unpow262.0%
hypot-1-def85.8%
*-commutative85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in K around 0 26.0%
unpow226.0%
unpow226.0%
Simplified26.0%
Taylor expanded in J around 0 27.2%
mul-1-neg27.2%
unsub-neg27.2%
associate-*r/27.2%
unpow227.2%
Simplified27.2%
if 5.5000000000000002e-5 < J Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
*-commutative98.2%
unpow298.2%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 43.0%
unpow243.0%
unpow243.0%
Simplified43.0%
Taylor expanded in J around inf 37.7%
*-commutative37.7%
Simplified37.7%
Final simplification36.1%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -7.5e+46)
(* -2.0 J)
(if (<= J -5e-310)
U
(if (<= J 3.6e-6) (- (/ (* -2.0 (* J J)) U) U) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -7.5e+46) {
tmp = -2.0 * J;
} else if (J <= -5e-310) {
tmp = U;
} else if (J <= 3.6e-6) {
tmp = ((-2.0 * (J * J)) / U) - 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 <= (-7.5d+46)) then
tmp = (-2.0d0) * j
else if (j <= (-5d-310)) then
tmp = u
else if (j <= 3.6d-6) then
tmp = (((-2.0d0) * (j * j)) / u) - 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 <= -7.5e+46) {
tmp = -2.0 * J;
} else if (J <= -5e-310) {
tmp = U;
} else if (J <= 3.6e-6) {
tmp = ((-2.0 * (J * J)) / U) - U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -7.5e+46: tmp = -2.0 * J elif J <= -5e-310: tmp = U elif J <= 3.6e-6: tmp = ((-2.0 * (J * J)) / U) - U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -7.5e+46) tmp = Float64(-2.0 * J); elseif (J <= -5e-310) tmp = U; elseif (J <= 3.6e-6) tmp = Float64(Float64(Float64(-2.0 * Float64(J * J)) / U) - 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 <= -7.5e+46) tmp = -2.0 * J; elseif (J <= -5e-310) tmp = U; elseif (J <= 3.6e-6) tmp = ((-2.0 * (J * J)) / U) - 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, -7.5e+46], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -5e-310], U, If[LessEqual[J, 3.6e-6], N[(N[(N[(-2.0 * N[(J * J), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision] - U), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -7.5 \cdot 10^{+46}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -5 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 3.6 \cdot 10^{-6}:\\
\;\;\;\;\frac{-2 \cdot \left(J \cdot J\right)}{U} - U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -7.5000000000000003e46 or 3.59999999999999984e-6 < J Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
*-commutative98.2%
unpow298.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 42.5%
unpow242.5%
unpow242.5%
Simplified42.5%
Taylor expanded in J around inf 41.4%
*-commutative41.4%
Simplified41.4%
if -7.5000000000000003e46 < J < -4.999999999999985e-310Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*r*57.7%
*-commutative57.7%
associate-*l*57.7%
*-commutative57.7%
unpow257.7%
hypot-1-def84.4%
*-commutative84.4%
associate-*l*84.4%
Simplified84.4%
Taylor expanded in U around -inf 34.8%
if -4.999999999999985e-310 < J < 3.59999999999999984e-6Initial program 62.0%
*-commutative62.0%
associate-*l*62.0%
associate-*r*62.0%
*-commutative62.0%
associate-*l*62.0%
*-commutative62.0%
unpow262.0%
hypot-1-def85.8%
*-commutative85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in K around 0 26.0%
unpow226.0%
unpow226.0%
Simplified26.0%
Taylor expanded in J around 0 27.2%
mul-1-neg27.2%
unsub-neg27.2%
associate-*r/27.2%
unpow227.2%
Simplified27.2%
Final simplification36.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -7.2e+46) (* -2.0 J) (if (<= J -5e-310) U (if (<= J 0.00185) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -7.2e+46) {
tmp = -2.0 * J;
} else if (J <= -5e-310) {
tmp = U;
} else if (J <= 0.00185) {
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 <= (-7.2d+46)) then
tmp = (-2.0d0) * j
else if (j <= (-5d-310)) then
tmp = u
else if (j <= 0.00185d0) 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 <= -7.2e+46) {
tmp = -2.0 * J;
} else if (J <= -5e-310) {
tmp = U;
} else if (J <= 0.00185) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -7.2e+46: tmp = -2.0 * J elif J <= -5e-310: tmp = U elif J <= 0.00185: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -7.2e+46) tmp = Float64(-2.0 * J); elseif (J <= -5e-310) tmp = U; elseif (J <= 0.00185) 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 <= -7.2e+46) tmp = -2.0 * J; elseif (J <= -5e-310) tmp = U; elseif (J <= 0.00185) 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, -7.2e+46], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -5e-310], U, If[LessEqual[J, 0.00185], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -7.2 \cdot 10^{+46}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -5 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 0.00185:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -7.1999999999999997e46 or 0.0018500000000000001 < J Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
*-commutative98.2%
unpow298.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 42.5%
unpow242.5%
unpow242.5%
Simplified42.5%
Taylor expanded in J around inf 41.4%
*-commutative41.4%
Simplified41.4%
if -7.1999999999999997e46 < J < -4.999999999999985e-310Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*r*57.7%
*-commutative57.7%
associate-*l*57.7%
*-commutative57.7%
unpow257.7%
hypot-1-def84.4%
*-commutative84.4%
associate-*l*84.4%
Simplified84.4%
Taylor expanded in U around -inf 34.8%
if -4.999999999999985e-310 < J < 0.0018500000000000001Initial program 62.0%
*-commutative62.0%
associate-*l*62.0%
associate-*r*62.0%
*-commutative62.0%
associate-*l*62.0%
*-commutative62.0%
unpow262.0%
hypot-1-def85.8%
*-commutative85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in J around 0 27.3%
neg-mul-127.3%
Simplified27.3%
Final simplification36.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 6.5e-308) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 6.5e-308) {
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 <= 6.5d-308) 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 <= 6.5e-308) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 6.5e-308: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 6.5e-308) 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 <= 6.5e-308) 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, 6.5e-308], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 6.5 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 6.4999999999999999e-308Initial program 74.3%
*-commutative74.3%
associate-*l*74.3%
associate-*r*74.3%
*-commutative74.3%
associate-*l*74.3%
*-commutative74.3%
unpow274.3%
hypot-1-def90.7%
*-commutative90.7%
associate-*l*90.7%
Simplified90.7%
Taylor expanded in U around -inf 26.0%
if 6.4999999999999999e-308 < J Initial program 80.4%
*-commutative80.4%
associate-*l*80.4%
associate-*r*80.4%
*-commutative80.4%
associate-*l*80.4%
*-commutative80.4%
unpow280.4%
hypot-1-def92.9%
*-commutative92.9%
associate-*l*92.9%
Simplified92.9%
Taylor expanded in J around 0 22.5%
neg-mul-122.5%
Simplified22.5%
Final simplification24.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 77.2%
*-commutative77.2%
associate-*l*77.2%
associate-*r*77.2%
*-commutative77.2%
associate-*l*77.2%
*-commutative77.2%
unpow277.2%
hypot-1-def91.8%
*-commutative91.8%
associate-*l*91.8%
Simplified91.8%
Taylor expanded in U around -inf 28.5%
Final simplification28.5%
herbie shell --seed 2023217
(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)))))