
(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 (cos (/ K 2.0))) (t_1 (exp (- l))) (t_2 (- (exp l) t_1)))
(if (<= t_2 (- INFINITY))
(+ (* (* J (- 27.0 t_1)) t_0) U)
(if (<= t_2 5e-16)
(+
U
(*
t_0
(*
l
(+
(* J 2.0)
(*
(pow l 2.0)
(+
(* J 0.3333333333333333)
(*
(pow l 2.0)
(+
(* 0.0003968253968253968 (* J (pow l 2.0)))
(* J 0.016666666666666666)))))))))
(+ U (* t_0 (* t_2 J)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(-l);
double t_2 = exp(l) - t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (t_2 <= 5e-16) {
tmp = U + (t_0 * (l * ((J * 2.0) + (pow(l, 2.0) * ((J * 0.3333333333333333) + (pow(l, 2.0) * ((0.0003968253968253968 * (J * pow(l, 2.0))) + (J * 0.016666666666666666))))))));
} else {
tmp = U + (t_0 * (t_2 * J));
}
return tmp;
}
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);
double t_2 = Math.exp(l) - t_1;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (t_2 <= 5e-16) {
tmp = U + (t_0 * (l * ((J * 2.0) + (Math.pow(l, 2.0) * ((J * 0.3333333333333333) + (Math.pow(l, 2.0) * ((0.0003968253968253968 * (J * Math.pow(l, 2.0))) + (J * 0.016666666666666666))))))));
} else {
tmp = U + (t_0 * (t_2 * J));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(-l) t_2 = math.exp(l) - t_1 tmp = 0 if t_2 <= -math.inf: tmp = ((J * (27.0 - t_1)) * t_0) + U elif t_2 <= 5e-16: tmp = U + (t_0 * (l * ((J * 2.0) + (math.pow(l, 2.0) * ((J * 0.3333333333333333) + (math.pow(l, 2.0) * ((0.0003968253968253968 * (J * math.pow(l, 2.0))) + (J * 0.016666666666666666)))))))) else: tmp = U + (t_0 * (t_2 * J)) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = exp(Float64(-l)) t_2 = Float64(exp(l) - t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(Float64(J * Float64(27.0 - t_1)) * t_0) + U); elseif (t_2 <= 5e-16) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(Float64(J * 2.0) + Float64((l ^ 2.0) * Float64(Float64(J * 0.3333333333333333) + Float64((l ^ 2.0) * Float64(Float64(0.0003968253968253968 * Float64(J * (l ^ 2.0))) + Float64(J * 0.016666666666666666))))))))); else tmp = Float64(U + Float64(t_0 * Float64(t_2 * J))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(-l); t_2 = exp(l) - t_1; tmp = 0.0; if (t_2 <= -Inf) tmp = ((J * (27.0 - t_1)) * t_0) + U; elseif (t_2 <= 5e-16) tmp = U + (t_0 * (l * ((J * 2.0) + ((l ^ 2.0) * ((J * 0.3333333333333333) + ((l ^ 2.0) * ((0.0003968253968253968 * (J * (l ^ 2.0))) + (J * 0.016666666666666666)))))))); else tmp = U + (t_0 * (t_2 * 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[Exp[(-l)], $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[l], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(J * N[(27.0 - t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$2, 5e-16], N[(U + N[(t$95$0 * N[(l * N[(N[(J * 2.0), $MachinePrecision] + N[(N[Power[l, 2.0], $MachinePrecision] * N[(N[(J * 0.3333333333333333), $MachinePrecision] + N[(N[Power[l, 2.0], $MachinePrecision] * N[(N[(0.0003968253968253968 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(t$95$2 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{-\ell}\\
t_2 := e^{\ell} - t\_1\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\left(J \cdot \left(27 - t\_1\right)\right) \cdot t\_0 + U\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-16}:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(J \cdot 2 + {\ell}^{2} \cdot \left(J \cdot 0.3333333333333333 + {\ell}^{2} \cdot \left(0.0003968253968253968 \cdot \left(J \cdot {\ell}^{2}\right) + J \cdot 0.016666666666666666\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(t\_2 \cdot J\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0Initial program 100.0%
Applied egg-rr100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000004e-16Initial program 74.9%
Taylor expanded in l around 0 99.9%
if 5.0000000000000004e-16 < (-.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 (cos (/ K 2.0))) (t_1 (exp (- l))) (t_2 (- (exp l) t_1)))
(if (<= t_2 (- INFINITY))
(+ (* (* J (- 27.0 t_1)) t_0) U)
(if (<= t_2 5e-16)
(+
U
(*
t_0
(*
J
(*
l
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* 0.016666666666666666 (* l l)))))))))
(+ U (* t_0 (* t_2 J)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(-l);
double t_2 = exp(l) - t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (t_2 <= 5e-16) {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
} else {
tmp = U + (t_0 * (t_2 * J));
}
return tmp;
}
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);
double t_2 = Math.exp(l) - t_1;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (t_2 <= 5e-16) {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
} else {
tmp = U + (t_0 * (t_2 * J));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(-l) t_2 = math.exp(l) - t_1 tmp = 0 if t_2 <= -math.inf: tmp = ((J * (27.0 - t_1)) * t_0) + U elif t_2 <= 5e-16: tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))) else: tmp = U + (t_0 * (t_2 * J)) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = exp(Float64(-l)) t_2 = Float64(exp(l) - t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(Float64(J * Float64(27.0 - t_1)) * t_0) + U); elseif (t_2 <= 5e-16) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l))))))))); else tmp = Float64(U + Float64(t_0 * Float64(t_2 * J))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(-l); t_2 = exp(l) - t_1; tmp = 0.0; if (t_2 <= -Inf) tmp = ((J * (27.0 - t_1)) * t_0) + U; elseif (t_2 <= 5e-16) tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))); else tmp = U + (t_0 * (t_2 * 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[Exp[(-l)], $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[l], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(J * N[(27.0 - t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$2, 5e-16], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(t$95$2 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{-\ell}\\
t_2 := e^{\ell} - t\_1\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\left(J \cdot \left(27 - t\_1\right)\right) \cdot t\_0 + U\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-16}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(t\_2 \cdot J\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0Initial program 100.0%
Applied egg-rr100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000004e-16Initial program 74.9%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
unpow299.9%
Applied egg-rr99.9%
unpow299.9%
Applied egg-rr99.9%
if 5.0000000000000004e-16 < (-.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 (cos (/ K 2.0))) (t_1 (exp (- l))))
(if (<= l -250.0)
(+ (* (* J (- 27.0 t_1)) t_0) U)
(if (or (<= l 2.2e+16) (not (<= l 1.25e+47)))
(+
U
(*
t_0
(*
J
(*
l
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* 0.016666666666666666 (* l l)))))))))
(+ U (* (- (exp l) t_1) J))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(-l);
double tmp;
if (l <= -250.0) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if ((l <= 2.2e+16) || !(l <= 1.25e+47)) {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
} else {
tmp = U + ((exp(l) - t_1) * 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)
if (l <= (-250.0d0)) then
tmp = ((j * (27.0d0 - t_1)) * t_0) + u
else if ((l <= 2.2d+16) .or. (.not. (l <= 1.25d+47))) then
tmp = u + (t_0 * (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (0.016666666666666666d0 * (l * l))))))))
else
tmp = u + ((exp(l) - t_1) * 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);
double tmp;
if (l <= -250.0) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if ((l <= 2.2e+16) || !(l <= 1.25e+47)) {
tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
} else {
tmp = U + ((Math.exp(l) - t_1) * J);
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(-l) tmp = 0 if l <= -250.0: tmp = ((J * (27.0 - t_1)) * t_0) + U elif (l <= 2.2e+16) or not (l <= 1.25e+47): tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))) else: tmp = U + ((math.exp(l) - t_1) * J) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = exp(Float64(-l)) tmp = 0.0 if (l <= -250.0) tmp = Float64(Float64(Float64(J * Float64(27.0 - t_1)) * t_0) + U); elseif ((l <= 2.2e+16) || !(l <= 1.25e+47)) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l))))))))); else tmp = Float64(U + Float64(Float64(exp(l) - t_1) * J)); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(-l); tmp = 0.0; if (l <= -250.0) tmp = ((J * (27.0 - t_1)) * t_0) + U; elseif ((l <= 2.2e+16) || ~((l <= 1.25e+47))) tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))); else tmp = U + ((exp(l) - t_1) * 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[Exp[(-l)], $MachinePrecision]}, If[LessEqual[l, -250.0], N[(N[(N[(J * N[(27.0 - t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[Or[LessEqual[l, 2.2e+16], N[Not[LessEqual[l, 1.25e+47]], $MachinePrecision]], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - t$95$1), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -250:\\
\;\;\;\;\left(J \cdot \left(27 - t\_1\right)\right) \cdot t\_0 + U\\
\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{+16} \lor \neg \left(\ell \leq 1.25 \cdot 10^{+47}\right):\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(e^{\ell} - t\_1\right) \cdot J\\
\end{array}
\end{array}
if l < -250Initial program 100.0%
Applied egg-rr100.0%
if -250 < l < 2.2e16 or 1.25000000000000005e47 < l Initial program 83.2%
Taylor expanded in l around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.2%
Applied egg-rr98.2%
unpow298.2%
Applied egg-rr98.2%
if 2.2e16 < l < 1.25000000000000005e47Initial program 100.0%
Taylor expanded in K around 0 90.9%
Final simplification98.4%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.02)
(* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U)))))
(+
U
(*
J
(*
l
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* 0.016666666666666666 (* l l))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U))));
} else {
tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
}
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.02d0)) then
tmp = u * (1.0d0 + (2.0d0 * (j * ((l * cos((k * 0.5d0))) / u))))
else
tmp = u + (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (0.016666666666666666d0 * (l * l)))))))
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.02) {
tmp = U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
} else {
tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U)))) else: tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l)))))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); else tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004Initial program 87.3%
Taylor expanded in l around 0 62.8%
+-commutative62.8%
associate-*r*62.8%
fma-define62.8%
*-commutative62.8%
*-commutative62.8%
Simplified62.8%
Taylor expanded in U around inf 72.0%
associate-/l*76.1%
Simplified76.1%
if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in l around 0 91.2%
*-commutative91.2%
Simplified91.2%
unpow291.2%
Applied egg-rr91.2%
unpow291.2%
Applied egg-rr91.2%
Taylor expanded in K around 0 88.3%
Final simplification85.0%
(FPCore (J l K U)
:precision binary64
(if (or (<= l 2.2e+16) (not (<= l 1.25e+47)))
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* 0.016666666666666666 (* l l)))))))))
(+ U (* (- (exp l) (exp (- l))) J))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 2.2e+16) || !(l <= 1.25e+47)) {
tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
} else {
tmp = U + ((exp(l) - exp(-l)) * J);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= 2.2d+16) .or. (.not. (l <= 1.25d+47))) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (0.016666666666666666d0 * (l * l))))))))
else
tmp = u + ((exp(l) - exp(-l)) * j)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 2.2e+16) || !(l <= 1.25e+47)) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
} else {
tmp = U + ((Math.exp(l) - Math.exp(-l)) * J);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= 2.2e+16) or not (l <= 1.25e+47): tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))) else: tmp = U + ((math.exp(l) - math.exp(-l)) * J) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= 2.2e+16) || !(l <= 1.25e+47)) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l))))))))); else tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= 2.2e+16) || ~((l <= 1.25e+47))) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))); else tmp = U + ((exp(l) - exp(-l)) * J); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, 2.2e+16], N[Not[LessEqual[l, 1.25e+47]], $MachinePrecision]], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.2 \cdot 10^{+16} \lor \neg \left(\ell \leq 1.25 \cdot 10^{+47}\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\end{array}
\end{array}
if l < 2.2e16 or 1.25000000000000005e47 < l Initial program 88.2%
Taylor expanded in l around 0 95.7%
*-commutative95.7%
Simplified95.7%
unpow295.7%
Applied egg-rr95.7%
unpow295.7%
Applied egg-rr95.7%
if 2.2e16 < l < 1.25000000000000005e47Initial program 100.0%
Taylor expanded in K around 0 90.9%
Final simplification95.5%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.02)
(+ U (* l (* 2.0 (* J (cos (* K 0.5))))))
(+
U
(*
J
(*
l
(+
2.0
(*
(* l l)
(+ 0.3333333333333333 (* 0.016666666666666666 (* l l))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = U + (l * (2.0 * (J * cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
}
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.02d0)) then
tmp = u + (l * (2.0d0 * (j * cos((k * 0.5d0)))))
else
tmp = u + (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (0.016666666666666666d0 * (l * l)))))))
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.02) {
tmp = U + (l * (2.0 * (J * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = U + (l * (2.0 * (J * math.cos((K * 0.5))))) else: tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(U + Float64(l * Float64(2.0 * Float64(J * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l)))))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = U + (l * (2.0 * (J * cos((K * 0.5))))); else tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(U + N[(l * N[(2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004Initial program 87.3%
Taylor expanded in l around 0 94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in l around 0 62.8%
*-commutative62.8%
associate-*r*62.8%
associate-*l*62.8%
*-commutative62.8%
*-commutative62.8%
*-commutative62.8%
Simplified62.8%
if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in l around 0 91.2%
*-commutative91.2%
Simplified91.2%
unpow291.2%
Applied egg-rr91.2%
unpow291.2%
Applied egg-rr91.2%
Taylor expanded in K around 0 88.3%
Final simplification81.3%
(FPCore (J l K U)
:precision binary64
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(+
2.0
(* (* l l) (+ 0.3333333333333333 (* 0.016666666666666666 (* l l))))))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (0.016666666666666666d0 * (l * l))))))))
end function
public static double code(double J, double l, double K, double U) {
return U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))))
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l))))))))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))); end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\right)
\end{array}
Initial program 88.7%
Taylor expanded in l around 0 92.1%
*-commutative92.1%
Simplified92.1%
unpow292.1%
Applied egg-rr92.1%
unpow292.1%
Applied egg-rr92.1%
Final simplification92.1%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -17500000000.0) (not (<= l 1.65e+22)))
(+
U
(*
J
(*
l
(+
2.0
(* (* l l) (+ 0.3333333333333333 (* 0.016666666666666666 (* l l))))))))
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -17500000000.0) || !(l <= 1.65e+22)) {
tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
} 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 <= (-17500000000.0d0)) .or. (.not. (l <= 1.65d+22))) then
tmp = u + (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (0.016666666666666666d0 * (l * l)))))))
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 <= -17500000000.0) || !(l <= 1.65e+22)) {
tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -17500000000.0) or not (l <= 1.65e+22): tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))) 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 <= -17500000000.0) || !(l <= 1.65e+22)) tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l)))))))); 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 <= -17500000000.0) || ~((l <= 1.65e+22))) tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))); 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, -17500000000.0], N[Not[LessEqual[l, 1.65e+22]], $MachinePrecision]], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -17500000000 \lor \neg \left(\ell \leq 1.65 \cdot 10^{+22}\right):\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\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.75e10 or 1.6499999999999999e22 < l Initial program 100.0%
Taylor expanded in l around 0 88.0%
*-commutative88.0%
Simplified88.0%
unpow288.0%
Applied egg-rr88.0%
unpow288.0%
Applied egg-rr88.0%
Taylor expanded in K around 0 67.2%
if -1.75e10 < l < 1.6499999999999999e22Initial program 76.1%
Taylor expanded in l around 0 95.4%
Final simplification80.5%
(FPCore (J l K U)
:precision binary64
(+
U
(*
J
(*
l
(+
2.0
(* (* l l) (+ 0.3333333333333333 (* 0.016666666666666666 (* l l)))))))))
double code(double J, double l, double K, double U) {
return U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
}
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 + ((l * l) * (0.3333333333333333d0 + (0.016666666666666666d0 * (l * l)))))))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))));
}
def code(J, l, K, U): return U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l)))))))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(0.016666666666666666 * Float64(l * l)))))))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (0.016666666666666666 * (l * l))))))); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(0.016666666666666666 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + 0.016666666666666666 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)
\end{array}
Initial program 88.7%
Taylor expanded in l around 0 92.1%
*-commutative92.1%
Simplified92.1%
unpow292.1%
Applied egg-rr92.1%
unpow292.1%
Applied egg-rr92.1%
Taylor expanded in K around 0 74.8%
Final simplification74.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3100000000000.0) (not (<= l 3700000000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3100000000000.0) || !(l <= 3700000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-3100000000000.0d0)) .or. (.not. (l <= 3700000000.0d0))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3100000000000.0) || !(l <= 3700000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -3100000000000.0) or not (l <= 3700000000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -3100000000000.0) || !(l <= 3700000000.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -3100000000000.0) || ~((l <= 3700000000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3100000000000.0], N[Not[LessEqual[l, 3700000000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3100000000000 \lor \neg \left(\ell \leq 3700000000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -3.1e12 or 3.7e9 < l Initial program 100.0%
Applied egg-rr12.7%
if -3.1e12 < l < 3.7e9Initial program 75.7%
Taylor expanded in J around 0 72.2%
Final simplification40.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 88.7%
Taylor expanded in l around 0 92.1%
*-commutative92.1%
Simplified92.1%
Taylor expanded in l around 0 57.2%
associate-*r*57.2%
*-commutative57.2%
Simplified57.2%
Taylor expanded in K around 0 48.8%
associate-*r*48.8%
*-commutative48.8%
associate-*r*49.2%
*-commutative49.2%
Simplified49.2%
Final simplification49.2%
(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 88.7%
Taylor expanded in J around 0 34.7%
(FPCore (J l K U) :precision binary64 -4.0)
double code(double J, double l, double K, double U) {
return -4.0;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = -4.0d0
end function
public static double code(double J, double l, double K, double U) {
return -4.0;
}
def code(J, l, K, U): return -4.0
function code(J, l, K, U) return -4.0 end
function tmp = code(J, l, K, U) tmp = -4.0; end
code[J_, l_, K_, U_] := -4.0
\begin{array}{l}
\\
-4
\end{array}
Initial program 88.7%
Applied egg-rr2.4%
Taylor expanded in U around 0 2.8%
herbie shell --seed 2024146
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))