
(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 12 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 (<= t_1 -200.0)
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(*
l
(+
2.0
(*
(* l l)
(+
0.3333333333333333
(*
(* l l)
(+
0.016666666666666666
(* (* l l) 0.0003968253968253968)))))))))))))
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 <= -200.0) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
}
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 <= (-200.0d0)) 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 + ((l * l) * 0.0003968253968253968d0)))))))))
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 <= -200.0) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
}
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 <= -200.0: tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968))))))))) 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 <= -200.0) 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) * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968)))))))))); 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 <= -200.0) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968))))))))); 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[LessEqual[t$95$1, -200.0], 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] * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $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 -200:\\
\;\;\;\;\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 \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -200Initial program 100.0%
if -200 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 81.0%
Taylor expanded in l around 0 98.4%
*-commutative98.4%
Simplified98.4%
unpow298.4%
Applied egg-rr98.4%
unpow298.4%
Applied egg-rr98.4%
unpow298.4%
Applied egg-rr98.4%
Final simplification98.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (<= (- (exp l) t_0) -200.0)
(+ U (* J (* (cos (* K 0.5)) (- 0.3333333333333333 t_0))))
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(+
2.0
(*
(* l l)
(+
0.3333333333333333
(*
(* l l)
(+
0.016666666666666666
(* (* l l) 0.0003968253968253968)))))))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(-l);
double tmp;
if ((exp(l) - t_0) <= -200.0) {
tmp = U + (J * (cos((K * 0.5)) * (0.3333333333333333 - t_0)));
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
}
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 = exp(-l)
if ((exp(l) - t_0) <= (-200.0d0)) then
tmp = u + (j * (cos((k * 0.5d0)) * (0.3333333333333333d0 - t_0)))
else
tmp = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * (0.016666666666666666d0 + ((l * l) * 0.0003968253968253968d0)))))))))
end if
code = tmp
end function
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) <= -200.0) {
tmp = U + (J * (Math.cos((K * 0.5)) * (0.3333333333333333 - t_0)));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(-l) tmp = 0 if (math.exp(l) - t_0) <= -200.0: tmp = U + (J * (math.cos((K * 0.5)) * (0.3333333333333333 - t_0))) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968))))))))) return tmp
function code(J, l, K, U) t_0 = exp(Float64(-l)) tmp = 0.0 if (Float64(exp(l) - t_0) <= -200.0) tmp = Float64(U + Float64(J * Float64(cos(Float64(K * 0.5)) * Float64(0.3333333333333333 - t_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) * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968)))))))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(-l); tmp = 0.0; if ((exp(l) - t_0) <= -200.0) tmp = U + (J * (cos((K * 0.5)) * (0.3333333333333333 - t_0))); else tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968))))))))); 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], -200.0], N[(U + N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 - t$95$0), $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] * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;e^{\ell} - t\_0 \leq -200:\\
\;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(0.3333333333333333 - t\_0\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 \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -200Initial program 100.0%
Applied egg-rr99.1%
Taylor expanded in J around 0 99.1%
if -200 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 81.0%
Taylor expanded in l around 0 98.4%
*-commutative98.4%
Simplified98.4%
unpow298.4%
Applied egg-rr98.4%
unpow298.4%
Applied egg-rr98.4%
unpow298.4%
Applied egg-rr98.4%
Final simplification98.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+
U
(*
(cos (/ K 2.0))
(*
J
(-
(* l (+ 1.0 (* l (- (* l 0.16666666666666666) 0.5))))
0.6666666666666666))))))
(if (<= l -1e+103)
t_0
(if (<= l -22.0)
(+ U (* J (- 0.3333333333333333 (exp (- l)))))
(if (<= l 1.9e-9)
(+ U (* l (* (cos (* K 0.5)) (* J 2.0))))
(if (<= l 2e+101)
(+
U
(*
J
(*
l
(+
2.0
(*
(+
0.3333333333333333
(*
(* l l)
(+ 0.016666666666666666 (* (* l l) 0.0003968253968253968))))
(pow l 2.0))))))
t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666)));
double tmp;
if (l <= -1e+103) {
tmp = t_0;
} else if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else if (l <= 2e+101) {
tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))) * pow(l, 2.0)))));
} else {
tmp = t_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 = u + (cos((k / 2.0d0)) * (j * ((l * (1.0d0 + (l * ((l * 0.16666666666666666d0) - 0.5d0)))) - 0.6666666666666666d0)))
if (l <= (-1d+103)) then
tmp = t_0
else if (l <= (-22.0d0)) then
tmp = u + (j * (0.3333333333333333d0 - exp(-l)))
else if (l <= 1.9d-9) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else if (l <= 2d+101) then
tmp = u + (j * (l * (2.0d0 + ((0.3333333333333333d0 + ((l * l) * (0.016666666666666666d0 + ((l * l) * 0.0003968253968253968d0)))) * (l ** 2.0d0)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666)));
double tmp;
if (l <= -1e+103) {
tmp = t_0;
} else if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - Math.exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else if (l <= 2e+101) {
tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))) * Math.pow(l, 2.0)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666))) tmp = 0 if l <= -1e+103: tmp = t_0 elif l <= -22.0: tmp = U + (J * (0.3333333333333333 - math.exp(-l))) elif l <= 1.9e-9: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) elif l <= 2e+101: tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))) * math.pow(l, 2.0))))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(l * Float64(1.0 + Float64(l * Float64(Float64(l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666)))) tmp = 0.0 if (l <= -1e+103) tmp = t_0; elseif (l <= -22.0) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 - exp(Float64(-l))))); elseif (l <= 1.9e-9) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); elseif (l <= 2e+101) tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(0.3333333333333333 + Float64(Float64(l * l) * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968)))) * (l ^ 2.0)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666))); tmp = 0.0; if (l <= -1e+103) tmp = t_0; elseif (l <= -22.0) tmp = U + (J * (0.3333333333333333 - exp(-l))); elseif (l <= 1.9e-9) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); elseif (l <= 2e+101) tmp = U + (J * (l * (2.0 + ((0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))) * (l ^ 2.0))))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(l * N[(1.0 + N[(l * N[(N[(l * 0.16666666666666666), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+103], t$95$0, If[LessEqual[l, -22.0], N[(U + N[(J * N[(0.3333333333333333 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e-9], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2e+101], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(1 + \ell \cdot \left(\ell \cdot 0.16666666666666666 - 0.5\right)\right) - 0.6666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -22:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{+101}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right) \cdot {\ell}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -1e103 or 2e101 < l Initial program 100.0%
Applied egg-rr58.3%
Taylor expanded in l around 0 100.0%
if -1e103 < l < -22Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 81.0%
if -22 < l < 1.90000000000000006e-9Initial program 72.9%
Taylor expanded in l around 0 98.6%
*-commutative98.6%
associate-*r*98.7%
associate-*l*98.7%
*-commutative98.7%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
if 1.90000000000000006e-9 < l < 2e101Initial program 100.0%
Taylor expanded in l around 0 82.9%
*-commutative82.9%
Simplified82.9%
unpow282.9%
Applied egg-rr82.9%
unpow282.9%
Applied egg-rr82.9%
Taylor expanded in K around 0 71.2%
Final simplification95.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+
U
(*
(cos (/ K 2.0))
(*
J
(-
(* l (+ 1.0 (* l (- (* l 0.16666666666666666) 0.5))))
0.6666666666666666))))))
(if (<= l -1e+103)
t_0
(if (<= l -22.0)
(+ U (* J (- 0.3333333333333333 (exp (- l)))))
(if (<= l 1.9e-9) (+ U (* l (* (cos (* K 0.5)) (* J 2.0)))) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666)));
double tmp;
if (l <= -1e+103) {
tmp = t_0;
} else if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = t_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 = u + (cos((k / 2.0d0)) * (j * ((l * (1.0d0 + (l * ((l * 0.16666666666666666d0) - 0.5d0)))) - 0.6666666666666666d0)))
if (l <= (-1d+103)) then
tmp = t_0
else if (l <= (-22.0d0)) then
tmp = u + (j * (0.3333333333333333d0 - exp(-l)))
else if (l <= 1.9d-9) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666)));
double tmp;
if (l <= -1e+103) {
tmp = t_0;
} else if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - Math.exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666))) tmp = 0 if l <= -1e+103: tmp = t_0 elif l <= -22.0: tmp = U + (J * (0.3333333333333333 - math.exp(-l))) elif l <= 1.9e-9: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(l * Float64(1.0 + Float64(l * Float64(Float64(l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666)))) tmp = 0.0 if (l <= -1e+103) tmp = t_0; elseif (l <= -22.0) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 - exp(Float64(-l))))); elseif (l <= 1.9e-9) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (cos((K / 2.0)) * (J * ((l * (1.0 + (l * ((l * 0.16666666666666666) - 0.5)))) - 0.6666666666666666))); tmp = 0.0; if (l <= -1e+103) tmp = t_0; elseif (l <= -22.0) tmp = U + (J * (0.3333333333333333 - exp(-l))); elseif (l <= 1.9e-9) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(l * N[(1.0 + N[(l * N[(N[(l * 0.16666666666666666), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+103], t$95$0, If[LessEqual[l, -22.0], N[(U + N[(J * N[(0.3333333333333333 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e-9], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(1 + \ell \cdot \left(\ell \cdot 0.16666666666666666 - 0.5\right)\right) - 0.6666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -22:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -1e103 or 1.90000000000000006e-9 < l Initial program 100.0%
Applied egg-rr52.3%
Taylor expanded in l around 0 89.3%
if -1e103 < l < -22Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 81.0%
if -22 < l < 1.90000000000000006e-9Initial program 72.9%
Taylor expanded in l around 0 98.6%
*-commutative98.6%
associate-*r*98.7%
associate-*l*98.7%
*-commutative98.7%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
Final simplification93.3%
(FPCore (J l K U)
:precision binary64
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(+
2.0
(*
(* l l)
(+
0.3333333333333333
(*
(* l l)
(+ 0.016666666666666666 (* (* l l) 0.0003968253968253968)))))))))))
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 + ((l * l) * 0.0003968253968253968)))))))));
}
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 + ((l * l) * 0.0003968253968253968d0)))))))))
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 + ((l * l) * 0.0003968253968253968)))))))));
}
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 + ((l * l) * 0.0003968253968253968)))))))))
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) * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968)))))))))) 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 + ((l * l) * 0.0003968253968253968))))))))); 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] * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $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 \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)
\end{array}
Initial program 86.5%
Taylor expanded in l around 0 95.9%
*-commutative95.9%
Simplified95.9%
unpow295.9%
Applied egg-rr95.9%
unpow295.9%
Applied egg-rr95.9%
unpow295.9%
Applied egg-rr95.9%
Final simplification95.9%
(FPCore (J l K U)
:precision binary64
(if (<= l -6e+144)
(+
U
(* (cos (/ K 2.0)) (* J (- (* l (+ 1.0 (* l -0.5))) 0.6666666666666666))))
(if (<= l -22.0)
(+ U (* J (- 0.3333333333333333 (exp (- l)))))
(if (<= l 1.9e-9)
(+ U (* l (* (cos (* K 0.5)) (* J 2.0))))
(+
U
(+
(* J -0.6666666666666666)
(* l (+ J (* l (+ (* J -0.5) (* 0.16666666666666666 (* l J))))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6e+144) {
tmp = U + (cos((K / 2.0)) * (J * ((l * (1.0 + (l * -0.5))) - 0.6666666666666666)));
} else if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-6d+144)) then
tmp = u + (cos((k / 2.0d0)) * (j * ((l * (1.0d0 + (l * (-0.5d0)))) - 0.6666666666666666d0)))
else if (l <= (-22.0d0)) then
tmp = u + (j * (0.3333333333333333d0 - exp(-l)))
else if (l <= 1.9d-9) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else
tmp = u + ((j * (-0.6666666666666666d0)) + (l * (j + (l * ((j * (-0.5d0)) + (0.16666666666666666d0 * (l * j)))))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6e+144) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((l * (1.0 + (l * -0.5))) - 0.6666666666666666)));
} else if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - Math.exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -6e+144: tmp = U + (math.cos((K / 2.0)) * (J * ((l * (1.0 + (l * -0.5))) - 0.6666666666666666))) elif l <= -22.0: tmp = U + (J * (0.3333333333333333 - math.exp(-l))) elif l <= 1.9e-9: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) else: tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -6e+144) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(l * Float64(1.0 + Float64(l * -0.5))) - 0.6666666666666666)))); elseif (l <= -22.0) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 - exp(Float64(-l))))); elseif (l <= 1.9e-9) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); else tmp = Float64(U + Float64(Float64(J * -0.6666666666666666) + Float64(l * Float64(J + Float64(l * Float64(Float64(J * -0.5) + Float64(0.16666666666666666 * Float64(l * J)))))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -6e+144) tmp = U + (cos((K / 2.0)) * (J * ((l * (1.0 + (l * -0.5))) - 0.6666666666666666))); elseif (l <= -22.0) tmp = U + (J * (0.3333333333333333 - exp(-l))); elseif (l <= 1.9e-9) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); else tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -6e+144], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(l * N[(1.0 + N[(l * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -22.0], N[(U + N[(J * N[(0.3333333333333333 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e-9], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * -0.6666666666666666), $MachinePrecision] + N[(l * N[(J + N[(l * N[(N[(J * -0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{+144}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(1 + \ell \cdot -0.5\right) - 0.6666666666666666\right)\right)\\
\mathbf{elif}\;\ell \leq -22:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot -0.6666666666666666 + \ell \cdot \left(J + \ell \cdot \left(J \cdot -0.5 + 0.16666666666666666 \cdot \left(\ell \cdot J\right)\right)\right)\right)\\
\end{array}
\end{array}
if l < -5.9999999999999998e144Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in l around 0 94.7%
if -5.9999999999999998e144 < l < -22Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 80.0%
if -22 < l < 1.90000000000000006e-9Initial program 72.9%
Taylor expanded in l around 0 98.6%
*-commutative98.6%
associate-*r*98.7%
associate-*l*98.7%
*-commutative98.7%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
if 1.90000000000000006e-9 < l Initial program 100.0%
Applied egg-rr8.9%
Taylor expanded in l around 0 79.6%
Taylor expanded in K around 0 54.6%
Final simplification85.9%
(FPCore (J l K U)
:precision binary64
(if (<= l -22.0)
(+ U (* J (- 0.3333333333333333 (exp (- l)))))
(if (<= l 1.9e-9)
(+ U (* l (* (cos (* K 0.5)) (* J 2.0))))
(+
U
(+
(* J -0.6666666666666666)
(* l (+ J (* l (+ (* J -0.5) (* 0.16666666666666666 (* l J)))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-22.0d0)) then
tmp = u + (j * (0.3333333333333333d0 - exp(-l)))
else if (l <= 1.9d-9) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else
tmp = u + ((j * (-0.6666666666666666d0)) + (l * (j + (l * ((j * (-0.5d0)) + (0.16666666666666666d0 * (l * j)))))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - Math.exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -22.0: tmp = U + (J * (0.3333333333333333 - math.exp(-l))) elif l <= 1.9e-9: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) else: tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -22.0) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 - exp(Float64(-l))))); elseif (l <= 1.9e-9) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); else tmp = Float64(U + Float64(Float64(J * -0.6666666666666666) + Float64(l * Float64(J + Float64(l * Float64(Float64(J * -0.5) + Float64(0.16666666666666666 * Float64(l * J)))))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -22.0) tmp = U + (J * (0.3333333333333333 - exp(-l))); elseif (l <= 1.9e-9) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); else tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -22.0], N[(U + N[(J * N[(0.3333333333333333 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e-9], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * -0.6666666666666666), $MachinePrecision] + N[(l * N[(J + N[(l * N[(N[(J * -0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -22:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot -0.6666666666666666 + \ell \cdot \left(J + \ell \cdot \left(J \cdot -0.5 + 0.16666666666666666 \cdot \left(\ell \cdot J\right)\right)\right)\right)\\
\end{array}
\end{array}
if l < -22Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 77.8%
if -22 < l < 1.90000000000000006e-9Initial program 72.9%
Taylor expanded in l around 0 98.6%
*-commutative98.6%
associate-*r*98.7%
associate-*l*98.7%
*-commutative98.7%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
if 1.90000000000000006e-9 < l Initial program 100.0%
Applied egg-rr8.9%
Taylor expanded in l around 0 79.6%
Taylor expanded in K around 0 54.6%
Final simplification83.1%
(FPCore (J l K U)
:precision binary64
(if (<= l -22.0)
(+ U (* J (- 0.3333333333333333 (exp (- l)))))
(if (<= l 1.9e-9)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(+
U
(+
(* J -0.6666666666666666)
(* l (+ J (* l (+ (* J -0.5) (* 0.16666666666666666 (* l J)))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-22.0d0)) then
tmp = u + (j * (0.3333333333333333d0 - exp(-l)))
else if (l <= 1.9d-9) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + ((j * (-0.6666666666666666d0)) + (l * (j + (l * ((j * (-0.5d0)) + (0.16666666666666666d0 * (l * j)))))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -22.0) {
tmp = U + (J * (0.3333333333333333 - Math.exp(-l)));
} else if (l <= 1.9e-9) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -22.0: tmp = U + (J * (0.3333333333333333 - math.exp(-l))) elif l <= 1.9e-9: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -22.0) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 - exp(Float64(-l))))); elseif (l <= 1.9e-9) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(Float64(J * -0.6666666666666666) + Float64(l * Float64(J + Float64(l * Float64(Float64(J * -0.5) + Float64(0.16666666666666666 * Float64(l * J)))))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -22.0) tmp = U + (J * (0.3333333333333333 - exp(-l))); elseif (l <= 1.9e-9) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -22.0], N[(U + N[(J * N[(0.3333333333333333 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e-9], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * -0.6666666666666666), $MachinePrecision] + N[(l * N[(J + N[(l * N[(N[(J * -0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -22:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot -0.6666666666666666 + \ell \cdot \left(J + \ell \cdot \left(J \cdot -0.5 + 0.16666666666666666 \cdot \left(\ell \cdot J\right)\right)\right)\right)\\
\end{array}
\end{array}
if l < -22Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 77.8%
if -22 < l < 1.90000000000000006e-9Initial program 72.9%
Taylor expanded in l around 0 98.6%
if 1.90000000000000006e-9 < l Initial program 100.0%
Applied egg-rr8.9%
Taylor expanded in l around 0 79.6%
Taylor expanded in K around 0 54.6%
Final simplification83.1%
(FPCore (J l K U)
:precision binary64
(if (<= l -6.4e-52)
(+ U (* J (- 0.3333333333333333 (exp (- l)))))
(if (<= l 7.6e-11)
U
(+
U
(+
(* J -0.6666666666666666)
(* l (+ J (* l (+ (* J -0.5) (* 0.16666666666666666 (* l J)))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6.4e-52) {
tmp = U + (J * (0.3333333333333333 - exp(-l)));
} else if (l <= 7.6e-11) {
tmp = U;
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-6.4d-52)) then
tmp = u + (j * (0.3333333333333333d0 - exp(-l)))
else if (l <= 7.6d-11) then
tmp = u
else
tmp = u + ((j * (-0.6666666666666666d0)) + (l * (j + (l * ((j * (-0.5d0)) + (0.16666666666666666d0 * (l * j)))))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6.4e-52) {
tmp = U + (J * (0.3333333333333333 - Math.exp(-l)));
} else if (l <= 7.6e-11) {
tmp = U;
} else {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -6.4e-52: tmp = U + (J * (0.3333333333333333 - math.exp(-l))) elif l <= 7.6e-11: tmp = U else: tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -6.4e-52) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 - exp(Float64(-l))))); elseif (l <= 7.6e-11) tmp = U; else tmp = Float64(U + Float64(Float64(J * -0.6666666666666666) + Float64(l * Float64(J + Float64(l * Float64(Float64(J * -0.5) + Float64(0.16666666666666666 * Float64(l * J)))))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -6.4e-52) tmp = U + (J * (0.3333333333333333 - exp(-l))); elseif (l <= 7.6e-11) tmp = U; else tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -6.4e-52], N[(U + N[(J * N[(0.3333333333333333 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.6e-11], U, N[(U + N[(N[(J * -0.6666666666666666), $MachinePrecision] + N[(l * N[(J + N[(l * N[(N[(J * -0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.4 \cdot 10^{-52}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 7.6 \cdot 10^{-11}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot -0.6666666666666666 + \ell \cdot \left(J + \ell \cdot \left(J \cdot -0.5 + 0.16666666666666666 \cdot \left(\ell \cdot J\right)\right)\right)\right)\\
\end{array}
\end{array}
if l < -6.4000000000000002e-52Initial program 94.0%
Applied egg-rr91.9%
Taylor expanded in K around 0 72.7%
if -6.4000000000000002e-52 < l < 7.5999999999999996e-11Initial program 74.2%
associate-*l*74.2%
fma-define74.2%
Simplified74.2%
Taylor expanded in J around 0 74.0%
if 7.5999999999999996e-11 < l Initial program 100.0%
Applied egg-rr8.9%
Taylor expanded in l around 0 79.6%
Taylor expanded in K around 0 54.6%
Final simplification69.3%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -2.3e-51) (not (<= l 1.1e-9)))
(+
U
(+
(* J -0.6666666666666666)
(* l (+ J (* l (+ (* J -0.5) (* 0.16666666666666666 (* l J))))))))
U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.3e-51) || !(l <= 1.1e-9)) {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-2.3d-51)) .or. (.not. (l <= 1.1d-9))) then
tmp = u + ((j * (-0.6666666666666666d0)) + (l * (j + (l * ((j * (-0.5d0)) + (0.16666666666666666d0 * (l * j)))))))
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.3e-51) || !(l <= 1.1e-9)) {
tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J)))))));
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.3e-51) or not (l <= 1.1e-9): tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.3e-51) || !(l <= 1.1e-9)) tmp = Float64(U + Float64(Float64(J * -0.6666666666666666) + Float64(l * Float64(J + Float64(l * Float64(Float64(J * -0.5) + Float64(0.16666666666666666 * Float64(l * J)))))))); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.3e-51) || ~((l <= 1.1e-9))) tmp = U + ((J * -0.6666666666666666) + (l * (J + (l * ((J * -0.5) + (0.16666666666666666 * (l * J))))))); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.3e-51], N[Not[LessEqual[l, 1.1e-9]], $MachinePrecision]], N[(U + N[(N[(J * -0.6666666666666666), $MachinePrecision] + N[(l * N[(J + N[(l * N[(N[(J * -0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{-51} \lor \neg \left(\ell \leq 1.1 \cdot 10^{-9}\right):\\
\;\;\;\;U + \left(J \cdot -0.6666666666666666 + \ell \cdot \left(J + \ell \cdot \left(J \cdot -0.5 + 0.16666666666666666 \cdot \left(\ell \cdot J\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -2.30000000000000002e-51 or 1.0999999999999999e-9 < l Initial program 96.4%
Applied egg-rr59.2%
Taylor expanded in l around 0 72.2%
Taylor expanded in K around 0 54.8%
if -2.30000000000000002e-51 < l < 1.0999999999999999e-9Initial program 74.2%
associate-*l*74.2%
fma-define74.2%
Simplified74.2%
Taylor expanded in J around 0 74.0%
Final simplification63.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3.4e+22) (not (<= l 750.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.4e+22) || !(l <= 750.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-3.4d+22)) .or. (.not. (l <= 750.0d0))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.4e+22) || !(l <= 750.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -3.4e+22) or not (l <= 750.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -3.4e+22) || !(l <= 750.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -3.4e+22) || ~((l <= 750.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.4e+22], N[Not[LessEqual[l, 750.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.4 \cdot 10^{+22} \lor \neg \left(\ell \leq 750\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -3.4e22 or 750 < l Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Applied egg-rr17.2%
if -3.4e22 < l < 750Initial program 74.4%
associate-*l*74.3%
fma-define74.3%
Simplified74.3%
Taylor expanded in J around 0 69.4%
Final simplification44.7%
(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 86.5%
associate-*l*86.5%
fma-define86.5%
Simplified86.5%
Taylor expanded in J around 0 37.7%
herbie shell --seed 2024132
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))