
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e-9)))
(* J (* t_0 (cos (* K 0.5))))
(+
U
(*
(* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* 2.0 J)))
(cos (/ K 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e-9)) {
tmp = J * (t_0 * cos((K * 0.5)));
} else {
tmp = U + ((l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (2.0 * J))) * cos((K / 2.0)));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 5e-9)) {
tmp = J * (t_0 * Math.cos((K * 0.5)));
} else {
tmp = U + ((l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (2.0 * J))) * Math.cos((K / 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 5e-9): tmp = J * (t_0 * math.cos((K * 0.5))) else: tmp = U + ((l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (2.0 * J))) * math.cos((K / 2.0))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e-9)) tmp = Float64(J * Float64(t_0 * cos(Float64(K * 0.5)))); else tmp = Float64(U + Float64(Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(2.0 * J))) * cos(Float64(K / 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 5e-9))) tmp = J * (t_0 * cos((K * 0.5))); else tmp = U + ((l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (2.0 * J))) * cos((K / 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-9]], $MachinePrecision]], N[(J * N[(t$95$0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;J \cdot \left(t\_0 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.0000000000000001e-9 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in J around 0 100.0%
Taylor expanded in J around inf 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-9Initial program 73.0%
Taylor expanded in l around 0 99.3%
Final simplification99.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.04)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
(+ U (* 2.0 (* J (log1p (expm1 l))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.04) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else {
tmp = U + (2.0 * (J * log1p(expm1(l))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.04) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else {
tmp = U + (2.0 * (J * Math.log1p(Math.expm1(l))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.04: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) else: tmp = U + (2.0 * (J * math.log1p(math.expm1(l)))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.04) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); else tmp = Float64(U + Float64(2.0 * Float64(J * log1p(expm1(l))))); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.04], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.04:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008Initial program 85.7%
Taylor expanded in l around 0 89.9%
if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.1%
Taylor expanded in l around 0 59.0%
log1p-expm1-u100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 88.0%
expm1-define96.1%
Simplified96.1%
Final simplification94.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.04) (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))) (+ U (* 2.0 (* J (log1p (expm1 l)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.04) {
tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U))));
} else {
tmp = U + (2.0 * (J * log1p(expm1(l))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.04) {
tmp = U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
} else {
tmp = U + (2.0 * (J * Math.log1p(Math.expm1(l))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.04: tmp = U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U)))) else: tmp = U + (2.0 * (J * math.log1p(math.expm1(l)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.04) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))); else tmp = Float64(U + Float64(2.0 * Float64(J * log1p(expm1(l))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.04], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.04:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008Initial program 85.7%
Taylor expanded in l around 0 66.5%
Taylor expanded in U around inf 70.0%
associate-/l*77.2%
Simplified77.2%
if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.1%
Taylor expanded in l around 0 59.0%
log1p-expm1-u100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 88.0%
expm1-define96.1%
Simplified96.1%
Final simplification92.1%
(FPCore (J l K U) :precision binary64 (+ (* 2.0 (* J (log1p (expm1 (* l (cos (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * log1p(expm1((l * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * Math.log1p(Math.expm1((l * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U): return (2.0 * (J * math.log1p(math.expm1((l * math.cos((K * 0.5))))))) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * log1p(expm1(Float64(l * cos(Float64(K * 0.5))))))) + U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Initial program 87.6%
Taylor expanded in l around 0 60.6%
log1p-expm1-u99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.04) (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))) (* U (+ 1.0 (/ (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) U)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.04) {
tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U))));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))) / U));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= 0.04d0) then
tmp = u * (1.0d0 + (2.0d0 * (j * ((l * cos((k * 0.5d0))) / u))))
else
tmp = u * (1.0d0 + ((j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))) / u))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.04) {
tmp = U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) / U));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.04: tmp = U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U)))) else: tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) / U)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.04) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))); else tmp = Float64(U * Float64(1.0 + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) / U))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.04) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); else tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))) / U)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.04], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.04:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008Initial program 85.7%
Taylor expanded in l around 0 66.5%
Taylor expanded in U around inf 70.0%
associate-/l*77.2%
Simplified77.2%
if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.1%
Taylor expanded in l around 0 88.2%
Taylor expanded in K around 0 84.3%
Taylor expanded in U around inf 85.0%
Final simplification83.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.04) (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.04) {
tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= 0.04d0) then
tmp = u * (1.0d0 + (2.0d0 * (j * ((l * cos((k * 0.5d0))) / u))))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.04) {
tmp = U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.04: tmp = U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U)))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.04) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.04) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.04], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.04:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008Initial program 85.7%
Taylor expanded in l around 0 66.5%
Taylor expanded in U around inf 70.0%
associate-/l*77.2%
Simplified77.2%
if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.1%
Taylor expanded in l around 0 88.2%
Taylor expanded in K around 0 84.3%
Final simplification82.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.04) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.04) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= 0.04d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.04) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.04: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.04) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.04) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.04], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.04:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008Initial program 85.7%
Taylor expanded in l around 0 66.5%
if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.1%
Taylor expanded in l around 0 88.2%
Taylor expanded in K around 0 84.3%
Final simplification80.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1400000000.0) (not (<= l 2.45e+30))) (* (pow l 3.0) (* J 0.3333333333333333)) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1400000000.0) || !(l <= 2.45e+30)) {
tmp = pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-1400000000.0d0)) .or. (.not. (l <= 2.45d+30))) then
tmp = (l ** 3.0d0) * (j * 0.3333333333333333d0)
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1400000000.0) || !(l <= 2.45e+30)) {
tmp = Math.pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1400000000.0) or not (l <= 2.45e+30): tmp = math.pow(l, 3.0) * (J * 0.3333333333333333) else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1400000000.0) || !(l <= 2.45e+30)) tmp = Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1400000000.0) || ~((l <= 2.45e+30))) tmp = (l ^ 3.0) * (J * 0.3333333333333333); else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1400000000.0], N[Not[LessEqual[l, 2.45e+30]], $MachinePrecision]], N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1400000000 \lor \neg \left(\ell \leq 2.45 \cdot 10^{+30}\right):\\
\;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -1.4e9 or 2.44999999999999992e30 < l Initial program 100.0%
Taylor expanded in l around 0 82.1%
Taylor expanded in K around 0 66.9%
Taylor expanded in l around inf 67.0%
associate-*r*67.0%
*-commutative67.0%
Simplified67.0%
if -1.4e9 < l < 2.44999999999999992e30Initial program 74.1%
Taylor expanded in l around 0 95.4%
Final simplification80.6%
(FPCore (J l K U)
:precision binary64
(if (<= l 2.45e+30)
(+ U (* J (* 2.0 l)))
(if (or (<= l 1.55e+127) (not (<= l 4.4e+269)))
(pow U -4.0)
(* J (+ (* 2.0 l) (/ U J))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.45e+30) {
tmp = U + (J * (2.0 * l));
} else if ((l <= 1.55e+127) || !(l <= 4.4e+269)) {
tmp = pow(U, -4.0);
} else {
tmp = J * ((2.0 * l) + (U / J));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= 2.45d+30) then
tmp = u + (j * (2.0d0 * l))
else if ((l <= 1.55d+127) .or. (.not. (l <= 4.4d+269))) then
tmp = u ** (-4.0d0)
else
tmp = j * ((2.0d0 * l) + (u / j))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.45e+30) {
tmp = U + (J * (2.0 * l));
} else if ((l <= 1.55e+127) || !(l <= 4.4e+269)) {
tmp = Math.pow(U, -4.0);
} else {
tmp = J * ((2.0 * l) + (U / J));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 2.45e+30: tmp = U + (J * (2.0 * l)) elif (l <= 1.55e+127) or not (l <= 4.4e+269): tmp = math.pow(U, -4.0) else: tmp = J * ((2.0 * l) + (U / J)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 2.45e+30) tmp = Float64(U + Float64(J * Float64(2.0 * l))); elseif ((l <= 1.55e+127) || !(l <= 4.4e+269)) tmp = U ^ -4.0; else tmp = Float64(J * Float64(Float64(2.0 * l) + Float64(U / J))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= 2.45e+30) tmp = U + (J * (2.0 * l)); elseif ((l <= 1.55e+127) || ~((l <= 4.4e+269))) tmp = U ^ -4.0; else tmp = J * ((2.0 * l) + (U / J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, 2.45e+30], N[(U + N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 1.55e+127], N[Not[LessEqual[l, 4.4e+269]], $MachinePrecision]], N[Power[U, -4.0], $MachinePrecision], N[(J * N[(N[(2.0 * l), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.45 \cdot 10^{+30}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\
\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+127} \lor \neg \left(\ell \leq 4.4 \cdot 10^{+269}\right):\\
\;\;\;\;{U}^{-4}\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(2 \cdot \ell + \frac{U}{J}\right)\\
\end{array}
\end{array}
if l < 2.44999999999999992e30Initial program 82.2%
Taylor expanded in l around 0 75.5%
Taylor expanded in K around 0 63.8%
+-commutative63.8%
*-commutative63.8%
associate-*r*63.8%
*-commutative63.8%
Simplified63.8%
if 2.44999999999999992e30 < l < 1.5500000000000001e127 or 4.3999999999999997e269 < l Initial program 100.0%
Applied egg-rr45.5%
if 1.5500000000000001e127 < l < 4.3999999999999997e269Initial program 100.0%
Taylor expanded in l around 0 38.3%
Taylor expanded in J around inf 40.8%
Taylor expanded in K around 0 37.4%
Final simplification57.1%
(FPCore (J l K U)
:precision binary64
(if (<= l 2.8e+30)
(+ U (* J (* 2.0 l)))
(if (<= l 2e+134)
(pow U -3.0)
(if (<= l 1e+269) (* J (+ (* 2.0 l) (/ U J))) (pow U -4.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.8e+30) {
tmp = U + (J * (2.0 * l));
} else if (l <= 2e+134) {
tmp = pow(U, -3.0);
} else if (l <= 1e+269) {
tmp = J * ((2.0 * l) + (U / J));
} else {
tmp = pow(U, -4.0);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= 2.8d+30) then
tmp = u + (j * (2.0d0 * l))
else if (l <= 2d+134) then
tmp = u ** (-3.0d0)
else if (l <= 1d+269) then
tmp = j * ((2.0d0 * l) + (u / j))
else
tmp = u ** (-4.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.8e+30) {
tmp = U + (J * (2.0 * l));
} else if (l <= 2e+134) {
tmp = Math.pow(U, -3.0);
} else if (l <= 1e+269) {
tmp = J * ((2.0 * l) + (U / J));
} else {
tmp = Math.pow(U, -4.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 2.8e+30: tmp = U + (J * (2.0 * l)) elif l <= 2e+134: tmp = math.pow(U, -3.0) elif l <= 1e+269: tmp = J * ((2.0 * l) + (U / J)) else: tmp = math.pow(U, -4.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 2.8e+30) tmp = Float64(U + Float64(J * Float64(2.0 * l))); elseif (l <= 2e+134) tmp = U ^ -3.0; elseif (l <= 1e+269) tmp = Float64(J * Float64(Float64(2.0 * l) + Float64(U / J))); else tmp = U ^ -4.0; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= 2.8e+30) tmp = U + (J * (2.0 * l)); elseif (l <= 2e+134) tmp = U ^ -3.0; elseif (l <= 1e+269) tmp = J * ((2.0 * l) + (U / J)); else tmp = U ^ -4.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, 2.8e+30], N[(U + N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2e+134], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 1e+269], N[(J * N[(N[(2.0 * l), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.8 \cdot 10^{+30}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{+134}:\\
\;\;\;\;{U}^{-3}\\
\mathbf{elif}\;\ell \leq 10^{+269}:\\
\;\;\;\;J \cdot \left(2 \cdot \ell + \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;{U}^{-4}\\
\end{array}
\end{array}
if l < 2.79999999999999983e30Initial program 82.2%
Taylor expanded in l around 0 75.5%
Taylor expanded in K around 0 63.8%
+-commutative63.8%
*-commutative63.8%
associate-*r*63.8%
*-commutative63.8%
Simplified63.8%
if 2.79999999999999983e30 < l < 1.99999999999999984e134Initial program 100.0%
Applied egg-rr39.4%
if 1.99999999999999984e134 < l < 1e269Initial program 100.0%
Taylor expanded in l around 0 39.2%
Taylor expanded in J around inf 41.8%
Taylor expanded in K around 0 38.4%
if 1e269 < l Initial program 100.0%
Applied egg-rr60.5%
Final simplification57.1%
(FPCore (J l K U)
:precision binary64
(if (<= l 2.8e+30)
(fma J (* 2.0 l) U)
(if (<= l 3.8e+132)
(pow U -3.0)
(if (<= l 2.1e+269) (* J (+ (* 2.0 l) (/ U J))) (pow U -4.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.8e+30) {
tmp = fma(J, (2.0 * l), U);
} else if (l <= 3.8e+132) {
tmp = pow(U, -3.0);
} else if (l <= 2.1e+269) {
tmp = J * ((2.0 * l) + (U / J));
} else {
tmp = pow(U, -4.0);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= 2.8e+30) tmp = fma(J, Float64(2.0 * l), U); elseif (l <= 3.8e+132) tmp = U ^ -3.0; elseif (l <= 2.1e+269) tmp = Float64(J * Float64(Float64(2.0 * l) + Float64(U / J))); else tmp = U ^ -4.0; end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, 2.8e+30], N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 3.8e+132], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 2.1e+269], N[(J * N[(N[(2.0 * l), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.8 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\
\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+132}:\\
\;\;\;\;{U}^{-3}\\
\mathbf{elif}\;\ell \leq 2.1 \cdot 10^{+269}:\\
\;\;\;\;J \cdot \left(2 \cdot \ell + \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;{U}^{-4}\\
\end{array}
\end{array}
if l < 2.79999999999999983e30Initial program 82.2%
Taylor expanded in l around 0 75.5%
Taylor expanded in K around 0 63.8%
+-commutative63.8%
*-commutative63.8%
associate-*r*63.8%
fma-define63.8%
*-commutative63.8%
Simplified63.8%
if 2.79999999999999983e30 < l < 3.80000000000000006e132Initial program 100.0%
Applied egg-rr39.4%
if 3.80000000000000006e132 < l < 2.1e269Initial program 100.0%
Taylor expanded in l around 0 39.2%
Taylor expanded in J around inf 41.8%
Taylor expanded in K around 0 38.4%
if 2.1e269 < l Initial program 100.0%
Applied egg-rr60.5%
Final simplification57.1%
(FPCore (J l K U) :precision binary64 (if (or (<= l -5200000.0) (not (<= l 2.45e+30))) (* (pow l 3.0) (* J 0.3333333333333333)) (fma J (* 2.0 l) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -5200000.0) || !(l <= 2.45e+30)) {
tmp = pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = fma(J, (2.0 * l), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -5200000.0) || !(l <= 2.45e+30)) tmp = Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)); else tmp = fma(J, Float64(2.0 * l), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -5200000.0], N[Not[LessEqual[l, 2.45e+30]], $MachinePrecision]], N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5200000 \lor \neg \left(\ell \leq 2.45 \cdot 10^{+30}\right):\\
\;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\
\end{array}
\end{array}
if l < -5.2e6 or 2.44999999999999992e30 < l Initial program 100.0%
Taylor expanded in l around 0 82.1%
Taylor expanded in K around 0 66.9%
Taylor expanded in l around inf 67.0%
associate-*r*67.0%
*-commutative67.0%
Simplified67.0%
if -5.2e6 < l < 2.44999999999999992e30Initial program 74.1%
Taylor expanded in l around 0 95.4%
Taylor expanded in K around 0 82.5%
+-commutative82.5%
*-commutative82.5%
associate-*r*82.5%
fma-define82.6%
*-commutative82.6%
Simplified82.6%
Final simplification74.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.05e+43) (not (<= l 1.7e-9))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.05e+43) || !(l <= 1.7e-9)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-2.05d+43)) .or. (.not. (l <= 1.7d-9))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.05e+43) || !(l <= 1.7e-9)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.05e+43) or not (l <= 1.7e-9): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.05e+43) || !(l <= 1.7e-9)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.05e+43) || ~((l <= 1.7e-9))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.05e+43], N[Not[LessEqual[l, 1.7e-9]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.05 \cdot 10^{+43} \lor \neg \left(\ell \leq 1.7 \cdot 10^{-9}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -2.05e43 or 1.6999999999999999e-9 < l Initial program 99.3%
Applied egg-rr13.7%
if -2.05e43 < l < 1.6999999999999999e-9Initial program 75.2%
Taylor expanded in J around 0 67.1%
Final simplification39.7%
(FPCore (J l K U) :precision binary64 (if (<= l -4200.0) (- -4.0 (* U U)) (if (<= l 1.7e-9) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4200.0) {
tmp = -4.0 - (U * U);
} else if (l <= 1.7e-9) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-4200.0d0)) then
tmp = (-4.0d0) - (u * u)
else if (l <= 1.7d-9) then
tmp = u
else
tmp = u * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4200.0) {
tmp = -4.0 - (U * U);
} else if (l <= 1.7e-9) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -4200.0: tmp = -4.0 - (U * U) elif l <= 1.7e-9: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -4200.0) tmp = Float64(-4.0 - Float64(U * U)); elseif (l <= 1.7e-9) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -4200.0) tmp = -4.0 - (U * U); elseif (l <= 1.7e-9) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -4200.0], N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.7e-9], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4200:\\
\;\;\;\;-4 - U \cdot U\\
\mathbf{elif}\;\ell \leq 1.7 \cdot 10^{-9}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -4200Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Applied egg-rr17.4%
cancel-sign-sub-inv17.4%
Simplified17.4%
if -4200 < l < 1.6999999999999999e-9Initial program 73.3%
Taylor expanded in J around 0 72.1%
if 1.6999999999999999e-9 < l Initial program 99.0%
Applied egg-rr13.3%
Final simplification40.8%
(FPCore (J l K U) :precision binary64 (+ U (* J (* 2.0 l))))
double code(double J, double l, double K, double U) {
return U + (J * (2.0 * l));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (j * (2.0d0 * l))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (2.0 * l));
}
def code(J, l, K, U): return U + (J * (2.0 * l))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(2.0 * l))) end
function tmp = code(J, l, K, U) tmp = U + (J * (2.0 * l)); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(2 \cdot \ell\right)
\end{array}
Initial program 87.6%
Taylor expanded in l around 0 60.6%
Taylor expanded in K around 0 51.4%
+-commutative51.4%
*-commutative51.4%
associate-*r*51.4%
*-commutative51.4%
Simplified51.4%
Final simplification51.4%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.0;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 87.6%
Applied egg-rr2.8%
*-inverses2.8%
Simplified2.8%
Final simplification2.8%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 87.6%
Taylor expanded in J around 0 33.8%
Final simplification33.8%
herbie shell --seed 2024076
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))