
(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 16 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 -20000.0) (not (<= t_1 0.01)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(+
(* 0.016666666666666666 (pow l 5.0))
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))))
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 <= -20000.0) || !(t_1 <= 0.01)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-20000.0d0)) .or. (.not. (t_1 <= 0.01d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (j * ((0.016666666666666666d0 * (l ** 5.0d0)) + ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -20000.0) || !(t_1 <= 0.01)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)))));
}
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 <= -20000.0) or not (t_1 <= 0.01): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))) 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 <= -20000.0) || !(t_1 <= 0.01)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))))); 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 <= -20000.0) || ~((t_1 <= 0.01))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -20000.0], N[Not[LessEqual[t$95$1, 0.01]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -20000 \lor \neg \left(t_1 \leq 0.01\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2e4 or 0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -2e4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0100000000000000002Initial program 70.0%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -20000.0) (not (<= t_1 0.002)))
(+ (* (* t_1 J) t_0) U)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))))
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 <= -20000.0) || !(t_1 <= 0.002)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-20000.0d0)) .or. (.not. (t_1 <= 0.002d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -20000.0) || !(t_1 <= 0.002)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
}
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 <= -20000.0) or not (t_1 <= 0.002): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) 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 <= -20000.0) || !(t_1 <= 0.002)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); 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 <= -20000.0) || ~((t_1 <= 0.002))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -20000.0], N[Not[LessEqual[t$95$1, 0.002]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $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 -20000 \lor \neg \left(t_1 \leq 0.002\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2e4 or 2e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
if -2e4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2e-3Initial program 69.8%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (or (<= t_0 0.21) (and (not (<= t_0 0.77)) (<= t_0 0.995)))
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 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.21) || (!(t_0 <= 0.77) && (t_0 <= 0.995))) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (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.21d0) .or. (.not. (t_0 <= 0.77d0)) .and. (t_0 <= 0.995d0)) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (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.21) || (!(t_0 <= 0.77) && (t_0 <= 0.995))) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if (t_0 <= 0.21) or (not (t_0 <= 0.77) and (t_0 <= 0.995)): tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (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.21) || (!(t_0 <= 0.77) && (t_0 <= 0.995))) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(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.21) || (~((t_0 <= 0.77)) && (t_0 <= 0.995))) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (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[Or[LessEqual[t$95$0, 0.21], And[N[Not[LessEqual[t$95$0, 0.77]], $MachinePrecision], LessEqual[t$95$0, 0.995]]], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.21 \lor \neg \left(t_0 \leq 0.77\right) \land t_0 \leq 0.995:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.209999999999999992 or 0.77000000000000002 < (cos.f64 (/.f64 K 2)) < 0.994999999999999996Initial program 83.9%
Taylor expanded in l around 0 70.2%
if 0.209999999999999992 < (cos.f64 (/.f64 K 2)) < 0.77000000000000002 or 0.994999999999999996 < (cos.f64 (/.f64 K 2)) Initial program 85.8%
Taylor expanded in l around 0 86.6%
Taylor expanded in K around 0 86.1%
Final simplification79.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* 0.016666666666666666 (* (* J (pow l 5.0)) (cos (* K 0.5))))))
(t_1 (+ U (* (- (exp l) (exp (- l))) (+ J (* J (* K (* K -0.125))))))))
(if (<= l -4.5e+61)
t_0
(if (<= l -8.5)
t_1
(if (<= l 0.0031)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 2.3e+52) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (0.016666666666666666 * ((J * pow(l, 5.0)) * cos((K * 0.5))));
double t_1 = U + ((exp(l) - exp(-l)) * (J + (J * (K * (K * -0.125)))));
double tmp;
if (l <= -4.5e+61) {
tmp = t_0;
} else if (l <= -8.5) {
tmp = t_1;
} else if (l <= 0.0031) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2.3e+52) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = u + (0.016666666666666666d0 * ((j * (l ** 5.0d0)) * cos((k * 0.5d0))))
t_1 = u + ((exp(l) - exp(-l)) * (j + (j * (k * (k * (-0.125d0))))))
if (l <= (-4.5d+61)) then
tmp = t_0
else if (l <= (-8.5d0)) then
tmp = t_1
else if (l <= 0.0031d0) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 2.3d+52) then
tmp = t_1
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 + (0.016666666666666666 * ((J * Math.pow(l, 5.0)) * Math.cos((K * 0.5))));
double t_1 = U + ((Math.exp(l) - Math.exp(-l)) * (J + (J * (K * (K * -0.125)))));
double tmp;
if (l <= -4.5e+61) {
tmp = t_0;
} else if (l <= -8.5) {
tmp = t_1;
} else if (l <= 0.0031) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2.3e+52) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (0.016666666666666666 * ((J * math.pow(l, 5.0)) * math.cos((K * 0.5)))) t_1 = U + ((math.exp(l) - math.exp(-l)) * (J + (J * (K * (K * -0.125))))) tmp = 0 if l <= -4.5e+61: tmp = t_0 elif l <= -8.5: tmp = t_1 elif l <= 0.0031: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 2.3e+52: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(0.016666666666666666 * Float64(Float64(J * (l ^ 5.0)) * cos(Float64(K * 0.5))))) t_1 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * Float64(J + Float64(J * Float64(K * Float64(K * -0.125)))))) tmp = 0.0 if (l <= -4.5e+61) tmp = t_0; elseif (l <= -8.5) tmp = t_1; elseif (l <= 0.0031) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 2.3e+52) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (0.016666666666666666 * ((J * (l ^ 5.0)) * cos((K * 0.5)))); t_1 = U + ((exp(l) - exp(-l)) * (J + (J * (K * (K * -0.125))))); tmp = 0.0; if (l <= -4.5e+61) tmp = t_0; elseif (l <= -8.5) tmp = t_1; elseif (l <= 0.0031) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 2.3e+52) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.016666666666666666 * N[(N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * N[(J + N[(J * N[(K * N[(K * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.5e+61], t$95$0, If[LessEqual[l, -8.5], t$95$1, If[LessEqual[l, 0.0031], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.3e+52], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 0.016666666666666666 \cdot \left(\left(J \cdot {\ell}^{5}\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\
t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + J \cdot \left(K \cdot \left(K \cdot -0.125\right)\right)\right)\\
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -8.5:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.0031:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2.3 \cdot 10^{+52}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -4.5e61 or 2.3e52 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
associate-*r*100.0%
Simplified100.0%
if -4.5e61 < l < -8.5 or 0.00309999999999999989 < l < 2.3e52Initial program 99.7%
Taylor expanded in K around 0 7.7%
+-commutative7.7%
associate-*r*7.7%
associate-*r*7.7%
distribute-rgt-out87.7%
associate-*r*87.7%
*-commutative87.7%
associate-*l*87.7%
*-commutative87.7%
unpow287.7%
associate-*l*87.7%
Simplified87.7%
if -8.5 < l < 0.00309999999999999989Initial program 69.8%
Taylor expanded in l around 0 99.9%
Final simplification98.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* 0.016666666666666666 (* (* J (pow l 5.0)) t_0)))))
(if (<= l -2.6e+44)
t_1
(if (<= l -0.00016)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 360000.0)
(+ U (* 2.0 (* J (* l t_0))))
(if (<= l 3.2e+51)
(+ U (* 2.0 (* J (+ l (log1p (expm1 (* l (* K (* K -0.125)))))))))
t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + (0.016666666666666666 * ((J * pow(l, 5.0)) * t_0));
double tmp;
if (l <= -2.6e+44) {
tmp = t_1;
} else if (l <= -0.00016) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 360000.0) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 3.2e+51) {
tmp = U + (2.0 * (J * (l + log1p(expm1((l * (K * (K * -0.125))))))));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K * 0.5));
double t_1 = U + (0.016666666666666666 * ((J * Math.pow(l, 5.0)) * t_0));
double tmp;
if (l <= -2.6e+44) {
tmp = t_1;
} else if (l <= -0.00016) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 360000.0) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 3.2e+51) {
tmp = U + (2.0 * (J * (l + Math.log1p(Math.expm1((l * (K * (K * -0.125))))))));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + (0.016666666666666666 * ((J * math.pow(l, 5.0)) * t_0)) tmp = 0 if l <= -2.6e+44: tmp = t_1 elif l <= -0.00016: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 360000.0: tmp = U + (2.0 * (J * (l * t_0))) elif l <= 3.2e+51: tmp = U + (2.0 * (J * (l + math.log1p(math.expm1((l * (K * (K * -0.125)))))))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64(0.016666666666666666 * Float64(Float64(J * (l ^ 5.0)) * t_0))) tmp = 0.0 if (l <= -2.6e+44) tmp = t_1; elseif (l <= -0.00016) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 360000.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); elseif (l <= 3.2e+51) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + log1p(expm1(Float64(l * Float64(K * Float64(K * -0.125))))))))); else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(0.016666666666666666 * N[(N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.6e+44], t$95$1, If[LessEqual[l, -0.00016], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 360000.0], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.2e+51], N[(U + N[(2.0 * N[(J * N[(l + N[Log[1 + N[(Exp[N[(l * N[(K * N[(K * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + 0.016666666666666666 \cdot \left(\left(J \cdot {\ell}^{5}\right) \cdot t_0\right)\\
\mathbf{if}\;\ell \leq -2.6 \cdot 10^{+44}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.00016:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 360000:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_0\right)\right)\\
\mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+51}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(K \cdot \left(K \cdot -0.125\right)\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -2.5999999999999999e44 or 3.2000000000000002e51 < l Initial program 100.0%
Taylor expanded in l around 0 97.4%
Taylor expanded in l around inf 97.4%
associate-*r*97.4%
Simplified97.4%
if -2.5999999999999999e44 < l < -1.60000000000000013e-4Initial program 98.6%
Taylor expanded in K around 0 83.2%
if -1.60000000000000013e-4 < l < 3.6e5Initial program 69.7%
Taylor expanded in l around 0 98.0%
if 3.6e5 < l < 3.2000000000000002e51Initial program 100.0%
Taylor expanded in l around 0 2.5%
Taylor expanded in K around 0 0.9%
associate-*r*0.9%
associate-*r*0.9%
distribute-rgt-out0.9%
unpow20.9%
Simplified0.9%
Taylor expanded in K around 0 34.3%
unpow234.3%
*-commutative34.3%
associate-*l*34.3%
Simplified34.3%
log1p-expm1-u67.5%
Applied egg-rr67.5%
Final simplification95.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* 0.016666666666666666 (* (* J (pow l 5.0)) (cos (* K 0.5)))))))
(if (<= l -2.7e+40)
t_0
(if (<= l -0.75)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 4800000000.0)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 2.4e+51)
(+ U (* 2.0 (* J (+ l (log1p (expm1 (* l (* K (* K -0.125)))))))))
t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (0.016666666666666666 * ((J * pow(l, 5.0)) * cos((K * 0.5))));
double tmp;
if (l <= -2.7e+40) {
tmp = t_0;
} else if (l <= -0.75) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 4800000000.0) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2.4e+51) {
tmp = U + (2.0 * (J * (l + log1p(expm1((l * (K * (K * -0.125))))))));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + (0.016666666666666666 * ((J * Math.pow(l, 5.0)) * Math.cos((K * 0.5))));
double tmp;
if (l <= -2.7e+40) {
tmp = t_0;
} else if (l <= -0.75) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 4800000000.0) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2.4e+51) {
tmp = U + (2.0 * (J * (l + Math.log1p(Math.expm1((l * (K * (K * -0.125))))))));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (0.016666666666666666 * ((J * math.pow(l, 5.0)) * math.cos((K * 0.5)))) tmp = 0 if l <= -2.7e+40: tmp = t_0 elif l <= -0.75: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 4800000000.0: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 2.4e+51: tmp = U + (2.0 * (J * (l + math.log1p(math.expm1((l * (K * (K * -0.125)))))))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(0.016666666666666666 * Float64(Float64(J * (l ^ 5.0)) * cos(Float64(K * 0.5))))) tmp = 0.0 if (l <= -2.7e+40) tmp = t_0; elseif (l <= -0.75) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 4800000000.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 2.4e+51) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + log1p(expm1(Float64(l * Float64(K * Float64(K * -0.125))))))))); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.016666666666666666 * N[(N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.7e+40], t$95$0, If[LessEqual[l, -0.75], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 4800000000.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+51], N[(U + N[(2.0 * N[(J * N[(l + N[Log[1 + N[(Exp[N[(l * N[(K * N[(K * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 0.016666666666666666 \cdot \left(\left(J \cdot {\ell}^{5}\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;\ell \leq -2.7 \cdot 10^{+40}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.75:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 4800000000:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+51}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(K \cdot \left(K \cdot -0.125\right)\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -2.70000000000000009e40 or 2.3999999999999999e51 < l Initial program 100.0%
Taylor expanded in l around 0 97.4%
Taylor expanded in l around inf 97.4%
associate-*r*97.4%
Simplified97.4%
if -2.70000000000000009e40 < l < -0.75Initial program 99.8%
Taylor expanded in K around 0 79.8%
if -0.75 < l < 4.8e9Initial program 70.2%
Taylor expanded in l around 0 99.0%
if 4.8e9 < l < 2.3999999999999999e51Initial program 100.0%
Taylor expanded in l around 0 2.5%
Taylor expanded in K around 0 0.9%
associate-*r*0.9%
associate-*r*0.9%
distribute-rgt-out0.9%
unpow20.9%
Simplified0.9%
Taylor expanded in K around 0 34.3%
unpow234.3%
*-commutative34.3%
associate-*l*34.3%
Simplified34.3%
log1p-expm1-u67.5%
Applied egg-rr67.5%
Final simplification96.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* 0.016666666666666666 (* (* J (pow l 5.0)) t_0)))))
(if (<= l -2.5e+48)
t_1
(if (<= l -0.000115)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 3.3) (+ U (* 2.0 (* J (* l t_0)))) t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + (0.016666666666666666 * ((J * pow(l, 5.0)) * t_0));
double tmp;
if (l <= -2.5e+48) {
tmp = t_1;
} else if (l <= -0.000115) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 3.3) {
tmp = U + (2.0 * (J * (l * t_0)));
} else {
tmp = t_1;
}
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 * 0.5d0))
t_1 = u + (0.016666666666666666d0 * ((j * (l ** 5.0d0)) * t_0))
if (l <= (-2.5d+48)) then
tmp = t_1
else if (l <= (-0.000115d0)) then
tmp = ((exp(l) - exp(-l)) * j) + u
else if (l <= 3.3d0) then
tmp = u + (2.0d0 * (j * (l * t_0)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K * 0.5));
double t_1 = U + (0.016666666666666666 * ((J * Math.pow(l, 5.0)) * t_0));
double tmp;
if (l <= -2.5e+48) {
tmp = t_1;
} else if (l <= -0.000115) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 3.3) {
tmp = U + (2.0 * (J * (l * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + (0.016666666666666666 * ((J * math.pow(l, 5.0)) * t_0)) tmp = 0 if l <= -2.5e+48: tmp = t_1 elif l <= -0.000115: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 3.3: tmp = U + (2.0 * (J * (l * t_0))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64(0.016666666666666666 * Float64(Float64(J * (l ^ 5.0)) * t_0))) tmp = 0.0 if (l <= -2.5e+48) tmp = t_1; elseif (l <= -0.000115) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 3.3) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); t_1 = U + (0.016666666666666666 * ((J * (l ^ 5.0)) * t_0)); tmp = 0.0; if (l <= -2.5e+48) tmp = t_1; elseif (l <= -0.000115) tmp = ((exp(l) - exp(-l)) * J) + U; elseif (l <= 3.3) tmp = U + (2.0 * (J * (l * t_0))); else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(0.016666666666666666 * N[(N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.5e+48], t$95$1, If[LessEqual[l, -0.000115], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 3.3], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + 0.016666666666666666 \cdot \left(\left(J \cdot {\ell}^{5}\right) \cdot t_0\right)\\
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{+48}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.000115:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 3.3:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -2.49999999999999987e48 or 3.2999999999999998 < l Initial program 100.0%
Taylor expanded in l around 0 90.2%
Taylor expanded in l around inf 90.2%
associate-*r*90.2%
Simplified90.2%
if -2.49999999999999987e48 < l < -1.15e-4Initial program 98.6%
Taylor expanded in K around 0 83.2%
if -1.15e-4 < l < 3.2999999999999998Initial program 69.4%
Taylor expanded in l around 0 98.8%
Final simplification94.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.00016) (not (<= l 0.00065))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.00016) || !(l <= 0.00065)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-0.00016d0)) .or. (.not. (l <= 0.00065d0))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.00016) || !(l <= 0.00065)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.00016) or not (l <= 0.00065): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.00016) || !(l <= 0.00065)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.00016) || ~((l <= 0.00065))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.00016], N[Not[LessEqual[l, 0.00065]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.00016 \lor \neg \left(\ell \leq 0.00065\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -1.60000000000000013e-4 or 6.4999999999999997e-4 < l Initial program 99.8%
Taylor expanded in K around 0 73.3%
if -1.60000000000000013e-4 < l < 6.4999999999999997e-4Initial program 69.2%
Taylor expanded in l around 0 99.2%
Final simplification85.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.58) (+ U (* 2.0 (* -0.125 (* J (* l (* K K)))))) (+ U (* 2.0 (* l J)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.58) {
tmp = U + (2.0 * (-0.125 * (J * (l * (K * K)))));
} else {
tmp = U + (2.0 * (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 (cos((k / 2.0d0)) <= (-0.58d0)) then
tmp = u + (2.0d0 * ((-0.125d0) * (j * (l * (k * k)))))
else
tmp = u + (2.0d0 * (l * j))
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.58) {
tmp = U + (2.0 * (-0.125 * (J * (l * (K * K)))));
} else {
tmp = U + (2.0 * (l * J));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.58: tmp = U + (2.0 * (-0.125 * (J * (l * (K * K))))) else: tmp = U + (2.0 * (l * J)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.58) tmp = Float64(U + Float64(2.0 * Float64(-0.125 * Float64(J * Float64(l * Float64(K * K)))))); else tmp = Float64(U + Float64(2.0 * Float64(l * J))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.58) tmp = U + (2.0 * (-0.125 * (J * (l * (K * K))))); else tmp = U + (2.0 * (l * J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.58], N[(U + N[(2.0 * N[(-0.125 * N[(J * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.58:\\
\;\;\;\;U + 2 \cdot \left(-0.125 \cdot \left(J \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.57999999999999996Initial program 86.1%
Taylor expanded in l around 0 59.1%
Taylor expanded in K around 0 7.5%
associate-*r*7.5%
associate-*r*7.5%
distribute-rgt-out7.5%
unpow27.5%
Simplified7.5%
Taylor expanded in K around 0 59.0%
unpow259.0%
*-commutative59.0%
associate-*l*59.0%
Simplified59.0%
Taylor expanded in K around inf 59.0%
*-commutative59.0%
unpow259.0%
Simplified59.0%
if -0.57999999999999996 < (cos.f64 (/.f64 K 2)) Initial program 84.8%
Taylor expanded in l around 0 67.7%
Taylor expanded in K around 0 61.3%
Final simplification60.9%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * cos((K * 0.5)))));
}
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 + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 85.0%
Taylor expanded in l around 0 66.3%
Final simplification66.3%
(FPCore (J l K U) :precision binary64 (if (<= l -2.2e+18) (* U U) (if (<= l 8e+32) U (if (<= l 8e+257) (* U U) (+ U (* J 0.125))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.2e+18) {
tmp = U * U;
} else if (l <= 8e+32) {
tmp = U;
} else if (l <= 8e+257) {
tmp = U * U;
} else {
tmp = U + (J * 0.125);
}
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.2d+18)) then
tmp = u * u
else if (l <= 8d+32) then
tmp = u
else if (l <= 8d+257) then
tmp = u * u
else
tmp = u + (j * 0.125d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.2e+18) {
tmp = U * U;
} else if (l <= 8e+32) {
tmp = U;
} else if (l <= 8e+257) {
tmp = U * U;
} else {
tmp = U + (J * 0.125);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -2.2e+18: tmp = U * U elif l <= 8e+32: tmp = U elif l <= 8e+257: tmp = U * U else: tmp = U + (J * 0.125) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -2.2e+18) tmp = Float64(U * U); elseif (l <= 8e+32) tmp = U; elseif (l <= 8e+257) tmp = Float64(U * U); else tmp = Float64(U + Float64(J * 0.125)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -2.2e+18) tmp = U * U; elseif (l <= 8e+32) tmp = U; elseif (l <= 8e+257) tmp = U * U; else tmp = U + (J * 0.125); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.2e+18], N[(U * U), $MachinePrecision], If[LessEqual[l, 8e+32], U, If[LessEqual[l, 8e+257], N[(U * U), $MachinePrecision], N[(U + N[(J * 0.125), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.2 \cdot 10^{+18}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 8 \cdot 10^{+32}:\\
\;\;\;\;U\\
\mathbf{elif}\;\ell \leq 8 \cdot 10^{+257}:\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot 0.125\\
\end{array}
\end{array}
if l < -2.2e18 or 8.00000000000000043e32 < l < 8.00000000000000024e257Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr18.3%
if -2.2e18 < l < 8.00000000000000043e32Initial program 72.0%
associate-*l*72.0%
fma-def72.0%
Simplified72.0%
Taylor expanded in J around 0 61.8%
if 8.00000000000000024e257 < l Initial program 100.0%
Applied egg-rr4.4%
Taylor expanded in K around 0 4.4%
*-commutative4.4%
Simplified4.4%
Final simplification41.3%
(FPCore (J l K U) :precision binary64 (if (<= l -6e+17) (* U U) (if (<= l 3.8e+31) U (if (<= l 5.1e+259) (* U U) U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6e+17) {
tmp = U * U;
} else if (l <= 3.8e+31) {
tmp = U;
} else if (l <= 5.1e+259) {
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 <= (-6d+17)) then
tmp = u * u
else if (l <= 3.8d+31) then
tmp = u
else if (l <= 5.1d+259) 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 <= -6e+17) {
tmp = U * U;
} else if (l <= 3.8e+31) {
tmp = U;
} else if (l <= 5.1e+259) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -6e+17: tmp = U * U elif l <= 3.8e+31: tmp = U elif l <= 5.1e+259: tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -6e+17) tmp = Float64(U * U); elseif (l <= 3.8e+31) tmp = U; elseif (l <= 5.1e+259) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -6e+17) tmp = U * U; elseif (l <= 3.8e+31) tmp = U; elseif (l <= 5.1e+259) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -6e+17], N[(U * U), $MachinePrecision], If[LessEqual[l, 3.8e+31], U, If[LessEqual[l, 5.1e+259], N[(U * U), $MachinePrecision], U]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{+17}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+31}:\\
\;\;\;\;U\\
\mathbf{elif}\;\ell \leq 5.1 \cdot 10^{+259}:\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -6e17 or 3.8000000000000001e31 < l < 5.1000000000000002e259Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr18.3%
if -6e17 < l < 3.8000000000000001e31 or 5.1000000000000002e259 < l Initial program 72.9%
associate-*l*72.9%
fma-def72.9%
Simplified72.9%
Taylor expanded in J around 0 59.7%
Final simplification41.3%
(FPCore (J l K U) :precision binary64 (if (<= l -6e+17) (* U U) (if (<= l 1.4e+31) U (if (<= l 2.5e+253) (* U U) (+ U -8.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6e+17) {
tmp = U * U;
} else if (l <= 1.4e+31) {
tmp = U;
} else if (l <= 2.5e+253) {
tmp = U * U;
} else {
tmp = U + -8.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 <= (-6d+17)) then
tmp = u * u
else if (l <= 1.4d+31) then
tmp = u
else if (l <= 2.5d+253) then
tmp = u * u
else
tmp = u + (-8.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6e+17) {
tmp = U * U;
} else if (l <= 1.4e+31) {
tmp = U;
} else if (l <= 2.5e+253) {
tmp = U * U;
} else {
tmp = U + -8.0;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -6e+17: tmp = U * U elif l <= 1.4e+31: tmp = U elif l <= 2.5e+253: tmp = U * U else: tmp = U + -8.0 return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -6e+17) tmp = Float64(U * U); elseif (l <= 1.4e+31) tmp = U; elseif (l <= 2.5e+253) tmp = Float64(U * U); else tmp = Float64(U + -8.0); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -6e+17) tmp = U * U; elseif (l <= 1.4e+31) tmp = U; elseif (l <= 2.5e+253) tmp = U * U; else tmp = U + -8.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -6e+17], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.4e+31], U, If[LessEqual[l, 2.5e+253], N[(U * U), $MachinePrecision], N[(U + -8.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{+17}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+31}:\\
\;\;\;\;U\\
\mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+253}:\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U + -8\\
\end{array}
\end{array}
if l < -6e17 or 1.40000000000000008e31 < l < 2.4999999999999998e253Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr18.6%
if -6e17 < l < 1.40000000000000008e31Initial program 72.0%
associate-*l*72.0%
fma-def72.0%
Simplified72.0%
Taylor expanded in J around 0 61.8%
if 2.4999999999999998e253 < l Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr3.0%
+-commutative3.0%
Simplified3.0%
Final simplification41.3%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* l J))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
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 + (2.0d0 * (l * j))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
def code(J, l, K, U): return U + (2.0 * (l * J))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(l * J))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (l * J)); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(\ell \cdot J\right)
\end{array}
Initial program 85.0%
Taylor expanded in l around 0 66.3%
Taylor expanded in K around 0 56.1%
Final simplification56.1%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.0;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 85.0%
associate-*l*85.0%
fma-def85.0%
Simplified85.0%
Applied egg-rr2.7%
*-inverses2.7%
Simplified2.7%
Final simplification2.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 85.0%
associate-*l*85.0%
fma-def85.0%
Simplified85.0%
Taylor expanded in J around 0 34.1%
Final simplification34.1%
herbie shell --seed 2023291
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))