
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (cos (/ K 2.0))))
(if (<= t_0 -0.2)
(+ (* t_0 (* J (cos (* 0.5 K)))) U)
(if (<= t_0 0.04)
(+
U
(*
(*
J
(*
l
(+
2.0
(*
(pow l 2.0)
(+
0.3333333333333333
(*
(pow l 2.0)
(+
0.016666666666666666
(* (pow l 2.0) 0.0003968253968253968))))))))
t_1))
(+ U (* t_1 (* t_0 J)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double t_1 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.2) {
tmp = (t_0 * (J * cos((0.5 * K)))) + U;
} else if (t_0 <= 0.04) {
tmp = U + ((J * (l * (2.0 + (pow(l, 2.0) * (0.3333333333333333 + (pow(l, 2.0) * (0.016666666666666666 + (pow(l, 2.0) * 0.0003968253968253968)))))))) * t_1);
} else {
tmp = U + (t_1 * (t_0 * 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 = exp(l) - exp(-l)
t_1 = cos((k / 2.0d0))
if (t_0 <= (-0.2d0)) then
tmp = (t_0 * (j * cos((0.5d0 * k)))) + u
else if (t_0 <= 0.04d0) then
tmp = u + ((j * (l * (2.0d0 + ((l ** 2.0d0) * (0.3333333333333333d0 + ((l ** 2.0d0) * (0.016666666666666666d0 + ((l ** 2.0d0) * 0.0003968253968253968d0)))))))) * t_1)
else
tmp = u + (t_1 * (t_0 * j))
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 t_1 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.2) {
tmp = (t_0 * (J * Math.cos((0.5 * K)))) + U;
} else if (t_0 <= 0.04) {
tmp = U + ((J * (l * (2.0 + (Math.pow(l, 2.0) * (0.3333333333333333 + (Math.pow(l, 2.0) * (0.016666666666666666 + (Math.pow(l, 2.0) * 0.0003968253968253968)))))))) * t_1);
} else {
tmp = U + (t_1 * (t_0 * J));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.2: tmp = (t_0 * (J * math.cos((0.5 * K)))) + U elif t_0 <= 0.04: tmp = U + ((J * (l * (2.0 + (math.pow(l, 2.0) * (0.3333333333333333 + (math.pow(l, 2.0) * (0.016666666666666666 + (math.pow(l, 2.0) * 0.0003968253968253968)))))))) * t_1) else: tmp = U + (t_1 * (t_0 * J)) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.2) tmp = Float64(Float64(t_0 * Float64(J * cos(Float64(0.5 * K)))) + U); elseif (t_0 <= 0.04) tmp = Float64(U + Float64(Float64(J * Float64(l * Float64(2.0 + Float64((l ^ 2.0) * Float64(0.3333333333333333 + Float64((l ^ 2.0) * Float64(0.016666666666666666 + Float64((l ^ 2.0) * 0.0003968253968253968)))))))) * t_1)); else tmp = Float64(U + Float64(t_1 * Float64(t_0 * J))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.2) tmp = (t_0 * (J * cos((0.5 * K)))) + U; elseif (t_0 <= 0.04) tmp = U + ((J * (l * (2.0 + ((l ^ 2.0) * (0.3333333333333333 + ((l ^ 2.0) * (0.016666666666666666 + ((l ^ 2.0) * 0.0003968253968253968)))))))) * t_1); else tmp = U + (t_1 * (t_0 * J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], N[(N[(t$95$0 * N[(J * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.04], N[(U + N[(N[(J * N[(l * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * N[(0.3333333333333333 + N[(N[Power[l, 2.0], $MachinePrecision] * N[(0.016666666666666666 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$1 * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_0 \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right) + U\\
\mathbf{elif}\;t\_0 \leq 0.04:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(0.3333333333333333 + {\ell}^{2} \cdot \left(0.016666666666666666 + {\ell}^{2} \cdot 0.0003968253968253968\right)\right)\right)\right)\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;U + t\_1 \cdot \left(t\_0 \cdot J\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.20000000000000001Initial program 100.0%
Taylor expanded in J around 0 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
if -0.20000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0400000000000000008Initial program 68.3%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 0.0400000000000000008 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (cos (/ K 2.0))))
(if (<= t_0 -0.2)
(+ (* t_0 (* J (cos (* 0.5 K)))) U)
(if (<= t_0 0.04)
(+
U
(*
t_1
(*
J
(*
l
(+
2.0
(*
(pow l 2.0)
(+ 0.3333333333333333 (* (pow l 2.0) 0.016666666666666666))))))))
(+ U (* t_1 (* t_0 J)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double t_1 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.2) {
tmp = (t_0 * (J * cos((0.5 * K)))) + U;
} else if (t_0 <= 0.04) {
tmp = U + (t_1 * (J * (l * (2.0 + (pow(l, 2.0) * (0.3333333333333333 + (pow(l, 2.0) * 0.016666666666666666)))))));
} else {
tmp = U + (t_1 * (t_0 * 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 = exp(l) - exp(-l)
t_1 = cos((k / 2.0d0))
if (t_0 <= (-0.2d0)) then
tmp = (t_0 * (j * cos((0.5d0 * k)))) + u
else if (t_0 <= 0.04d0) then
tmp = u + (t_1 * (j * (l * (2.0d0 + ((l ** 2.0d0) * (0.3333333333333333d0 + ((l ** 2.0d0) * 0.016666666666666666d0)))))))
else
tmp = u + (t_1 * (t_0 * j))
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 t_1 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.2) {
tmp = (t_0 * (J * Math.cos((0.5 * K)))) + U;
} else if (t_0 <= 0.04) {
tmp = U + (t_1 * (J * (l * (2.0 + (Math.pow(l, 2.0) * (0.3333333333333333 + (Math.pow(l, 2.0) * 0.016666666666666666)))))));
} else {
tmp = U + (t_1 * (t_0 * J));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.2: tmp = (t_0 * (J * math.cos((0.5 * K)))) + U elif t_0 <= 0.04: tmp = U + (t_1 * (J * (l * (2.0 + (math.pow(l, 2.0) * (0.3333333333333333 + (math.pow(l, 2.0) * 0.016666666666666666))))))) else: tmp = U + (t_1 * (t_0 * J)) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.2) tmp = Float64(Float64(t_0 * Float64(J * cos(Float64(0.5 * K)))) + U); elseif (t_0 <= 0.04) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(l * Float64(2.0 + Float64((l ^ 2.0) * Float64(0.3333333333333333 + Float64((l ^ 2.0) * 0.016666666666666666)))))))); else tmp = Float64(U + Float64(t_1 * Float64(t_0 * J))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.2) tmp = (t_0 * (J * cos((0.5 * K)))) + U; elseif (t_0 <= 0.04) tmp = U + (t_1 * (J * (l * (2.0 + ((l ^ 2.0) * (0.3333333333333333 + ((l ^ 2.0) * 0.016666666666666666))))))); else tmp = U + (t_1 * (t_0 * J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], N[(N[(t$95$0 * N[(J * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.04], N[(U + N[(t$95$1 * N[(J * N[(l * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * N[(0.3333333333333333 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$1 * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_0 \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right) + U\\
\mathbf{elif}\;t\_0 \leq 0.04:\\
\;\;\;\;U + t\_1 \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(0.3333333333333333 + {\ell}^{2} \cdot 0.016666666666666666\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t\_1 \cdot \left(t\_0 \cdot J\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.20000000000000001Initial program 100.0%
Taylor expanded in J around 0 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
if -0.20000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0400000000000000008Initial program 68.3%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 0.0400000000000000008 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -0.2) (not (<= t_0 5e-16)))
(+ U (* (cos (/ K 2.0)) (* t_0 J)))
(+
U
(*
l
(*
(* J (cos (* 0.5 K)))
(+ 2.0 (* (pow l 2.0) 0.3333333333333333))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -0.2) || !(t_0 <= 5e-16)) {
tmp = U + (cos((K / 2.0)) * (t_0 * J));
} else {
tmp = U + (l * ((J * cos((0.5 * K))) * (2.0 + (pow(l, 2.0) * 0.3333333333333333))));
}
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 <= (-0.2d0)) .or. (.not. (t_0 <= 5d-16))) then
tmp = u + (cos((k / 2.0d0)) * (t_0 * j))
else
tmp = u + (l * ((j * cos((0.5d0 * k))) * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0))))
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 <= -0.2) || !(t_0 <= 5e-16)) {
tmp = U + (Math.cos((K / 2.0)) * (t_0 * J));
} else {
tmp = U + (l * ((J * Math.cos((0.5 * K))) * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -0.2) or not (t_0 <= 5e-16): tmp = U + (math.cos((K / 2.0)) * (t_0 * J)) else: tmp = U + (l * ((J * math.cos((0.5 * K))) * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333)))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -0.2) || !(t_0 <= 5e-16)) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J))); else tmp = Float64(U + Float64(l * Float64(Float64(J * cos(Float64(0.5 * K))) * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -0.2) || ~((t_0 <= 5e-16))) tmp = U + (cos((K / 2.0)) * (t_0 * J)); else tmp = U + (l * ((J * cos((0.5 * K))) * (2.0 + ((l ^ 2.0) * 0.3333333333333333)))); 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, -0.2], N[Not[LessEqual[t$95$0, 5e-16]], $MachinePrecision]], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(N[(J * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -0.2 \lor \neg \left(t\_0 \leq 5 \cdot 10^{-16}\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(t\_0 \cdot J\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.20000000000000001 or 5.0000000000000004e-16 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
if -0.20000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000004e-16Initial program 67.3%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
add-cube-cbrt99.3%
pow399.4%
Applied egg-rr99.4%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
*-commutative99.9%
associate-*l*99.9%
distribute-lft-out99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (* J (cos (* 0.5 K)))))
(if (<= t_0 -0.2)
(+ (* t_0 t_1) U)
(if (<= t_0 5e-16)
(+ U (* l (* t_1 (+ 2.0 (* (pow l 2.0) 0.3333333333333333)))))
(+ U (* (cos (/ K 2.0)) (* t_0 J)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double t_1 = J * cos((0.5 * K));
double tmp;
if (t_0 <= -0.2) {
tmp = (t_0 * t_1) + U;
} else if (t_0 <= 5e-16) {
tmp = U + (l * (t_1 * (2.0 + (pow(l, 2.0) * 0.3333333333333333))));
} else {
tmp = U + (cos((K / 2.0)) * (t_0 * 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 = exp(l) - exp(-l)
t_1 = j * cos((0.5d0 * k))
if (t_0 <= (-0.2d0)) then
tmp = (t_0 * t_1) + u
else if (t_0 <= 5d-16) then
tmp = u + (l * (t_1 * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0))))
else
tmp = u + (cos((k / 2.0d0)) * (t_0 * j))
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 t_1 = J * Math.cos((0.5 * K));
double tmp;
if (t_0 <= -0.2) {
tmp = (t_0 * t_1) + U;
} else if (t_0 <= 5e-16) {
tmp = U + (l * (t_1 * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333))));
} else {
tmp = U + (Math.cos((K / 2.0)) * (t_0 * J));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = J * math.cos((0.5 * K)) tmp = 0 if t_0 <= -0.2: tmp = (t_0 * t_1) + U elif t_0 <= 5e-16: tmp = U + (l * (t_1 * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333)))) else: tmp = U + (math.cos((K / 2.0)) * (t_0 * J)) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = Float64(J * cos(Float64(0.5 * K))) tmp = 0.0 if (t_0 <= -0.2) tmp = Float64(Float64(t_0 * t_1) + U); elseif (t_0 <= 5e-16) tmp = Float64(U + Float64(l * Float64(t_1 * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333))))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = J * cos((0.5 * K)); tmp = 0.0; if (t_0 <= -0.2) tmp = (t_0 * t_1) + U; elseif (t_0 <= 5e-16) tmp = U + (l * (t_1 * (2.0 + ((l ^ 2.0) * 0.3333333333333333)))); else tmp = U + (cos((K / 2.0)) * (t_0 * J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], N[(N[(t$95$0 * t$95$1), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 5e-16], N[(U + N[(l * N[(t$95$1 * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := J \cdot \cos \left(0.5 \cdot K\right)\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_0 \cdot t\_1 + U\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-16}:\\
\;\;\;\;U + \ell \cdot \left(t\_1 \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(t\_0 \cdot J\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.20000000000000001Initial program 100.0%
Taylor expanded in J around 0 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
if -0.20000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000004e-16Initial program 67.3%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
add-cube-cbrt99.3%
pow399.4%
Applied egg-rr99.4%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
*-commutative99.9%
associate-*l*99.9%
distribute-lft-out99.9%
*-commutative99.9%
Simplified99.9%
if 5.0000000000000004e-16 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J)))
(if (or (<= t_0 -5e-48) (not (<= t_0 2e+210)))
(+ U t_0)
(+ U (* 2.0 (* J (* l (cos (* 0.5 K)))))))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double tmp;
if ((t_0 <= -5e-48) || !(t_0 <= 2e+210)) {
tmp = U + t_0;
} else {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
}
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)) * j
if ((t_0 <= (-5d-48)) .or. (.not. (t_0 <= 2d+210))) then
tmp = u + t_0
else
tmp = u + (2.0d0 * (j * (l * cos((0.5d0 * k)))))
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)) * J;
double tmp;
if ((t_0 <= -5e-48) || !(t_0 <= 2e+210)) {
tmp = U + t_0;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = (math.exp(l) - math.exp(-l)) * J tmp = 0 if (t_0 <= -5e-48) or not (t_0 <= 2e+210): tmp = U + t_0 else: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) return tmp
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if ((t_0 <= -5e-48) || !(t_0 <= 2e+210)) tmp = Float64(U + t_0); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (exp(l) - exp(-l)) * J; tmp = 0.0; if ((t_0 <= -5e-48) || ~((t_0 <= 2e+210))) tmp = U + t_0; else tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-48], N[Not[LessEqual[t$95$0, 2e+210]], $MachinePrecision]], N[(U + t$95$0), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-48} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+210}\right):\\
\;\;\;\;U + t\_0\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -4.9999999999999999e-48 or 1.99999999999999985e210 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 99.8%
Taylor expanded in K around 0 78.7%
if -4.9999999999999999e-48 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 1.99999999999999985e210Initial program 68.5%
Taylor expanded in l around 0 99.4%
Final simplification88.7%
(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)))))
(if (<= l -3.4e+24)
t_0
(if (<= l -175.0)
(+ U (* t_1 J))
(if (<= l 0.18)
(+ U (* 2.0 (* J (* l (cos (* 0.5 K))))))
(if (<= l 5.6e+43) (+ U (* t_1 -0.5)) 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);
double tmp;
if (l <= -3.4e+24) {
tmp = t_0;
} else if (l <= -175.0) {
tmp = U + (t_1 * J);
} else if (l <= 0.18) {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
} else if (l <= 5.6e+43) {
tmp = U + (t_1 * -0.5);
} 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)
if (l <= (-3.4d+24)) then
tmp = t_0
else if (l <= (-175.0d0)) then
tmp = u + (t_1 * j)
else if (l <= 0.18d0) then
tmp = u + (2.0d0 * (j * (l * cos((0.5d0 * k)))))
else if (l <= 5.6d+43) then
tmp = u + (t_1 * (-0.5d0))
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);
double tmp;
if (l <= -3.4e+24) {
tmp = t_0;
} else if (l <= -175.0) {
tmp = U + (t_1 * J);
} else if (l <= 0.18) {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
} else if (l <= 5.6e+43) {
tmp = U + (t_1 * -0.5);
} 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) tmp = 0 if l <= -3.4e+24: tmp = t_0 elif l <= -175.0: tmp = U + (t_1 * J) elif l <= 0.18: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) elif l <= 5.6e+43: tmp = U + (t_1 * -0.5) 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(exp(l) - exp(Float64(-l))) tmp = 0.0 if (l <= -3.4e+24) tmp = t_0; elseif (l <= -175.0) tmp = Float64(U + Float64(t_1 * J)); elseif (l <= 0.18) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); elseif (l <= 5.6e+43) tmp = Float64(U + Float64(t_1 * -0.5)); 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); tmp = 0.0; if (l <= -3.4e+24) tmp = t_0; elseif (l <= -175.0) tmp = U + (t_1 * J); elseif (l <= 0.18) tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); elseif (l <= 5.6e+43) tmp = U + (t_1 * -0.5); 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[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.4e+24], t$95$0, If[LessEqual[l, -175.0], N[(U + N[(t$95$1 * J), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.18], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.6e+43], N[(U + N[(t$95$1 * -0.5), $MachinePrecision]), $MachinePrecision], 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 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;\ell \leq -3.4 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -175:\\
\;\;\;\;U + t\_1 \cdot J\\
\mathbf{elif}\;\ell \leq 0.18:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+43}:\\
\;\;\;\;U + t\_1 \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -3.4000000000000001e24 or 5.60000000000000038e43 < l Initial program 100.0%
Taylor expanded in l around 0 98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in l around inf 98.4%
*-commutative98.4%
*-commutative98.4%
associate-*r*98.4%
Simplified98.4%
if -3.4000000000000001e24 < l < -175Initial program 100.0%
Taylor expanded in K around 0 100.0%
if -175 < l < 0.17999999999999999Initial program 68.8%
Taylor expanded in l around 0 98.7%
if 0.17999999999999999 < l < 5.60000000000000038e43Initial program 100.0%
Taylor expanded in J around 0 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr87.5%
Final simplification98.2%
(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)))))
(if (<= l -3.4e+24)
t_0
(if (<= l -175.0)
(+ U (* t_1 J))
(if (<= l 0.18)
(+
U
(*
l
(*
(* J (cos (* 0.5 K)))
(+ 2.0 (* (pow l 2.0) 0.3333333333333333)))))
(if (<= l 1.14e+42) (+ U (* t_1 -0.5)) 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);
double tmp;
if (l <= -3.4e+24) {
tmp = t_0;
} else if (l <= -175.0) {
tmp = U + (t_1 * J);
} else if (l <= 0.18) {
tmp = U + (l * ((J * cos((0.5 * K))) * (2.0 + (pow(l, 2.0) * 0.3333333333333333))));
} else if (l <= 1.14e+42) {
tmp = U + (t_1 * -0.5);
} 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)
if (l <= (-3.4d+24)) then
tmp = t_0
else if (l <= (-175.0d0)) then
tmp = u + (t_1 * j)
else if (l <= 0.18d0) then
tmp = u + (l * ((j * cos((0.5d0 * k))) * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0))))
else if (l <= 1.14d+42) then
tmp = u + (t_1 * (-0.5d0))
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);
double tmp;
if (l <= -3.4e+24) {
tmp = t_0;
} else if (l <= -175.0) {
tmp = U + (t_1 * J);
} else if (l <= 0.18) {
tmp = U + (l * ((J * Math.cos((0.5 * K))) * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333))));
} else if (l <= 1.14e+42) {
tmp = U + (t_1 * -0.5);
} 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) tmp = 0 if l <= -3.4e+24: tmp = t_0 elif l <= -175.0: tmp = U + (t_1 * J) elif l <= 0.18: tmp = U + (l * ((J * math.cos((0.5 * K))) * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333)))) elif l <= 1.14e+42: tmp = U + (t_1 * -0.5) 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(exp(l) - exp(Float64(-l))) tmp = 0.0 if (l <= -3.4e+24) tmp = t_0; elseif (l <= -175.0) tmp = Float64(U + Float64(t_1 * J)); elseif (l <= 0.18) tmp = Float64(U + Float64(l * Float64(Float64(J * cos(Float64(0.5 * K))) * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333))))); elseif (l <= 1.14e+42) tmp = Float64(U + Float64(t_1 * -0.5)); 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); tmp = 0.0; if (l <= -3.4e+24) tmp = t_0; elseif (l <= -175.0) tmp = U + (t_1 * J); elseif (l <= 0.18) tmp = U + (l * ((J * cos((0.5 * K))) * (2.0 + ((l ^ 2.0) * 0.3333333333333333)))); elseif (l <= 1.14e+42) tmp = U + (t_1 * -0.5); 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[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.4e+24], t$95$0, If[LessEqual[l, -175.0], N[(U + N[(t$95$1 * J), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.18], N[(U + N[(l * N[(N[(J * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.14e+42], N[(U + N[(t$95$1 * -0.5), $MachinePrecision]), $MachinePrecision], 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 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;\ell \leq -3.4 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -175:\\
\;\;\;\;U + t\_1 \cdot J\\
\mathbf{elif}\;\ell \leq 0.18:\\
\;\;\;\;U + \ell \cdot \left(\left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\\
\mathbf{elif}\;\ell \leq 1.14 \cdot 10^{+42}:\\
\;\;\;\;U + t\_1 \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -3.4000000000000001e24 or 1.14000000000000004e42 < l Initial program 100.0%
Taylor expanded in l around 0 98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in l around inf 98.4%
*-commutative98.4%
*-commutative98.4%
associate-*r*98.4%
Simplified98.4%
if -3.4000000000000001e24 < l < -175Initial program 100.0%
Taylor expanded in K around 0 100.0%
if -175 < l < 0.17999999999999999Initial program 68.8%
Taylor expanded in l around 0 99.8%
*-commutative99.8%
Simplified99.8%
add-cube-cbrt99.2%
pow399.3%
Applied egg-rr99.3%
Taylor expanded in l around 0 99.3%
+-commutative99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
associate-*l*99.3%
*-commutative99.3%
associate-*l*99.3%
distribute-lft-out99.3%
*-commutative99.3%
Simplified99.3%
if 0.17999999999999999 < l < 1.14000000000000004e42Initial program 100.0%
Taylor expanded in J around 0 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr87.5%
Final simplification98.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.19) (+ U (* 2.0 (* J (* l (cos (* 0.5 K)))))) (+ U (* J (* l (+ 2.0 (* (pow l 2.0) 0.3333333333333333)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.19) {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
} else {
tmp = U + (J * (l * (2.0 + (pow(l, 2.0) * 0.3333333333333333))));
}
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.19d0) then
tmp = u + (2.0d0 * (j * (l * cos((0.5d0 * k)))))
else
tmp = u + (j * (l * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0))))
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.19) {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
} else {
tmp = U + (J * (l * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.19: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) else: tmp = U + (J * (l * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.19) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.19) tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); else tmp = U + (J * (l * (2.0 + ((l ^ 2.0) * 0.3333333333333333)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.19], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.19:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.19Initial program 81.5%
Taylor expanded in l around 0 63.2%
if 0.19 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.7%
Taylor expanded in K around 0 85.3%
Taylor expanded in l around 0 83.0%
Final simplification78.5%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* 0.5 K)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * cos((0.5 * K)))));
}
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((0.5d0 * k)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((0.5 * K)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)
\end{array}
Initial program 84.7%
Taylor expanded in l around 0 63.4%
Final simplification63.4%
(FPCore (J l K U) :precision binary64 (if (or (<= l -145000.0) (not (<= l 9e+30))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -145000.0) || !(l <= 9e+30)) {
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 <= (-145000.0d0)) .or. (.not. (l <= 9d+30))) 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 <= -145000.0) || !(l <= 9e+30)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -145000.0) or not (l <= 9e+30): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -145000.0) || !(l <= 9e+30)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -145000.0) || ~((l <= 9e+30))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -145000.0], N[Not[LessEqual[l, 9e+30]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -145000 \lor \neg \left(\ell \leq 9 \cdot 10^{+30}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -145000 or 8.9999999999999999e30 < l Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Applied egg-rr13.7%
if -145000 < l < 8.9999999999999999e30Initial program 70.2%
associate-*l*70.2%
fma-define70.2%
Simplified70.2%
Taylor expanded in J around 0 63.9%
Final simplification39.4%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l 2.0))))
double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (j * (l * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
def code(J, l, K, U): return U + (J * (l * 2.0))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot 2\right)
\end{array}
Initial program 84.7%
Taylor expanded in K around 0 73.5%
Taylor expanded in l around 0 53.8%
Final simplification53.8%
(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 84.7%
associate-*l*84.8%
fma-define84.8%
Simplified84.8%
Applied egg-rr2.5%
*-inverses2.5%
Simplified2.5%
Final simplification2.5%
(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 84.7%
associate-*l*84.8%
fma-define84.8%
Simplified84.8%
Taylor expanded in J around 0 33.7%
Final simplification33.7%
herbie shell --seed 2024112
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))