
(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 8 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+300) t_1 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+300) {
tmp = t_1;
} 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+300) {
tmp = t_1;
} 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+300: tmp = t_1 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+300) tmp = t_1; 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+300) tmp = t_1; 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+300], t$95$1, 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^{+300}:\\
\;\;\;\;t_1\\
\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.8%
Simplified5.8%
Taylor expanded in J around 0 36.5%
neg-mul-136.5%
Simplified36.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)))) < 1.0000000000000001e300Initial program 99.9%
if 1.0000000000000001e300 < (*.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 7.9%
Simplified7.9%
Taylor expanded in U around -inf 51.8%
Final simplification83.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* -2.0 (* t_0 (* J (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 -2.0 * (t_0 * (J * 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 -2.0 * (t_0 * (J * 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 -2.0 * (t_0 * (J * 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(-2.0 * Float64(t_0 * Float64(J * hypot(1.0, Float64(Float64(U / Float64(J * 2.0)) / t_0))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = -2.0 * (t_0 * (J * 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[(-2.0 * N[(t$95$0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(t_0 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{t_0}\right)\right)\right)
\end{array}
\end{array}
Initial program 72.6%
Simplified87.4%
Final simplification87.4%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* (* J (cos (/ K 2.0))) (hypot 1.0 (* 0.5 (/ U J)))))))
(if (<= J -7e-99)
t_0
(if (<= J -1.42e-303) U (if (<= J 1.05e-99) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, (0.5 * (U / J))));
double tmp;
if (J <= -7e-99) {
tmp = t_0;
} else if (J <= -1.42e-303) {
tmp = U;
} else if (J <= 1.05e-99) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = -2.0 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, (0.5 * (U / J))));
double tmp;
if (J <= -7e-99) {
tmp = t_0;
} else if (J <= -1.42e-303) {
tmp = U;
} else if (J <= 1.05e-99) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, (0.5 * (U / J)))) tmp = 0 if J <= -7e-99: tmp = t_0 elif J <= -1.42e-303: tmp = U elif J <= 1.05e-99: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(0.5 * Float64(U / J))))) tmp = 0.0 if (J <= -7e-99) tmp = t_0; elseif (J <= -1.42e-303) tmp = U; elseif (J <= 1.05e-99) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, (0.5 * (U / J)))); tmp = 0.0; if (J <= -7e-99) tmp = t_0; elseif (J <= -1.42e-303) tmp = U; elseif (J <= 1.05e-99) 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[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -7e-99], t$95$0, If[LessEqual[J, -1.42e-303], U, If[LessEqual[J, 1.05e-99], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
\mathbf{if}\;J \leq -7 \cdot 10^{-99}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -1.42 \cdot 10^{-303}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.05 \cdot 10^{-99}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -6.9999999999999997e-99 or 1.04999999999999992e-99 < J Initial program 87.6%
associate-*l*87.6%
associate-*l*87.6%
unpow287.6%
hypot-1-def98.8%
associate-/r*98.7%
cos-neg98.7%
distribute-frac-neg98.7%
associate-/r*98.8%
associate-/r*98.7%
distribute-frac-neg98.7%
cos-neg98.7%
Simplified98.7%
Taylor expanded in K around 0 84.8%
if -6.9999999999999997e-99 < J < -1.42e-303Initial program 45.3%
Simplified45.3%
Taylor expanded in U around -inf 44.2%
if -1.42e-303 < J < 1.04999999999999992e-99Initial program 36.6%
Simplified36.5%
Taylor expanded in J around 0 37.2%
neg-mul-137.2%
Simplified37.2%
Final simplification70.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* J (hypot 1.0 (* 0.5 (/ U J))))))
(t_1 (* (* -2.0 J) (cos (* K 0.5)))))
(if (<= J -6.8e+82)
t_1
(if (<= J -6.4e-55)
t_0
(if (<= J -6.5e-78)
t_1
(if (<= J -1.42e-303)
U
(if (<= J 2.1e-59) (- U) (if (<= J 1.95e+90) t_0 t_1))))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J * hypot(1.0, (0.5 * (U / J))));
double t_1 = (-2.0 * J) * cos((K * 0.5));
double tmp;
if (J <= -6.8e+82) {
tmp = t_1;
} else if (J <= -6.4e-55) {
tmp = t_0;
} else if (J <= -6.5e-78) {
tmp = t_1;
} else if (J <= -1.42e-303) {
tmp = U;
} else if (J <= 2.1e-59) {
tmp = -U;
} else if (J <= 1.95e+90) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (J * Math.hypot(1.0, (0.5 * (U / J))));
double t_1 = (-2.0 * J) * Math.cos((K * 0.5));
double tmp;
if (J <= -6.8e+82) {
tmp = t_1;
} else if (J <= -6.4e-55) {
tmp = t_0;
} else if (J <= -6.5e-78) {
tmp = t_1;
} else if (J <= -1.42e-303) {
tmp = U;
} else if (J <= 2.1e-59) {
tmp = -U;
} else if (J <= 1.95e+90) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J * math.hypot(1.0, (0.5 * (U / J)))) t_1 = (-2.0 * J) * math.cos((K * 0.5)) tmp = 0 if J <= -6.8e+82: tmp = t_1 elif J <= -6.4e-55: tmp = t_0 elif J <= -6.5e-78: tmp = t_1 elif J <= -1.42e-303: tmp = U elif J <= 2.1e-59: tmp = -U elif J <= 1.95e+90: tmp = t_0 else: tmp = t_1 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J * hypot(1.0, Float64(0.5 * Float64(U / J))))) t_1 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= -6.8e+82) tmp = t_1; elseif (J <= -6.4e-55) tmp = t_0; elseif (J <= -6.5e-78) tmp = t_1; elseif (J <= -1.42e-303) tmp = U; elseif (J <= 2.1e-59) tmp = Float64(-U); elseif (J <= 1.95e+90) tmp = t_0; else tmp = t_1; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * (J * hypot(1.0, (0.5 * (U / J)))); t_1 = (-2.0 * J) * cos((K * 0.5)); tmp = 0.0; if (J <= -6.8e+82) tmp = t_1; elseif (J <= -6.4e-55) tmp = t_0; elseif (J <= -6.5e-78) tmp = t_1; elseif (J <= -1.42e-303) tmp = U; elseif (J <= 2.1e-59) tmp = -U; elseif (J <= 1.95e+90) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -6.8e+82], t$95$1, If[LessEqual[J, -6.4e-55], t$95$0, If[LessEqual[J, -6.5e-78], t$95$1, If[LessEqual[J, -1.42e-303], U, If[LessEqual[J, 2.1e-59], (-U), If[LessEqual[J, 1.95e+90], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
t_1 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -6.8 \cdot 10^{+82}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq -6.4 \cdot 10^{-55}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -6.5 \cdot 10^{-78}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq -1.42 \cdot 10^{-303}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.1 \cdot 10^{-59}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 1.95 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if J < -6.79999999999999989e82 or -6.4000000000000003e-55 < J < -6.5000000000000003e-78 or 1.9500000000000001e90 < J Initial program 98.1%
Simplified98.0%
Taylor expanded in J around inf 83.4%
associate-*r*83.4%
*-commutative83.4%
Simplified83.4%
if -6.79999999999999989e82 < J < -6.4000000000000003e-55 or 2.09999999999999997e-59 < J < 1.9500000000000001e90Initial program 73.0%
associate-*l*73.0%
associate-*l*73.0%
unpow273.0%
hypot-1-def98.4%
associate-/r*98.2%
cos-neg98.2%
distribute-frac-neg98.2%
associate-/r*98.4%
associate-/r*98.2%
distribute-frac-neg98.2%
cos-neg98.2%
Simplified98.2%
log1p-expm1-u98.2%
div-inv98.2%
metadata-eval98.2%
Applied egg-rr98.2%
Taylor expanded in K around 0 77.1%
Taylor expanded in K around 0 72.8%
if -6.5000000000000003e-78 < J < -1.42e-303Initial program 46.8%
Simplified46.9%
Taylor expanded in U around -inf 42.0%
if -1.42e-303 < J < 2.09999999999999997e-59Initial program 43.5%
Simplified43.4%
Taylor expanded in J around 0 36.9%
neg-mul-136.9%
Simplified36.9%
Final simplification64.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* -2.0 J) (cos (* K 0.5)))))
(if (<= J -3.2e-78)
t_0
(if (<= J -1.42e-303) U (if (<= J 1.86e+90) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = (-2.0 * J) * cos((K * 0.5));
double tmp;
if (J <= -3.2e-78) {
tmp = t_0;
} else if (J <= -1.42e-303) {
tmp = U;
} else if (J <= 1.86e+90) {
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 = ((-2.0d0) * j) * cos((k * 0.5d0))
if (j <= (-3.2d-78)) then
tmp = t_0
else if (j <= (-1.42d-303)) then
tmp = u
else if (j <= 1.86d+90) 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 = (-2.0 * J) * Math.cos((K * 0.5));
double tmp;
if (J <= -3.2e-78) {
tmp = t_0;
} else if (J <= -1.42e-303) {
tmp = U;
} else if (J <= 1.86e+90) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = (-2.0 * J) * math.cos((K * 0.5)) tmp = 0 if J <= -3.2e-78: tmp = t_0 elif J <= -1.42e-303: tmp = U elif J <= 1.86e+90: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= -3.2e-78) tmp = t_0; elseif (J <= -1.42e-303) tmp = U; elseif (J <= 1.86e+90) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = (-2.0 * J) * cos((K * 0.5)); tmp = 0.0; if (J <= -3.2e-78) tmp = t_0; elseif (J <= -1.42e-303) tmp = U; elseif (J <= 1.86e+90) 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[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -3.2e-78], t$95$0, If[LessEqual[J, -1.42e-303], U, If[LessEqual[J, 1.86e+90], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -3.2 \cdot 10^{-78}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -1.42 \cdot 10^{-303}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.86 \cdot 10^{+90}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -3.2e-78 or 1.8600000000000001e90 < J Initial program 95.7%
Simplified95.6%
Taylor expanded in J around inf 76.9%
associate-*r*76.9%
*-commutative76.9%
Simplified76.9%
if -3.2e-78 < J < -1.42e-303Initial program 46.8%
Simplified46.9%
Taylor expanded in U around -inf 42.0%
if -1.42e-303 < J < 1.8600000000000001e90Initial program 50.9%
Simplified50.9%
Taylor expanded in J around 0 33.2%
neg-mul-133.2%
Simplified33.2%
Final simplification57.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.5e+43) (* -2.0 J) (if (<= J -1.5e-303) U (if (<= J 1.25e+138) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.5e+43) {
tmp = -2.0 * J;
} else if (J <= -1.5e-303) {
tmp = U;
} else if (J <= 1.25e+138) {
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 <= (-2.5d+43)) then
tmp = (-2.0d0) * j
else if (j <= (-1.5d-303)) then
tmp = u
else if (j <= 1.25d+138) 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 <= -2.5e+43) {
tmp = -2.0 * J;
} else if (J <= -1.5e-303) {
tmp = U;
} else if (J <= 1.25e+138) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.5e+43: tmp = -2.0 * J elif J <= -1.5e-303: tmp = U elif J <= 1.25e+138: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.5e+43) tmp = Float64(-2.0 * J); elseif (J <= -1.5e-303) tmp = U; elseif (J <= 1.25e+138) 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 <= -2.5e+43) tmp = -2.0 * J; elseif (J <= -1.5e-303) tmp = U; elseif (J <= 1.25e+138) 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, -2.5e+43], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -1.5e-303], U, If[LessEqual[J, 1.25e+138], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.5 \cdot 10^{+43}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -1.5 \cdot 10^{-303}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.25 \cdot 10^{+138}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.5000000000000002e43 or 1.25000000000000004e138 < J Initial program 98.1%
Simplified98.1%
Taylor expanded in J around inf 84.1%
associate-*r*84.1%
*-commutative84.1%
Simplified84.1%
Taylor expanded in K around 0 52.7%
*-commutative52.7%
Simplified52.7%
if -2.5000000000000002e43 < J < -1.50000000000000014e-303Initial program 60.4%
Simplified60.5%
Taylor expanded in U around -inf 38.2%
if -1.50000000000000014e-303 < J < 1.25000000000000004e138Initial program 53.4%
Simplified53.3%
Taylor expanded in J around 0 31.0%
neg-mul-131.0%
Simplified31.0%
Final simplification41.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.42e-303) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.42e-303) {
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 <= (-1.42d-303)) 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 <= -1.42e-303) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.42e-303: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.42e-303) 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 <= -1.42e-303) 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, -1.42e-303], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.42 \cdot 10^{-303}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -1.42e-303Initial program 76.6%
Simplified76.6%
Taylor expanded in U around -inf 27.4%
if -1.42e-303 < J Initial program 68.0%
Simplified67.9%
Taylor expanded in J around 0 23.8%
neg-mul-123.8%
Simplified23.8%
Final simplification25.7%
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.6%
Simplified72.6%
Taylor expanded in U around -inf 30.8%
Final simplification30.8%
herbie shell --seed 2023302
(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)))))