
(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 (or (<= t_1 -1.0) (not (<= t_1 0.1)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(+
(* 0.0003968253968253968 (pow l 7.0))
(+
(* 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 <= -1.0) || !(t_1 <= 0.1)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.0003968253968253968 * pow(l, 7.0)) + ((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 <= (-1.0d0)) .or. (.not. (t_1 <= 0.1d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (j * ((0.0003968253968253968d0 * (l ** 7.0d0)) + ((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 <= -1.0) || !(t_1 <= 0.1)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.0003968253968253968 * Math.pow(l, 7.0)) + ((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 <= -1.0) or not (t_1 <= 0.1): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * ((0.0003968253968253968 * math.pow(l, 7.0)) + ((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 <= -1.0) || !(t_1 <= 0.1)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.0003968253968253968 * (l ^ 7.0)) + 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 <= -1.0) || ~((t_1 <= 0.1))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * ((0.0003968253968253968 * (l ^ 7.0)) + ((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, -1.0], N[Not[LessEqual[t$95$1, 0.1]], $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.0003968253968253968 * N[Power[l, 7.0], $MachinePrecision]), $MachinePrecision] + 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]), $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 -1 \lor \neg \left(t\_1 \leq 0.1\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -1 or 0.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -1 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.10000000000000001Initial program 68.7%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -1.0) (not (<= t_1 2e-6)))
(+ (* (* t_1 J) t_0) U)
(+
U
(* t_0 (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J))))))))
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 <= -1.0) || !(t_1 <= 2e-6)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((0.3333333333333333 * (J * pow(l, 3.0))) + (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-1.0d0)) .or. (.not. (t_1 <= 2d-6))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (2.0d0 * (l * j))))
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 <= -1.0) || !(t_1 <= 2e-6)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J))));
}
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 <= -1.0) or not (t_1 <= 2e-6): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J)))) 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 <= -1.0) || !(t_1 <= 2e-6)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J))))); 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 <= -1.0) || ~((t_1 <= 2e-6))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J)))); 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, -1.0], N[Not[LessEqual[t$95$1, 2e-6]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $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 -1 \lor \neg \left(t\_1 \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -1 or 1.99999999999999991e-6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
if -1 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1.99999999999999991e-6Initial program 68.0%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -1.0) (not (<= t_0 2e-6)))
(+ (* t_0 J) U)
(+ U (* (* l 2.0) (* J (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -1.0) || !(t_0 <= 2e-6)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + ((l * 2.0) * (J * 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) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-1.0d0)) .or. (.not. (t_0 <= 2d-6))) then
tmp = (t_0 * j) + u
else
tmp = u + ((l * 2.0d0) * (j * cos((k * 0.5d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -1.0) || !(t_0 <= 2e-6)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -1.0) or not (t_0 <= 2e-6): tmp = (t_0 * J) + U else: tmp = U + ((l * 2.0) * (J * math.cos((K * 0.5)))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -1.0) || !(t_0 <= 2e-6)) tmp = Float64(Float64(t_0 * J) + U); else tmp = Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -1.0) || ~((t_0 <= 2e-6))) tmp = (t_0 * J) + U; else tmp = U + ((l * 2.0) * (J * cos((K * 0.5)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1.0], N[Not[LessEqual[t$95$0, 2e-6]], $MachinePrecision]], N[(N[(t$95$0 * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -1 \lor \neg \left(t\_0 \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;t\_0 \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -1 or 1.99999999999999991e-6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
Taylor expanded in K around 0 77.0%
if -1 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1.99999999999999991e-6Initial program 68.0%
Taylor expanded in l around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
associate-*r*99.8%
Simplified99.8%
Final simplification87.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* (* l 2.0) (* J (cos (* K 0.5)))))))
(if (<= t_0 -0.7)
t_1
(if (<= t_0 -0.16)
(+ U (+ (* 2.0 (* l J)) (* -0.25 (* J (* l (pow K 2.0))))))
(if (<= t_0 0.355)
t_1
(+ 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 t_1 = U + ((l * 2.0) * (J * cos((K * 0.5))));
double tmp;
if (t_0 <= -0.7) {
tmp = t_1;
} else if (t_0 <= -0.16) {
tmp = U + ((2.0 * (l * J)) + (-0.25 * (J * (l * pow(K, 2.0)))));
} else if (t_0 <= 0.355) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u + ((l * 2.0d0) * (j * cos((k * 0.5d0))))
if (t_0 <= (-0.7d0)) then
tmp = t_1
else if (t_0 <= (-0.16d0)) then
tmp = u + ((2.0d0 * (l * j)) + ((-0.25d0) * (j * (l * (k ** 2.0d0)))))
else if (t_0 <= 0.355d0) then
tmp = t_1
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 t_1 = U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
double tmp;
if (t_0 <= -0.7) {
tmp = t_1;
} else if (t_0 <= -0.16) {
tmp = U + ((2.0 * (l * J)) + (-0.25 * (J * (l * Math.pow(K, 2.0)))));
} else if (t_0 <= 0.355) {
tmp = t_1;
} 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)) t_1 = U + ((l * 2.0) * (J * math.cos((K * 0.5)))) tmp = 0 if t_0 <= -0.7: tmp = t_1 elif t_0 <= -0.16: tmp = U + ((2.0 * (l * J)) + (-0.25 * (J * (l * math.pow(K, 2.0))))) elif t_0 <= 0.355: tmp = t_1 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)) t_1 = Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))) tmp = 0.0 if (t_0 <= -0.7) tmp = t_1; elseif (t_0 <= -0.16) tmp = Float64(U + Float64(Float64(2.0 * Float64(l * J)) + Float64(-0.25 * Float64(J * Float64(l * (K ^ 2.0)))))); elseif (t_0 <= 0.355) tmp = t_1; 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)); t_1 = U + ((l * 2.0) * (J * cos((K * 0.5)))); tmp = 0.0; if (t_0 <= -0.7) tmp = t_1; elseif (t_0 <= -0.16) tmp = U + ((2.0 * (l * J)) + (-0.25 * (J * (l * (K ^ 2.0))))); elseif (t_0 <= 0.355) tmp = t_1; 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]}, Block[{t$95$1 = N[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.7], t$95$1, If[LessEqual[t$95$0, -0.16], N[(U + N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.355], t$95$1, 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)\\
t_1 := U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;t\_0 \leq -0.7:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -0.16:\\
\;\;\;\;U + \left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left(J \cdot \left(\ell \cdot {K}^{2}\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.355:\\
\;\;\;\;t\_1\\
\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.69999999999999996 or -0.160000000000000003 < (cos.f64 (/.f64 K 2)) < 0.35499999999999998Initial program 81.4%
Taylor expanded in l around 0 72.3%
associate-*r*72.3%
*-commutative72.3%
associate-*l*72.4%
associate-*r*72.4%
Simplified72.4%
if -0.69999999999999996 < (cos.f64 (/.f64 K 2)) < -0.160000000000000003Initial program 94.5%
Taylor expanded in l around 0 29.2%
Taylor expanded in K around 0 78.6%
if 0.35499999999999998 < (cos.f64 (/.f64 K 2)) Initial program 85.4%
Taylor expanded in K around 0 85.4%
Taylor expanded in l around 0 79.8%
Final simplification77.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 7.0) (* J 0.0003968253968253968)))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -1.65e+43)
t_1
(if (<= l -0.2)
t_2
(if (<= l 5.3e-5)
(+
U
(* t_0 (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J)))))
(if (<= l 3e+32) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + (t_0 * (pow(l, 7.0) * (J * 0.0003968253968253968)));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -1.65e+43) {
tmp = t_1;
} else if (l <= -0.2) {
tmp = t_2;
} else if (l <= 5.3e-5) {
tmp = U + (t_0 * ((0.3333333333333333 * (J * pow(l, 3.0))) + (2.0 * (l * J))));
} else if (l <= 3e+32) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u + (t_0 * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-1.65d+43)) then
tmp = t_1
else if (l <= (-0.2d0)) then
tmp = t_2
else if (l <= 5.3d-5) then
tmp = u + (t_0 * ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (2.0d0 * (l * j))))
else if (l <= 3d+32) then
tmp = t_2
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 / 2.0));
double t_1 = U + (t_0 * (Math.pow(l, 7.0) * (J * 0.0003968253968253968)));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -1.65e+43) {
tmp = t_1;
} else if (l <= -0.2) {
tmp = t_2;
} else if (l <= 5.3e-5) {
tmp = U + (t_0 * ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J))));
} else if (l <= 3e+32) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + (t_0 * (math.pow(l, 7.0) * (J * 0.0003968253968253968))) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -1.65e+43: tmp = t_1 elif l <= -0.2: tmp = t_2 elif l <= 5.3e-5: tmp = U + (t_0 * ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J)))) elif l <= 3e+32: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(t_0 * Float64((l ^ 7.0) * Float64(J * 0.0003968253968253968)))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -1.65e+43) tmp = t_1; elseif (l <= -0.2) tmp = t_2; elseif (l <= 5.3e-5) tmp = Float64(U + Float64(t_0 * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J))))); elseif (l <= 3e+32) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = U + (t_0 * ((l ^ 7.0) * (J * 0.0003968253968253968))); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -1.65e+43) tmp = t_1; elseif (l <= -0.2) tmp = t_2; elseif (l <= 5.3e-5) tmp = U + (t_0 * ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J)))); elseif (l <= 3e+32) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(t$95$0 * N[(N[Power[l, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -1.65e+43], t$95$1, If[LessEqual[l, -0.2], t$95$2, If[LessEqual[l, 5.3e-5], N[(U + N[(t$95$0 * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3e+32], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + t\_0 \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -1.65 \cdot 10^{+43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -0.2:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 5.3 \cdot 10^{-5}:\\
\;\;\;\;U + t\_0 \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\mathbf{elif}\;\ell \leq 3 \cdot 10^{+32}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -1.6500000000000001e43 or 3e32 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -1.6500000000000001e43 < l < -0.20000000000000001 or 5.3000000000000001e-5 < l < 3e32Initial program 99.7%
Taylor expanded in K around 0 94.7%
if -0.20000000000000001 < l < 5.3000000000000001e-5Initial program 68.0%
Taylor expanded in l around 0 99.9%
Final simplification99.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (cos (/ K 2.0)) (* (pow l 7.0) (* J 0.0003968253968253968)))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -1.65e+43)
t_0
(if (<= l -0.00325)
t_1
(if (<= l 5.3e-5)
(+ U (* (* l 2.0) (* J (cos (* K 0.5)))))
(if (<= l 3e+32) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (pow(l, 7.0) * (J * 0.0003968253968253968)));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -1.65e+43) {
tmp = t_0;
} else if (l <= -0.00325) {
tmp = t_1;
} else if (l <= 5.3e-5) {
tmp = U + ((l * 2.0) * (J * cos((K * 0.5))));
} else if (l <= 3e+32) {
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 + (cos((k / 2.0d0)) * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-1.65d+43)) then
tmp = t_0
else if (l <= (-0.00325d0)) then
tmp = t_1
else if (l <= 5.3d-5) then
tmp = u + ((l * 2.0d0) * (j * cos((k * 0.5d0))))
else if (l <= 3d+32) 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 + (Math.cos((K / 2.0)) * (Math.pow(l, 7.0) * (J * 0.0003968253968253968)));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -1.65e+43) {
tmp = t_0;
} else if (l <= -0.00325) {
tmp = t_1;
} else if (l <= 5.3e-5) {
tmp = U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
} else if (l <= 3e+32) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.cos((K / 2.0)) * (math.pow(l, 7.0) * (J * 0.0003968253968253968))) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -1.65e+43: tmp = t_0 elif l <= -0.00325: tmp = t_1 elif l <= 5.3e-5: tmp = U + ((l * 2.0) * (J * math.cos((K * 0.5)))) elif l <= 3e+32: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64((l ^ 7.0) * Float64(J * 0.0003968253968253968)))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -1.65e+43) tmp = t_0; elseif (l <= -0.00325) tmp = t_1; elseif (l <= 5.3e-5) tmp = Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))); elseif (l <= 3e+32) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (cos((K / 2.0)) * ((l ^ 7.0) * (J * 0.0003968253968253968))); t_1 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -1.65e+43) tmp = t_0; elseif (l <= -0.00325) tmp = t_1; elseif (l <= 5.3e-5) tmp = U + ((l * 2.0) * (J * cos((K * 0.5)))); elseif (l <= 3e+32) tmp = t_1; 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[(N[Power[l, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -1.65e+43], t$95$0, If[LessEqual[l, -0.00325], t$95$1, If[LessEqual[l, 5.3e-5], N[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3e+32], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -1.65 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -0.00325:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq 5.3 \cdot 10^{-5}:\\
\;\;\;\;U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;\ell \leq 3 \cdot 10^{+32}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -1.6500000000000001e43 or 3e32 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -1.6500000000000001e43 < l < -0.00324999999999999985 or 5.3000000000000001e-5 < l < 3e32Initial program 99.7%
Taylor expanded in K around 0 94.7%
if -0.00324999999999999985 < l < 5.3000000000000001e-5Initial program 68.0%
Taylor expanded in l around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
associate-*r*99.8%
Simplified99.8%
Final simplification99.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 7.0) (* J 0.0003968253968253968)))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -1.65e+43)
t_1
(if (<= l -0.27)
t_2
(if (<= l 5.3e-5)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 3e+32) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + (t_0 * (pow(l, 7.0) * (J * 0.0003968253968253968)));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -1.65e+43) {
tmp = t_1;
} else if (l <= -0.27) {
tmp = t_2;
} else if (l <= 5.3e-5) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 3e+32) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u + (t_0 * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-1.65d+43)) then
tmp = t_1
else if (l <= (-0.27d0)) then
tmp = t_2
else if (l <= 5.3d-5) then
tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 3d+32) then
tmp = t_2
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 / 2.0));
double t_1 = U + (t_0 * (Math.pow(l, 7.0) * (J * 0.0003968253968253968)));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -1.65e+43) {
tmp = t_1;
} else if (l <= -0.27) {
tmp = t_2;
} else if (l <= 5.3e-5) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 3e+32) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + (t_0 * (math.pow(l, 7.0) * (J * 0.0003968253968253968))) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -1.65e+43: tmp = t_1 elif l <= -0.27: tmp = t_2 elif l <= 5.3e-5: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 3e+32: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(t_0 * Float64((l ^ 7.0) * Float64(J * 0.0003968253968253968)))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -1.65e+43) tmp = t_1; elseif (l <= -0.27) tmp = t_2; elseif (l <= 5.3e-5) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 3e+32) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = U + (t_0 * ((l ^ 7.0) * (J * 0.0003968253968253968))); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -1.65e+43) tmp = t_1; elseif (l <= -0.27) tmp = t_2; elseif (l <= 5.3e-5) tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 3e+32) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(t$95$0 * N[(N[Power[l, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -1.65e+43], t$95$1, If[LessEqual[l, -0.27], t$95$2, If[LessEqual[l, 5.3e-5], 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], If[LessEqual[l, 3e+32], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + t\_0 \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -1.65 \cdot 10^{+43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -0.27:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 5.3 \cdot 10^{-5}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 3 \cdot 10^{+32}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -1.6500000000000001e43 or 3e32 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -1.6500000000000001e43 < l < -0.27000000000000002 or 5.3000000000000001e-5 < l < 3e32Initial program 99.7%
Taylor expanded in K around 0 94.7%
if -0.27000000000000002 < l < 5.3000000000000001e-5Initial program 68.0%
Taylor expanded in l around 0 99.9%
Final simplification99.4%
(FPCore (J l K U) :precision binary64 (if (<= (/ K 2.0) 40000.0) (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))) (+ U (* (* l 2.0) (* J (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 40000.0) {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
} else {
tmp = U + ((l * 2.0) * (J * cos((K * 0.5))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((k / 2.0d0) <= 40000.0d0) then
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))
else
tmp = u + ((l * 2.0d0) * (j * cos((k * 0.5d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 40000.0) {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
} else {
tmp = U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 40000.0: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) else: tmp = U + ((l * 2.0) * (J * math.cos((K * 0.5)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 40000.0) tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))); else tmp = Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((K / 2.0) <= 40000.0) tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))); else tmp = U + ((l * 2.0) * (J * cos((K * 0.5)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 40000.0], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 40000:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (/.f64 K 2) < 4e4Initial program 85.3%
Taylor expanded in K around 0 77.9%
Taylor expanded in l around 0 73.7%
if 4e4 < (/.f64 K 2) Initial program 84.3%
Taylor expanded in l around 0 66.3%
associate-*r*66.3%
*-commutative66.3%
associate-*l*66.4%
associate-*r*66.4%
Simplified66.4%
Final simplification72.1%
(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.1%
Taylor expanded in l around 0 64.1%
Final simplification64.1%
(FPCore (J l K U) :precision binary64 (+ U (* (* l 2.0) (* J (cos (* K 0.5))))))
double code(double J, double l, double K, double U) {
return U + ((l * 2.0) * (J * 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 + ((l * 2.0d0) * (j * cos((k * 0.5d0))))
end function
public static double code(double J, double l, double K, double U) {
return U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
}
def code(J, l, K, U): return U + ((l * 2.0) * (J * math.cos((K * 0.5))))
function code(J, l, K, U) return Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))) end
function tmp = code(J, l, K, U) tmp = U + ((l * 2.0) * (J * cos((K * 0.5)))); end
code[J_, l_, K_, U_] := N[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0 64.1%
associate-*r*64.1%
*-commutative64.1%
associate-*l*64.1%
associate-*r*64.1%
Simplified64.1%
Final simplification64.1%
(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.1%
Taylor expanded in l around 0 64.1%
Taylor expanded in K around 0 53.9%
+-commutative53.9%
Simplified53.9%
Final simplification53.9%
(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.1%
Applied egg-rr26.3%
Taylor expanded in J around 0 33.9%
Final simplification33.9%
herbie shell --seed 2024043
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))