
(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 14 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 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
(if (<= t_0 0.0)
(+
(*
J
(*
l
(*
(cos (* K 0.5))
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))
U)
(+ t_0 U))))
double code(double J, double l, double K, double U) {
double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (J * (l * (cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (j * (exp(l) - exp(-l))) * cos((k / 2.0d0))
if (t_0 <= 0.0d0) then
tmp = (j * (l * (cos((k * 0.5d0)) * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0))))))) + u
else
tmp = t_0 + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = (J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (J * (l * (Math.cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U;
} else {
tmp = t_0 + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = (J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.0: tmp = (J * (l * (math.cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U else: tmp = t_0 + U return tmp
function code(J, l, K, U) t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(J * Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666))))))) + U); else tmp = Float64(t_0 + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = (J * (l * (cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U; else tmp = t_0 + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(J * N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 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] + U), $MachinePrecision], N[(t$95$0 + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;t\_0 + U\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -0.0Initial program 85.2%
Taylor expanded in l around 0 98.3%
*-commutative98.3%
Simplified98.3%
Taylor expanded in J around 0 98.3%
unpow298.3%
Applied egg-rr98.3%
unpow298.3%
Applied egg-rr98.3%
if -0.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) Initial program 100.0%
Final simplification98.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (<= (- (exp l) t_0) (- INFINITY))
(+ U (* (cos (/ K 2.0)) (* J (- 27.0 t_0))))
(+
(*
J
(*
l
(*
(cos (* K 0.5))
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))
U))))
double code(double J, double l, double K, double U) {
double t_0 = exp(-l);
double tmp;
if ((exp(l) - t_0) <= -((double) INFINITY)) {
tmp = U + (cos((K / 2.0)) * (J * (27.0 - t_0)));
} else {
tmp = (J * (l * (cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(-l);
double tmp;
if ((Math.exp(l) - t_0) <= -Double.POSITIVE_INFINITY) {
tmp = U + (Math.cos((K / 2.0)) * (J * (27.0 - t_0)));
} else {
tmp = (J * (l * (Math.cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(-l) tmp = 0 if (math.exp(l) - t_0) <= -math.inf: tmp = U + (math.cos((K / 2.0)) * (J * (27.0 - t_0))) else: tmp = (J * (l * (math.cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U return tmp
function code(J, l, K, U) t_0 = exp(Float64(-l)) tmp = 0.0 if (Float64(exp(l) - t_0) <= Float64(-Inf)) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(27.0 - t_0)))); else tmp = Float64(Float64(J * Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666))))))) + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(-l); tmp = 0.0; if ((exp(l) - t_0) <= -Inf) tmp = U + (cos((K / 2.0)) * (J * (27.0 - t_0))); else tmp = (J * (l * (cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[N[(N[Exp[l], $MachinePrecision] - t$95$0), $MachinePrecision], (-Infinity)], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(27.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(J * N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 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] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;e^{\ell} - t\_0 \leq -\infty:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(27 - t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) + U\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0Initial program 100.0%
Applied egg-rr100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 85.8%
Taylor expanded in l around 0 96.4%
*-commutative96.4%
Simplified96.4%
Taylor expanded in J around 0 96.5%
unpow296.5%
Applied egg-rr96.5%
unpow296.5%
Applied egg-rr96.5%
Final simplification97.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.9976)
(+ U (* t_0 (* J (* l (+ 2.0 (* (* l l) 0.3333333333333333))))))
(+
U
(*
J
(*
l
(+
2.0
(*
(+ 0.3333333333333333 (* (* l l) 0.016666666666666666))
(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.9976) {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * 0.3333333333333333)))));
} else {
tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * 0.016666666666666666)) * 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.9976d0) then
tmp = u + (t_0 * (j * (l * (2.0d0 + ((l * l) * 0.3333333333333333d0)))))
else
tmp = u + (j * (l * (2.0d0 + ((0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0)) * (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.9976) {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * 0.3333333333333333)))));
} else {
tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * 0.016666666666666666)) * 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.9976: tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * 0.3333333333333333))))) else: tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * 0.016666666666666666)) * 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.9976) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * 0.3333333333333333)))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)) * (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.9976) tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * 0.3333333333333333))))); else tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * 0.016666666666666666)) * (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.9976], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision] * 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.9976:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right) \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99760000000000004Initial program 90.1%
Taylor expanded in l around 0 87.8%
unpow293.5%
Applied egg-rr87.8%
if 0.99760000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in l around 0 96.5%
*-commutative96.5%
Simplified96.5%
Taylor expanded in J around 0 96.5%
unpow296.5%
Applied egg-rr96.5%
Taylor expanded in K around 0 96.5%
Final simplification92.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (* 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.01) {
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.01d0)) 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.01) {
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.01: 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.01) 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.01) 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.01], 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.01:\\
\;\;\;\;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.0100000000000000002Initial program 88.6%
Taylor expanded in l around 0 69.3%
*-commutative69.3%
associate-*l*69.3%
Simplified69.3%
Taylor expanded in U around inf 74.0%
associate-/l*73.9%
Simplified73.9%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 90.0%
Taylor expanded in l around 0 90.2%
Taylor expanded in K around 0 88.3%
Final simplification84.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (+ U (* J (* 2.0 (* 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.01) {
tmp = U + (J * (2.0 * (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.01d0)) then
tmp = u + (j * (2.0d0 * (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.01) {
tmp = U + (J * (2.0 * (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.01: tmp = U + (J * (2.0 * (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.01) tmp = Float64(U + Float64(J * Float64(2.0 * 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.01) tmp = U + (J * (2.0 * (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.01], N[(U + N[(J * N[(2.0 * 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.01:\\
\;\;\;\;U + J \cdot \left(2 \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.0100000000000000002Initial program 88.6%
Taylor expanded in l around 0 69.3%
*-commutative69.3%
associate-*l*69.3%
*-commutative69.3%
*-commutative69.3%
Simplified69.3%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 90.0%
Taylor expanded in l around 0 90.2%
Taylor expanded in K around 0 88.3%
Final simplification83.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (+ U (* J (* 2.0 (* l (cos (* K 0.5)))))) (* 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.01) {
tmp = U + (J * (2.0 * (l * cos((K * 0.5)))));
} 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.01d0)) then
tmp = u + (j * (2.0d0 * (l * cos((k * 0.5d0)))))
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.01) {
tmp = U + (J * (2.0 * (l * Math.cos((K * 0.5)))));
} 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.01: tmp = U + (J * (2.0 * (l * math.cos((K * 0.5))))) 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.01) tmp = Float64(U + Float64(J * Float64(2.0 * Float64(l * cos(Float64(K * 0.5)))))); 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.01) tmp = U + (J * (2.0 * (l * cos((K * 0.5))))); 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.01], N[(U + N[(J * N[(2.0 * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $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.01:\\
\;\;\;\;U + J \cdot \left(2 \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\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.0100000000000000002Initial program 88.6%
Taylor expanded in l around 0 69.3%
*-commutative69.3%
associate-*l*69.3%
*-commutative69.3%
*-commutative69.3%
Simplified69.3%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 90.0%
Taylor expanded in l around 0 62.5%
*-commutative62.5%
associate-*l*62.5%
Simplified62.5%
Taylor expanded in K around 0 60.5%
associate-*r*60.5%
*-commutative60.5%
Simplified60.5%
Taylor expanded in U around inf 65.3%
associate-/l*68.3%
Simplified68.3%
Final simplification68.5%
(FPCore (J l K U)
:precision binary64
(+
(*
J
(*
l
(*
(cos (* K 0.5))
(+
2.0
(* (* l l) (+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))
U))
double code(double J, double l, double K, double U) {
return (J * (l * (cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + 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 * (l * (cos((k * 0.5d0)) * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0))))))) + u
end function
public static double code(double J, double l, double K, double U) {
return (J * (l * (Math.cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U;
}
def code(J, l, K, U): return (J * (l * (math.cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U
function code(J, l, K, U) return Float64(Float64(J * Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666))))))) + U) end
function tmp = code(J, l, K, U) tmp = (J * (l * (cos((K * 0.5)) * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))) + U; end
code[J_, l_, K_, U_] := N[(N[(J * N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 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] + U), $MachinePrecision]
\begin{array}{l}
\\
J \cdot \left(\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) + U
\end{array}
Initial program 89.7%
Taylor expanded in l around 0 95.1%
*-commutative95.1%
Simplified95.1%
Taylor expanded in J around 0 95.2%
unpow295.2%
Applied egg-rr95.2%
unpow295.2%
Applied egg-rr95.2%
Final simplification95.2%
(FPCore (J l K U) :precision binary64 (+ U (* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* (* l l) 0.3333333333333333)))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * 0.3333333333333333)))));
}
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)))))
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)))));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * 0.3333333333333333)))))
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) * 0.3333333333333333)))))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * 0.3333333333333333))))); 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] * 0.3333333333333333), $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 0.3333333333333333\right)\right)\right)
\end{array}
Initial program 89.7%
Taylor expanded in l around 0 89.2%
unpow295.2%
Applied egg-rr89.2%
Final simplification89.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -9500000.0) (not (<= l 8.5e-6))) (* J (* l 2.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -9500000.0) || !(l <= 8.5e-6)) {
tmp = J * (l * 2.0);
} 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 <= (-9500000.0d0)) .or. (.not. (l <= 8.5d-6))) then
tmp = j * (l * 2.0d0)
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 <= -9500000.0) || !(l <= 8.5e-6)) {
tmp = J * (l * 2.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -9500000.0) or not (l <= 8.5e-6): tmp = J * (l * 2.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -9500000.0) || !(l <= 8.5e-6)) tmp = Float64(J * Float64(l * 2.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -9500000.0) || ~((l <= 8.5e-6))) tmp = J * (l * 2.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -9500000.0], N[Not[LessEqual[l, 8.5e-6]], $MachinePrecision]], N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9500000 \lor \neg \left(\ell \leq 8.5 \cdot 10^{-6}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -9.5e6 or 8.4999999999999999e-6 < l Initial program 99.8%
Taylor expanded in l around 0 33.2%
*-commutative33.2%
associate-*l*33.2%
Simplified33.2%
Taylor expanded in K around 0 26.6%
associate-*r*26.6%
*-commutative26.6%
Simplified26.6%
Taylor expanded in l around inf 26.6%
Taylor expanded in l around inf 26.5%
associate-*r*26.5%
*-commutative26.5%
associate-*r*26.5%
Simplified26.5%
if -9.5e6 < l < 8.4999999999999999e-6Initial program 78.2%
Applied egg-rr50.9%
Taylor expanded in U around inf 77.4%
Final simplification50.4%
(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 89.7%
Taylor expanded in l around 0 64.1%
*-commutative64.1%
associate-*l*64.1%
Simplified64.1%
Taylor expanded in K around 0 56.3%
associate-*r*56.3%
*-commutative56.3%
Simplified56.3%
Taylor expanded in U around inf 60.0%
associate-/l*62.3%
Simplified62.3%
(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 89.7%
Taylor expanded in l around 0 64.1%
*-commutative64.1%
associate-*l*64.1%
Simplified64.1%
Taylor expanded in K around 0 56.3%
associate-*r*56.3%
*-commutative56.3%
Simplified56.3%
Final simplification56.3%
(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 89.7%
Applied egg-rr25.1%
Taylor expanded in U around inf 37.5%
(FPCore (J l K U) :precision binary64 0.25)
double code(double J, double l, double K, double U) {
return 0.25;
}
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 = 0.25d0
end function
public static double code(double J, double l, double K, double U) {
return 0.25;
}
def code(J, l, K, U): return 0.25
function code(J, l, K, U) return 0.25 end
function tmp = code(J, l, K, U) tmp = 0.25; end
code[J_, l_, K_, U_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 89.7%
Applied egg-rr25.5%
Taylor expanded in U around 0 2.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 89.7%
Applied egg-rr25.1%
Taylor expanded in U around 0 2.5%
herbie shell --seed 2024185
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))