
(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 13 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 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -2.0) (not (<= t_1 0.001)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(*
l
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -2.0) || !(t_1 <= 0.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
}
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 = exp(l) - exp(-l)
if ((t_1 <= (-2.0d0)) .or. (.not. (t_1 <= 0.001d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0)))))))
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 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -2.0) || !(t_1 <= 0.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -2.0) or not (t_1 <= 0.001): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= -2.0) || !(t_1 <= 0.001)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)))))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -2.0) || ~((t_1 <= 0.001))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))); 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[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2.0], N[Not[LessEqual[t$95$1, 0.001]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_1 \leq -2 \lor \neg \left(t\_1 \leq 0.001\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2 or 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -2 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3Initial program 71.5%
Taylor expanded in l around 0 100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
Applied egg-rr100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.996) (+ U (* l (* (cos (* K 0.5)) (* J 2.0)))) (* U (+ 1.0 (* 2.0 (* J (/ l U)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.996) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / 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.996d0) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else
tmp = u * (1.0d0 + (2.0d0 * (j * (l / 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.996) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.996: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) else: tmp = U * (1.0 + (2.0 * (J * (l / U)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.996) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); else tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.996) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); else tmp = U * (1.0 + (2.0 * (J * (l / U)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.996], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.996:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.996Initial program 86.7%
Taylor expanded in l around 0 57.7%
*-commutative57.7%
associate-*l*57.7%
Simplified57.7%
Taylor expanded in J around 0 57.6%
*-commutative57.6%
associate-*r*57.7%
associate-*l*57.7%
*-commutative57.7%
associate-*r*57.7%
*-commutative57.7%
Simplified57.7%
if 0.996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.1%
Taylor expanded in l around 0 66.1%
*-commutative66.1%
associate-*l*66.1%
Simplified66.1%
Taylor expanded in K around 0 66.1%
associate-*r*66.1%
*-commutative66.1%
associate-*r*66.1%
Simplified66.1%
Taylor expanded in U around inf 69.7%
associate-/l*72.3%
Simplified72.3%
Final simplification65.8%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 2e-41)
(+ U (* J (log1p (expm1 (* l 2.0)))))
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* (* l l) 0.016666666666666666))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 2e-41) {
tmp = U + (J * log1p(expm1((l * 2.0))));
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 2e-41) {
tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 2e-41: tmp = U + (J * math.log1p(math.expm1((l * 2.0)))) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 2e-41) tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0))))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)))))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 2e-41], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 2.00000000000000001e-41Initial program 86.6%
Taylor expanded in l around 0 61.3%
*-commutative61.3%
associate-*l*61.3%
Simplified61.3%
Taylor expanded in K around 0 56.9%
associate-*r*56.9%
*-commutative56.9%
associate-*r*56.9%
Simplified56.9%
log1p-expm1-u90.3%
Applied egg-rr90.3%
if 2.00000000000000001e-41 < (/.f64 K #s(literal 2 binary64)) Initial program 83.3%
Taylor expanded in l around 0 95.6%
*-commutative95.6%
Simplified95.6%
unpow295.6%
Applied egg-rr95.6%
unpow295.6%
Applied egg-rr95.6%
Final simplification91.6%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -0.008) (not (<= l 6.5e-5)))
(+
U
(*
(*
J
(*
l
(+
2.0
(* (* l l) (+ 0.3333333333333333 (* (* l l) 0.016666666666666666))))))
(cos (* K -4.0))))
(+ U (* l (* (cos (* K 0.5)) (* J 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.008) || !(l <= 6.5e-5)) {
tmp = U + ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))) * cos((K * -4.0)));
} else {
tmp = U + (l * (cos((K * 0.5)) * (J * 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 <= (-0.008d0)) .or. (.not. (l <= 6.5d-5))) then
tmp = u + ((j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0)))))) * cos((k * (-4.0d0))))
else
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.008) || !(l <= 6.5e-5)) {
tmp = U + ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))) * Math.cos((K * -4.0)));
} else {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.008) or not (l <= 6.5e-5): tmp = U + ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))) * math.cos((K * -4.0))) else: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.008) || !(l <= 6.5e-5)) tmp = Float64(U + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)))))) * cos(Float64(K * -4.0)))); else tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.008) || ~((l <= 6.5e-5))) tmp = U + ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))) * cos((K * -4.0))); else tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.008], N[Not[LessEqual[l, 6.5e-5]], $MachinePrecision]], N[(U + N[(N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.008 \lor \neg \left(\ell \leq 6.5 \cdot 10^{-5}\right):\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) \cdot \cos \left(K \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -0.0080000000000000002 or 6.49999999999999943e-5 < l Initial program 99.9%
Taylor expanded in l around 0 85.5%
*-commutative85.5%
Simplified85.5%
unpow285.5%
Applied egg-rr85.5%
unpow285.5%
Applied egg-rr85.5%
Applied egg-rr69.1%
rem-log-exp69.1%
*-commutative69.1%
Simplified69.1%
if -0.0080000000000000002 < l < 6.49999999999999943e-5Initial program 71.4%
Taylor expanded in l around 0 100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in J around 0 99.9%
*-commutative99.9%
associate-*r*100.0%
associate-*l*100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification84.4%
(FPCore (J l K U)
:precision binary64
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(+
2.0
(* (* l l) (+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
}
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 + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0)))))))
end function
public static double code(double J, double l, double K, double U) {
return U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))))
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)))))))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))); end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)
\end{array}
Initial program 85.8%
Taylor expanded in l around 0 92.7%
*-commutative92.7%
Simplified92.7%
unpow292.7%
Applied egg-rr92.7%
unpow292.7%
Applied egg-rr92.7%
Final simplification92.7%
(FPCore (J l K U) :precision binary64 (if (<= K 0.0035) (* U (+ 1.0 (* 2.0 (* J (/ l U))))) (+ U (* J (* 2.0 (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 0.0035) {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
} else {
tmp = U + (J * (2.0 * (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 (k <= 0.0035d0) then
tmp = u * (1.0d0 + (2.0d0 * (j * (l / u))))
else
tmp = u + (j * (2.0d0 * (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 (K <= 0.0035) {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
} else {
tmp = U + (J * (2.0 * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if K <= 0.0035: tmp = U * (1.0 + (2.0 * (J * (l / U)))) else: tmp = U + (J * (2.0 * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (K <= 0.0035) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))); else tmp = Float64(U + Float64(J * Float64(2.0 * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (K <= 0.0035) tmp = U * (1.0 + (2.0 * (J * (l / U)))); else tmp = U + (J * (2.0 * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[K, 0.0035], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(2.0 * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 0.0035:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if K < 0.00350000000000000007Initial program 86.1%
Taylor expanded in l around 0 62.2%
*-commutative62.2%
associate-*l*62.2%
Simplified62.2%
Taylor expanded in K around 0 57.9%
associate-*r*57.9%
*-commutative57.9%
associate-*r*57.9%
Simplified57.9%
Taylor expanded in U around inf 60.5%
associate-/l*63.4%
Simplified63.4%
if 0.00350000000000000007 < K Initial program 84.6%
Taylor expanded in l around 0 62.8%
*-commutative62.8%
associate-*l*62.8%
*-commutative62.8%
*-commutative62.8%
Simplified62.8%
Final simplification63.2%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / 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 * (1.0d0 + (2.0d0 * (j * ((l * cos((k * 0.5d0))) / u))))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U))))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); end
code[J_, l_, K_, U_] := 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]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)
\end{array}
Initial program 85.8%
Taylor expanded in l around 0 62.3%
*-commutative62.3%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in U around inf 65.4%
associate-/l*68.8%
Simplified68.8%
Final simplification68.8%
(FPCore (J l K U) :precision binary64 (if (<= l -1700000000000.0) (* J (+ (* l 2.0) (/ U J))) (+ U (* J (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1700000000000.0) {
tmp = J * ((l * 2.0) + (U / J));
} else {
tmp = U + (J * (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 <= (-1700000000000.0d0)) then
tmp = j * ((l * 2.0d0) + (u / j))
else
tmp = u + (j * (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 <= -1700000000000.0) {
tmp = J * ((l * 2.0) + (U / J));
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1700000000000.0: tmp = J * ((l * 2.0) + (U / J)) else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1700000000000.0) tmp = Float64(J * Float64(Float64(l * 2.0) + Float64(U / J))); else tmp = Float64(U + Float64(J * Float64(l * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1700000000000.0) tmp = J * ((l * 2.0) + (U / J)); else tmp = U + (J * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1700000000000.0], N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1700000000000:\\
\;\;\;\;J \cdot \left(\ell \cdot 2 + \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -1.7e12Initial program 100.0%
Taylor expanded in l around 0 27.5%
*-commutative27.5%
associate-*l*27.5%
Simplified27.5%
Taylor expanded in K around 0 22.3%
associate-*r*22.3%
*-commutative22.3%
associate-*r*22.3%
Simplified22.3%
Taylor expanded in J around inf 29.7%
if -1.7e12 < l Initial program 81.2%
Taylor expanded in l around 0 73.5%
*-commutative73.5%
associate-*l*73.5%
Simplified73.5%
Taylor expanded in K around 0 64.3%
associate-*r*64.3%
*-commutative64.3%
associate-*r*64.3%
Simplified64.3%
Final simplification55.9%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (* J (/ l U))))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / 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 * (1.0d0 + (2.0d0 * (j * (l / u))))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / U))));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * (J * (l / U))))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * (J * (l / U)))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)
\end{array}
Initial program 85.8%
Taylor expanded in l around 0 62.3%
*-commutative62.3%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in K around 0 54.1%
associate-*r*54.1%
*-commutative54.1%
associate-*r*54.1%
Simplified54.1%
Taylor expanded in U around inf 56.1%
associate-/l*58.4%
Simplified58.4%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l 2.0))))
double code(double J, double l, double K, double U) {
return U + (J * (l * 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 + (j * (l * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
def code(J, l, K, U): return U + (J * (l * 2.0))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot 2\right)
\end{array}
Initial program 85.8%
Taylor expanded in l around 0 62.3%
*-commutative62.3%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in K around 0 54.1%
associate-*r*54.1%
*-commutative54.1%
associate-*r*54.1%
Simplified54.1%
Final simplification54.1%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 10.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 10.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 * 10.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 10.0));
}
def code(J, l, K, U): return U + (l * (J * 10.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 10.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 10.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 10\right)
\end{array}
Initial program 85.8%
Taylor expanded in l around 0 62.3%
*-commutative62.3%
associate-*l*62.3%
Simplified62.3%
Applied egg-rr46.4%
log1p-undefine46.4%
rem-exp-log46.4%
+-commutative46.4%
associate--l+46.4%
*-commutative46.4%
metadata-eval46.4%
Simplified46.4%
Taylor expanded in K around 0 46.4%
associate-*r*46.4%
*-commutative46.4%
*-commutative46.4%
Simplified46.4%
Final simplification46.4%
(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 85.8%
Applied egg-rr24.6%
Taylor expanded in U around inf 36.9%
(FPCore (J l K U) :precision binary64 -4.0)
double code(double J, double l, double K, double U) {
return -4.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 = -4.0d0
end function
public static double code(double J, double l, double K, double U) {
return -4.0;
}
def code(J, l, K, U): return -4.0
function code(J, l, K, U) return -4.0 end
function tmp = code(J, l, K, U) tmp = -4.0; end
code[J_, l_, K_, U_] := -4.0
\begin{array}{l}
\\
-4
\end{array}
Initial program 85.8%
Applied egg-rr24.6%
Taylor expanded in U around 0 2.7%
herbie shell --seed 2024177
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))