
(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 (+ (* (log1p (expm1 (* (cos (* 0.5 K)) l))) (* J 2.0)) U))
double code(double J, double l, double K, double U) {
return (log1p(expm1((cos((0.5 * K)) * l))) * (J * 2.0)) + U;
}
public static double code(double J, double l, double K, double U) {
return (Math.log1p(Math.expm1((Math.cos((0.5 * K)) * l))) * (J * 2.0)) + U;
}
def code(J, l, K, U): return (math.log1p(math.expm1((math.cos((0.5 * K)) * l))) * (J * 2.0)) + U
function code(J, l, K, U) return Float64(Float64(log1p(expm1(Float64(cos(Float64(0.5 * K)) * l))) * Float64(J * 2.0)) + U) end
code[J_, l_, K_, U_] := N[(N[(N[Log[1 + N[(Exp[N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right)\right) \cdot \left(J \cdot 2\right) + U
\end{array}
Initial program 84.0%
Taylor expanded in l around 0 61.8%
associate-*r*61.8%
Simplified61.8%
Taylor expanded in J around 0 61.8%
associate-*r*61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
Simplified61.8%
log1p-expm1-u99.4%
Applied egg-rr99.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* 0.5 K))) (t_1 (cos (/ K 2.0))))
(if (<= t_1 -0.82)
(* U (+ 1.0 (* 2.0 (* J (/ (* t_0 l) U)))))
(if (<= t_1 -0.55)
(+ U (* (* J 2.0) (+ l (* l (* -0.125 (pow K 2.0))))))
(if (<= t_1 -0.005)
(+ U (* 2.0 (* l (* t_0 J))))
(+ U (* (* J 2.0) (log1p (expm1 l)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((0.5 * K));
double t_1 = cos((K / 2.0));
double tmp;
if (t_1 <= -0.82) {
tmp = U * (1.0 + (2.0 * (J * ((t_0 * l) / U))));
} else if (t_1 <= -0.55) {
tmp = U + ((J * 2.0) * (l + (l * (-0.125 * pow(K, 2.0)))));
} else if (t_1 <= -0.005) {
tmp = U + (2.0 * (l * (t_0 * J)));
} else {
tmp = U + ((J * 2.0) * log1p(expm1(l)));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((0.5 * K));
double t_1 = Math.cos((K / 2.0));
double tmp;
if (t_1 <= -0.82) {
tmp = U * (1.0 + (2.0 * (J * ((t_0 * l) / U))));
} else if (t_1 <= -0.55) {
tmp = U + ((J * 2.0) * (l + (l * (-0.125 * Math.pow(K, 2.0)))));
} else if (t_1 <= -0.005) {
tmp = U + (2.0 * (l * (t_0 * J)));
} else {
tmp = U + ((J * 2.0) * Math.log1p(Math.expm1(l)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((0.5 * K)) t_1 = math.cos((K / 2.0)) tmp = 0 if t_1 <= -0.82: tmp = U * (1.0 + (2.0 * (J * ((t_0 * l) / U)))) elif t_1 <= -0.55: tmp = U + ((J * 2.0) * (l + (l * (-0.125 * math.pow(K, 2.0))))) elif t_1 <= -0.005: tmp = U + (2.0 * (l * (t_0 * J))) else: tmp = U + ((J * 2.0) * math.log1p(math.expm1(l))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(0.5 * K)) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_1 <= -0.82) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(t_0 * l) / U))))); elseif (t_1 <= -0.55) tmp = Float64(U + Float64(Float64(J * 2.0) * Float64(l + Float64(l * Float64(-0.125 * (K ^ 2.0)))))); elseif (t_1 <= -0.005) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(t_0 * J)))); else tmp = Float64(U + Float64(Float64(J * 2.0) * log1p(expm1(l)))); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.82], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(t$95$0 * l), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.55], N[(U + N[(N[(J * 2.0), $MachinePrecision] * N[(l + N[(l * N[(-0.125 * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.005], N[(U + N[(2.0 * N[(l * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * 2.0), $MachinePrecision] * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_1 \leq -0.82:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{t\_0 \cdot \ell}{U}\right)\right)\\
\mathbf{elif}\;t\_1 \leq -0.55:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \left(\ell + \ell \cdot \left(-0.125 \cdot {K}^{2}\right)\right)\\
\mathbf{elif}\;t\_1 \leq -0.005:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(t\_0 \cdot J\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.819999999999999951Initial program 73.4%
Taylor expanded in l around 0 62.7%
associate-*r*62.7%
Simplified62.7%
Taylor expanded in U around inf 62.6%
associate-/l*75.7%
*-commutative75.7%
Simplified75.7%
if -0.819999999999999951 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.55000000000000004Initial program 97.5%
Taylor expanded in l around 0 29.0%
associate-*r*29.0%
Simplified29.0%
Taylor expanded in J around 0 29.0%
associate-*r*29.0%
*-commutative29.0%
*-commutative29.0%
*-commutative29.0%
Simplified29.0%
Taylor expanded in K around 0 70.2%
associate-*r*70.2%
Simplified70.2%
if -0.55000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0050000000000000001Initial program 65.8%
Taylor expanded in l around 0 72.2%
associate-*r*72.2%
Simplified72.2%
Taylor expanded in J around 0 72.2%
associate-*r*72.2%
*-commutative72.2%
*-commutative72.2%
*-commutative72.2%
Simplified72.2%
log1p-expm1-u99.9%
Applied egg-rr99.9%
Taylor expanded in K around inf 72.2%
*-commutative72.2%
associate-*l*72.2%
*-commutative72.2%
Simplified72.2%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0 63.9%
associate-*r*63.9%
Simplified63.9%
Taylor expanded in J around 0 63.9%
associate-*r*63.9%
*-commutative63.9%
*-commutative63.9%
*-commutative63.9%
Simplified63.9%
log1p-expm1-u99.5%
Applied egg-rr99.5%
Taylor expanded in K around 0 94.7%
Final simplification89.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (* U (+ 1.0 (* 2.0 (* J (/ (* (cos (* 0.5 K)) l) U)))))))
(if (<= t_0 -0.82)
t_1
(if (<= t_0 -0.55)
(+ U (* (* J 2.0) (+ l (* l (* -0.125 (pow K 2.0))))))
(if (<= t_0 0.2)
t_1
(+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U * (1.0 + (2.0 * (J * ((cos((0.5 * K)) * l) / U))));
double tmp;
if (t_0 <= -0.82) {
tmp = t_1;
} else if (t_0 <= -0.55) {
tmp = U + ((J * 2.0) * (l + (l * (-0.125 * pow(K, 2.0)))));
} else if (t_0 <= 0.2) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u * (1.0d0 + (2.0d0 * (j * ((cos((0.5d0 * k)) * l) / u))))
if (t_0 <= (-0.82d0)) then
tmp = t_1
else if (t_0 <= (-0.55d0)) then
tmp = u + ((j * 2.0d0) * (l + (l * ((-0.125d0) * (k ** 2.0d0)))))
else if (t_0 <= 0.2d0) then
tmp = t_1
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 t_0 = Math.cos((K / 2.0));
double t_1 = U * (1.0 + (2.0 * (J * ((Math.cos((0.5 * K)) * l) / U))));
double tmp;
if (t_0 <= -0.82) {
tmp = t_1;
} else if (t_0 <= -0.55) {
tmp = U + ((J * 2.0) * (l + (l * (-0.125 * Math.pow(K, 2.0)))));
} else if (t_0 <= 0.2) {
tmp = t_1;
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U * (1.0 + (2.0 * (J * ((math.cos((0.5 * K)) * l) / U)))) tmp = 0 if t_0 <= -0.82: tmp = t_1 elif t_0 <= -0.55: tmp = U + ((J * 2.0) * (l + (l * (-0.125 * math.pow(K, 2.0))))) elif t_0 <= 0.2: tmp = t_1 else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(cos(Float64(0.5 * K)) * l) / U))))) tmp = 0.0 if (t_0 <= -0.82) tmp = t_1; elseif (t_0 <= -0.55) tmp = Float64(U + Float64(Float64(J * 2.0) * Float64(l + Float64(l * Float64(-0.125 * (K ^ 2.0)))))); elseif (t_0 <= 0.2) tmp = t_1; 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) t_0 = cos((K / 2.0)); t_1 = U * (1.0 + (2.0 * (J * ((cos((0.5 * K)) * l) / U)))); tmp = 0.0; if (t_0 <= -0.82) tmp = t_1; elseif (t_0 <= -0.55) tmp = U + ((J * 2.0) * (l + (l * (-0.125 * (K ^ 2.0))))); elseif (t_0 <= 0.2) tmp = t_1; else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.82], t$95$1, If[LessEqual[t$95$0, -0.55], N[(U + N[(N[(J * 2.0), $MachinePrecision] * N[(l + N[(l * N[(-0.125 * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.2], t$95$1, 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}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\cos \left(0.5 \cdot K\right) \cdot \ell}{U}\right)\right)\\
\mathbf{if}\;t\_0 \leq -0.82:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -0.55:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \left(\ell + \ell \cdot \left(-0.125 \cdot {K}^{2}\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.2:\\
\;\;\;\;t\_1\\
\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.819999999999999951 or -0.55000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.20000000000000001Initial program 71.2%
Taylor expanded in l around 0 65.6%
associate-*r*65.6%
Simplified65.6%
Taylor expanded in U around inf 65.5%
associate-/l*74.3%
*-commutative74.3%
Simplified74.3%
if -0.819999999999999951 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.55000000000000004Initial program 97.5%
Taylor expanded in l around 0 29.0%
associate-*r*29.0%
Simplified29.0%
Taylor expanded in J around 0 29.0%
associate-*r*29.0%
*-commutative29.0%
*-commutative29.0%
*-commutative29.0%
Simplified29.0%
Taylor expanded in K around 0 70.2%
associate-*r*70.2%
Simplified70.2%
if 0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.4%
Taylor expanded in l around 0 80.3%
Taylor expanded in K around 0 76.4%
Taylor expanded in J around 0 80.5%
Final simplification78.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.55)
(+ U (* (* J 2.0) (+ l (* l (* -0.125 (pow K 2.0))))))
(if (<= t_0 0.4)
(+ U (* 2.0 (* (* (cos (* 0.5 K)) l) J)))
(+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.55) {
tmp = U + ((J * 2.0) * (l + (l * (-0.125 * pow(K, 2.0)))));
} else if (t_0 <= 0.4) {
tmp = U + (2.0 * ((cos((0.5 * K)) * l) * J));
} 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) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= (-0.55d0)) then
tmp = u + ((j * 2.0d0) * (l + (l * ((-0.125d0) * (k ** 2.0d0)))))
else if (t_0 <= 0.4d0) then
tmp = u + (2.0d0 * ((cos((0.5d0 * k)) * l) * j))
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 t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.55) {
tmp = U + ((J * 2.0) * (l + (l * (-0.125 * Math.pow(K, 2.0)))));
} else if (t_0 <= 0.4) {
tmp = U + (2.0 * ((Math.cos((0.5 * K)) * l) * J));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.55: tmp = U + ((J * 2.0) * (l + (l * (-0.125 * math.pow(K, 2.0))))) elif t_0 <= 0.4: tmp = U + (2.0 * ((math.cos((0.5 * K)) * l) * J)) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.55) tmp = Float64(U + Float64(Float64(J * 2.0) * Float64(l + Float64(l * Float64(-0.125 * (K ^ 2.0)))))); elseif (t_0 <= 0.4) tmp = Float64(U + Float64(2.0 * Float64(Float64(cos(Float64(0.5 * K)) * l) * J))); 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) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.55) tmp = U + ((J * 2.0) * (l + (l * (-0.125 * (K ^ 2.0))))); elseif (t_0 <= 0.4) tmp = U + (2.0 * ((cos((0.5 * K)) * l) * J)); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = 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.55], N[(U + N[(N[(J * 2.0), $MachinePrecision] * N[(l + N[(l * N[(-0.125 * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.4], N[(U + N[(2.0 * N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * J), $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}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.55:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \left(\ell + \ell \cdot \left(-0.125 \cdot {K}^{2}\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.4:\\
\;\;\;\;U + 2 \cdot \left(\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right) \cdot J\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.55000000000000004Initial program 84.6%
Taylor expanded in l around 0 47.1%
associate-*r*47.1%
Simplified47.1%
Taylor expanded in J around 0 47.0%
associate-*r*47.0%
*-commutative47.0%
*-commutative47.0%
*-commutative47.0%
Simplified47.0%
Taylor expanded in K around 0 58.3%
associate-*r*58.3%
Simplified58.3%
if -0.55000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.40000000000000002Initial program 66.8%
Taylor expanded in l around 0 70.0%
if 0.40000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.6%
Taylor expanded in l around 0 79.6%
Taylor expanded in K around 0 77.0%
Taylor expanded in J around 0 81.2%
Final simplification75.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.5)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
(+ U (* (* J 2.0) (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.5) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else {
tmp = U + ((J * 2.0) * 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.5) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else {
tmp = U + ((J * 2.0) * 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.5: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) else: tmp = U + ((J * 2.0) * 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.5) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); else tmp = Float64(U + Float64(Float64(J * 2.0) * 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.5], 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[(N[(J * 2.0), $MachinePrecision] * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.5:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.5Initial program 76.5%
Taylor expanded in l around 0 88.2%
if 0.5 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.7%
Taylor expanded in l around 0 64.1%
associate-*r*64.1%
Simplified64.1%
Taylor expanded in J around 0 64.1%
associate-*r*64.1%
*-commutative64.1%
*-commutative64.1%
*-commutative64.1%
Simplified64.1%
log1p-expm1-u99.5%
Applied egg-rr99.5%
Taylor expanded in K around 0 97.3%
Final simplification94.3%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.5)
(+
U
(* J (* l (* (cos (* 0.5 K)) (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
(+ U (* (* J 2.0) (log1p (expm1 l))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.5) {
tmp = U + (J * (l * (cos((0.5 * K)) * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else {
tmp = U + ((J * 2.0) * 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.5) {
tmp = U + (J * (l * (Math.cos((0.5 * K)) * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else {
tmp = U + ((J * 2.0) * Math.log1p(Math.expm1(l)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.5: tmp = U + (J * (l * (math.cos((0.5 * K)) * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) else: tmp = U + ((J * 2.0) * math.log1p(math.expm1(l))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.5) tmp = Float64(U + Float64(J * Float64(l * Float64(cos(Float64(0.5 * K)) * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); else tmp = Float64(U + Float64(Float64(J * 2.0) * log1p(expm1(l)))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.5], N[(U + N[(J * N[(l * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * 2.0), $MachinePrecision] * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.5:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.5Initial program 76.5%
Taylor expanded in l around 0 83.8%
Taylor expanded in J around 0 88.1%
if 0.5 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.7%
Taylor expanded in l around 0 64.1%
associate-*r*64.1%
Simplified64.1%
Taylor expanded in J around 0 64.1%
associate-*r*64.1%
*-commutative64.1%
*-commutative64.1%
*-commutative64.1%
Simplified64.1%
log1p-expm1-u99.5%
Applied egg-rr99.5%
Taylor expanded in K around 0 97.3%
Final simplification94.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (cos (/ K 2.0)) (* 0.3333333333333333 (* J (pow l 3.0)))))))
(if (<= l -2.6e+119)
t_0
(if (<= l -340.0)
(+ U (* (* J 2.0) (log1p (expm1 l))))
(if (<= l 5.9e-5)
(+ U (* 2.0 (* l (* (cos (* 0.5 K)) J))))
(if (<= l 7.8e+99) (+ U (* J (- (exp l) (exp (- l))))) t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (0.3333333333333333 * (J * pow(l, 3.0))));
double tmp;
if (l <= -2.6e+119) {
tmp = t_0;
} else if (l <= -340.0) {
tmp = U + ((J * 2.0) * log1p(expm1(l)));
} else if (l <= 5.9e-5) {
tmp = U + (2.0 * (l * (cos((0.5 * K)) * J)));
} else if (l <= 7.8e+99) {
tmp = U + (J * (exp(l) - exp(-l)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.cos((K / 2.0)) * (0.3333333333333333 * (J * Math.pow(l, 3.0))));
double tmp;
if (l <= -2.6e+119) {
tmp = t_0;
} else if (l <= -340.0) {
tmp = U + ((J * 2.0) * Math.log1p(Math.expm1(l)));
} else if (l <= 5.9e-5) {
tmp = U + (2.0 * (l * (Math.cos((0.5 * K)) * J)));
} else if (l <= 7.8e+99) {
tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.cos((K / 2.0)) * (0.3333333333333333 * (J * math.pow(l, 3.0)))) tmp = 0 if l <= -2.6e+119: tmp = t_0 elif l <= -340.0: tmp = U + ((J * 2.0) * math.log1p(math.expm1(l))) elif l <= 5.9e-5: tmp = U + (2.0 * (l * (math.cos((0.5 * K)) * J))) elif l <= 7.8e+99: tmp = U + (J * (math.exp(l) - math.exp(-l))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))))) tmp = 0.0 if (l <= -2.6e+119) tmp = t_0; elseif (l <= -340.0) tmp = Float64(U + Float64(Float64(J * 2.0) * log1p(expm1(l)))); elseif (l <= 5.9e-5) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(cos(Float64(0.5 * K)) * J)))); elseif (l <= 7.8e+99) tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.6e+119], t$95$0, If[LessEqual[l, -340.0], N[(U + N[(N[(J * 2.0), $MachinePrecision] * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.9e-5], N[(U + N[(2.0 * N[(l * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.8e+99], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\mathbf{if}\;\ell \leq -2.6 \cdot 10^{+119}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -340:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\\
\mathbf{elif}\;\ell \leq 5.9 \cdot 10^{-5}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\right)\right)\\
\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+99}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -2.6e119 or 7.79999999999999989e99 < l Initial program 100.0%
Taylor expanded in l around 0 89.5%
Taylor expanded in l around inf 100.0%
if -2.6e119 < l < -340Initial program 100.0%
Taylor expanded in l around 0 12.4%
associate-*r*12.4%
Simplified12.4%
Taylor expanded in J around 0 12.4%
associate-*r*12.4%
*-commutative12.4%
*-commutative12.4%
*-commutative12.4%
Simplified12.4%
log1p-expm1-u100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 81.3%
if -340 < l < 5.8999999999999998e-5Initial program 66.0%
Taylor expanded in l around 0 99.4%
associate-*r*99.4%
Simplified99.4%
Taylor expanded in J around 0 99.4%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
*-commutative99.4%
Simplified99.4%
log1p-expm1-u99.4%
Applied egg-rr99.4%
Taylor expanded in K around inf 99.4%
*-commutative99.4%
associate-*l*99.4%
*-commutative99.4%
Simplified99.4%
if 5.8999999999999998e-5 < l < 7.79999999999999989e99Initial program 98.9%
Taylor expanded in K around 0 82.3%
Final simplification95.7%
(FPCore (J l K U)
:precision binary64
(if (<= l -5.3e+42)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 1.02e-5)
(+ U (* 2.0 (* l (* (cos (* 0.5 K)) J))))
(+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -5.3e+42) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 1.02e-5) {
tmp = U + (2.0 * (l * (cos((0.5 * K)) * J)));
} 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 (l <= (-5.3d+42)) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else if (l <= 1.02d-5) then
tmp = u + (2.0d0 * (l * (cos((0.5d0 * k)) * j)))
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 (l <= -5.3e+42) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else if (l <= 1.02e-5) {
tmp = U + (2.0 * (l * (Math.cos((0.5 * K)) * J)));
} 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 l <= -5.3e+42: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) elif l <= 1.02e-5: tmp = U + (2.0 * (l * (math.cos((0.5 * K)) * J))) 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 (l <= -5.3e+42) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 1.02e-5) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(cos(Float64(0.5 * K)) * J)))); 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 (l <= -5.3e+42) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); elseif (l <= 1.02e-5) tmp = U + (2.0 * (l * (cos((0.5 * K)) * J))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -5.3e+42], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.02e-5], N[(U + N[(2.0 * N[(l * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $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}\;\ell \leq -5.3 \cdot 10^{+42}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 1.02 \cdot 10^{-5}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -5.30000000000000028e42Initial program 100.0%
Taylor expanded in l around 0 72.5%
Taylor expanded in K around 0 56.6%
Taylor expanded in l around inf 66.4%
if -5.30000000000000028e42 < l < 1.0200000000000001e-5Initial program 69.1%
Taylor expanded in l around 0 91.5%
associate-*r*91.5%
Simplified91.5%
Taylor expanded in J around 0 91.5%
associate-*r*91.5%
*-commutative91.5%
*-commutative91.5%
*-commutative91.5%
Simplified91.5%
log1p-expm1-u99.4%
Applied egg-rr99.4%
Taylor expanded in K around inf 91.5%
*-commutative91.5%
associate-*l*91.5%
*-commutative91.5%
Simplified91.5%
if 1.0200000000000001e-5 < l Initial program 99.6%
Taylor expanded in l around 0 65.5%
Taylor expanded in K around 0 48.1%
Taylor expanded in J around 0 50.9%
Final simplification75.3%
(FPCore (J l K U)
:precision binary64
(if (<= l -5.4e+42)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 0.00027)
(+ U (* 2.0 (* l (* (cos (* 0.5 K)) J))))
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -5.4e+42) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 0.00027) {
tmp = U + (2.0 * (l * (cos((0.5 * K)) * J)));
} else {
tmp = 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 (l <= (-5.4d+42)) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else if (l <= 0.00027d0) then
tmp = u + (2.0d0 * (l * (cos((0.5d0 * k)) * j)))
else
tmp = 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 (l <= -5.4e+42) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else if (l <= 0.00027) {
tmp = U + (2.0 * (l * (Math.cos((0.5 * K)) * J)));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -5.4e+42: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) elif l <= 0.00027: tmp = U + (2.0 * (l * (math.cos((0.5 * K)) * J))) else: tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -5.4e+42) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 0.00027) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(cos(Float64(0.5 * K)) * J)))); else tmp = 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 (l <= -5.4e+42) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); elseif (l <= 0.00027) tmp = U + (2.0 * (l * (cos((0.5 * K)) * J))); else tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -5.4e+42], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.00027], N[(U + N[(2.0 * N[(l * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.4 \cdot 10^{+42}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 0.00027:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -5.4000000000000001e42Initial program 100.0%
Taylor expanded in l around 0 72.5%
Taylor expanded in K around 0 56.6%
Taylor expanded in l around inf 66.4%
if -5.4000000000000001e42 < l < 2.70000000000000003e-4Initial program 69.3%
Taylor expanded in l around 0 91.5%
associate-*r*91.5%
Simplified91.5%
Taylor expanded in J around 0 91.5%
associate-*r*91.5%
*-commutative91.5%
*-commutative91.5%
*-commutative91.5%
Simplified91.5%
log1p-expm1-u99.4%
Applied egg-rr99.4%
Taylor expanded in K around inf 91.5%
*-commutative91.5%
associate-*l*91.6%
*-commutative91.6%
Simplified91.6%
if 2.70000000000000003e-4 < l Initial program 99.6%
Taylor expanded in l around 0 64.9%
Taylor expanded in K around 0 47.3%
Taylor expanded in J around inf 49.4%
Final simplification75.2%
(FPCore (J l K U)
:precision binary64
(if (<= l -5.3e+42)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 0.00027)
(+ U (* 2.0 (* (* (cos (* 0.5 K)) l) J)))
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -5.3e+42) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 0.00027) {
tmp = U + (2.0 * ((cos((0.5 * K)) * l) * J));
} else {
tmp = 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 (l <= (-5.3d+42)) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else if (l <= 0.00027d0) then
tmp = u + (2.0d0 * ((cos((0.5d0 * k)) * l) * j))
else
tmp = 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 (l <= -5.3e+42) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else if (l <= 0.00027) {
tmp = U + (2.0 * ((Math.cos((0.5 * K)) * l) * J));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -5.3e+42: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) elif l <= 0.00027: tmp = U + (2.0 * ((math.cos((0.5 * K)) * l) * J)) else: tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -5.3e+42) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 0.00027) tmp = Float64(U + Float64(2.0 * Float64(Float64(cos(Float64(0.5 * K)) * l) * J))); else tmp = 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 (l <= -5.3e+42) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); elseif (l <= 0.00027) tmp = U + (2.0 * ((cos((0.5 * K)) * l) * J)); else tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -5.3e+42], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.00027], N[(U + N[(2.0 * N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.3 \cdot 10^{+42}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 0.00027:\\
\;\;\;\;U + 2 \cdot \left(\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right) \cdot J\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -5.30000000000000028e42Initial program 100.0%
Taylor expanded in l around 0 72.5%
Taylor expanded in K around 0 56.6%
Taylor expanded in l around inf 66.4%
if -5.30000000000000028e42 < l < 2.70000000000000003e-4Initial program 69.3%
Taylor expanded in l around 0 91.5%
if 2.70000000000000003e-4 < l Initial program 99.6%
Taylor expanded in l around 0 64.9%
Taylor expanded in K around 0 47.3%
Taylor expanded in J around inf 49.4%
Final simplification75.1%
(FPCore (J l K U)
:precision binary64
(if (<= l -2.2e+26)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 0.00027)
(fma l (* J 2.0) U)
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.2e+26) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 0.00027) {
tmp = fma(l, (J * 2.0), U);
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))));
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -2.2e+26) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 0.00027) tmp = fma(l, Float64(J * 2.0), U); else tmp = Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.2e+26], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.00027], N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.2 \cdot 10^{+26}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 0.00027:\\
\;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -2.20000000000000007e26Initial program 100.0%
Taylor expanded in l around 0 67.6%
Taylor expanded in K around 0 51.5%
Taylor expanded in l around inf 60.4%
if -2.20000000000000007e26 < l < 2.70000000000000003e-4Initial program 67.9%
Taylor expanded in l around 0 95.0%
associate-*r*95.0%
Simplified95.0%
Taylor expanded in J around 0 94.9%
associate-*r*94.9%
*-commutative94.9%
*-commutative94.9%
*-commutative94.9%
Simplified94.9%
log1p-expm1-u99.4%
Applied egg-rr99.4%
Taylor expanded in K around 0 76.4%
+-commutative76.4%
*-commutative76.4%
*-commutative76.4%
associate-*r*76.4%
fma-define76.4%
*-commutative76.4%
Simplified76.4%
if 2.70000000000000003e-4 < l Initial program 99.6%
Taylor expanded in l around 0 64.9%
Taylor expanded in K around 0 47.3%
Taylor expanded in J around inf 49.4%
Final simplification65.6%
(FPCore (J l K U)
:precision binary64
(if (<= l -2.3e+26)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 9e+32)
(fma l (* J 2.0) U)
(+ U (* (pow l 3.0) (* J 0.3333333333333333))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.3e+26) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 9e+32) {
tmp = fma(l, (J * 2.0), U);
} else {
tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -2.3e+26) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 9e+32) tmp = fma(l, Float64(J * 2.0), U); else tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.3e+26], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 9e+32], N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+26}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 9 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\
\mathbf{else}:\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if l < -2.3000000000000001e26Initial program 100.0%
Taylor expanded in l around 0 67.6%
Taylor expanded in K around 0 51.5%
Taylor expanded in l around inf 60.4%
if -2.3000000000000001e26 < l < 9.0000000000000007e32Initial program 69.8%
Taylor expanded in l around 0 89.8%
associate-*r*89.8%
Simplified89.8%
Taylor expanded in J around 0 89.7%
associate-*r*89.7%
*-commutative89.7%
*-commutative89.7%
*-commutative89.7%
Simplified89.7%
log1p-expm1-u98.9%
Applied egg-rr98.9%
Taylor expanded in K around 0 72.4%
+-commutative72.4%
*-commutative72.4%
*-commutative72.4%
associate-*r*72.4%
fma-define72.4%
*-commutative72.4%
Simplified72.4%
if 9.0000000000000007e32 < l Initial program 100.0%
Taylor expanded in l around 0 69.6%
Taylor expanded in l around inf 78.0%
Taylor expanded in K around 0 54.7%
*-commutative54.7%
*-commutative54.7%
associate-*l*54.7%
Simplified54.7%
Final simplification65.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.2e+26) (not (<= l 2000000000000.0))) (* 0.3333333333333333 (* J (pow l 3.0))) (fma l (* J 2.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.2e+26) || !(l <= 2000000000000.0)) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else {
tmp = fma(l, (J * 2.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.2e+26) || !(l <= 2000000000000.0)) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); else tmp = fma(l, Float64(J * 2.0), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.2e+26], N[Not[LessEqual[l, 2000000000000.0]], $MachinePrecision]], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.2 \cdot 10^{+26} \lor \neg \left(\ell \leq 2000000000000\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\
\end{array}
\end{array}
if l < -2.20000000000000007e26 or 2e12 < l Initial program 100.0%
Taylor expanded in l around 0 67.7%
Taylor expanded in K around 0 50.3%
Taylor expanded in l around inf 56.3%
if -2.20000000000000007e26 < l < 2e12Initial program 69.1%
Taylor expanded in l around 0 91.7%
associate-*r*91.7%
Simplified91.7%
Taylor expanded in J around 0 91.7%
associate-*r*91.7%
*-commutative91.7%
*-commutative91.7%
*-commutative91.7%
Simplified91.7%
log1p-expm1-u98.8%
Applied egg-rr98.8%
Taylor expanded in K around 0 74.0%
+-commutative74.0%
*-commutative74.0%
*-commutative74.0%
associate-*r*74.0%
fma-define74.0%
*-commutative74.0%
Simplified74.0%
Final simplification65.5%
(FPCore (J l K U) :precision binary64 (fma l (* J 2.0) U))
double code(double J, double l, double K, double U) {
return fma(l, (J * 2.0), U);
}
function code(J, l, K, U) return fma(l, Float64(J * 2.0), U) end
code[J_, l_, K_, U_] := N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\ell, J \cdot 2, U\right)
\end{array}
Initial program 84.0%
Taylor expanded in l around 0 61.8%
associate-*r*61.8%
Simplified61.8%
Taylor expanded in J around 0 61.8%
associate-*r*61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
Simplified61.8%
log1p-expm1-u99.4%
Applied egg-rr99.4%
Taylor expanded in K around 0 50.4%
+-commutative50.4%
*-commutative50.4%
*-commutative50.4%
associate-*r*50.4%
fma-define50.4%
*-commutative50.4%
Simplified50.4%
Final simplification50.4%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 2.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 = u + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 84.0%
Taylor expanded in l around 0 61.8%
associate-*r*61.8%
Simplified61.8%
Taylor expanded in K around 0 50.4%
associate-*r*50.4%
*-commutative50.4%
*-commutative50.4%
Simplified50.4%
Final simplification50.4%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J -6.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * -6.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 = u + (l * (j * (-6.0d0)))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * -6.0));
}
def code(J, l, K, U): return U + (l * (J * -6.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * -6.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * -6.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot -6\right)
\end{array}
Initial program 84.0%
Taylor expanded in l around 0 61.8%
associate-*r*61.8%
Simplified61.8%
Applied egg-rr34.7%
*-commutative34.7%
Simplified34.7%
Taylor expanded in K around 0 34.1%
*-commutative34.1%
*-commutative34.1%
associate-*l*34.1%
Simplified34.1%
Final simplification34.1%
(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 84.0%
Applied egg-rr25.2%
Taylor expanded in J around 0 32.2%
herbie shell --seed 2024088
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))