
(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 17 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 0.0005)
(+ U (* t_0 (* l (+ (* 0.3333333333333333 (* J (* l l))) (* J 2.0)))))
(+ 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 <= 0.0005) {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0))));
} 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 <= 0.0005) {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0))));
} 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 <= 0.0005: tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0)))) 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 <= 0.0005) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * Float64(l * l))) + Float64(J * 2.0))))); 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 <= 0.0005) tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0)))); 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, 0.0005], N[(U + N[(t$95$0 * N[(l * N[(N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 2.0), $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 0.0005:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right) + J \cdot 2\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.0000000000000001e-4Initial program 71.7%
Taylor expanded in l around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
if 5.0000000000000001e-4 < (-.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 (+ U (* (- (exp l) (exp (- l))) J)))
(t_1 (cos (/ K 2.0)))
(t_2 (+ U (* t_1 (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))))
(if (<= l -1.95e+77)
t_2
(if (<= l -0.015)
t_0
(if (<= l 210.0)
(+ U (* t_1 (* l (+ (* 0.3333333333333333 (* J (* l l))) (* J 2.0)))))
(if (<= l 2.4e+93) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((exp(l) - exp(-l)) * J);
double t_1 = cos((K / 2.0));
double t_2 = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
double tmp;
if (l <= -1.95e+77) {
tmp = t_2;
} else if (l <= -0.015) {
tmp = t_0;
} else if (l <= 210.0) {
tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0))));
} else if (l <= 2.4e+93) {
tmp = t_0;
} else {
tmp = t_2;
}
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 = u + ((exp(l) - exp(-l)) * j)
t_1 = cos((k / 2.0d0))
t_2 = u + (t_1 * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
if (l <= (-1.95d+77)) then
tmp = t_2
else if (l <= (-0.015d0)) then
tmp = t_0
else if (l <= 210.0d0) then
tmp = u + (t_1 * (l * ((0.3333333333333333d0 * (j * (l * l))) + (j * 2.0d0))))
else if (l <= 2.4d+93) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + ((Math.exp(l) - Math.exp(-l)) * J);
double t_1 = Math.cos((K / 2.0));
double t_2 = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
double tmp;
if (l <= -1.95e+77) {
tmp = t_2;
} else if (l <= -0.015) {
tmp = t_0;
} else if (l <= 210.0) {
tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0))));
} else if (l <= 2.4e+93) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.exp(l) - math.exp(-l)) * J) t_1 = math.cos((K / 2.0)) t_2 = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) tmp = 0 if l <= -1.95e+77: tmp = t_2 elif l <= -0.015: tmp = t_0 elif l <= 210.0: tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0)))) elif l <= 2.4e+93: tmp = t_0 else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) t_1 = cos(Float64(K / 2.0)) t_2 = Float64(U + Float64(t_1 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))))))) tmp = 0.0 if (l <= -1.95e+77) tmp = t_2; elseif (l <= -0.015) tmp = t_0; elseif (l <= 210.0) tmp = Float64(U + Float64(t_1 * Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * Float64(l * l))) + Float64(J * 2.0))))); elseif (l <= 2.4e+93) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((exp(l) - exp(-l)) * J); t_1 = cos((K / 2.0)); t_2 = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); tmp = 0.0; if (l <= -1.95e+77) tmp = t_2; elseif (l <= -0.015) tmp = t_0; elseif (l <= 210.0) tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0)))); elseif (l <= 2.4e+93) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(t$95$1 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.95e+77], t$95$2, If[LessEqual[l, -0.015], t$95$0, If[LessEqual[l, 210.0], N[(U + N[(t$95$1 * N[(l * N[(N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+93], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := U + t\_1 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\mathbf{if}\;\ell \leq -1.95 \cdot 10^{+77}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq -0.015:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 210:\\
\;\;\;\;U + t\_1 \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right) + J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if l < -1.9499999999999999e77 or 2.4000000000000001e93 < l Initial program 100.0%
Taylor expanded in l around 0 99.1%
unpow290.2%
Applied egg-rr99.1%
if -1.9499999999999999e77 < l < -0.014999999999999999 or 210 < l < 2.4000000000000001e93Initial program 100.0%
Taylor expanded in K around 0 80.0%
if -0.014999999999999999 < l < 210Initial program 71.9%
Taylor expanded in l around 0 99.1%
unpow299.1%
Applied egg-rr99.1%
Final simplification96.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (exp (- l))))
(if (<= l -4.0)
(+ (* (* J (- 27.0 t_1)) t_0) U)
(if (<= l 210.0)
(+ U (* t_0 (* l (+ (* 0.3333333333333333 (* J (* l l))) (* J 2.0)))))
(if (<= l 3.2e+93)
(+ U (* (- (exp l) t_1) J))
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))))))
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 <= -4.0) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (l <= 210.0) {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0))));
} else if (l <= 3.2e+93) {
tmp = U + ((exp(l) - t_1) * J);
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(-l)
if (l <= (-4.0d0)) then
tmp = ((j * (27.0d0 - t_1)) * t_0) + u
else if (l <= 210.0d0) then
tmp = u + (t_0 * (l * ((0.3333333333333333d0 * (j * (l * l))) + (j * 2.0d0))))
else if (l <= 3.2d+93) then
tmp = u + ((exp(l) - t_1) * j)
else
tmp = u + (t_0 * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
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 <= -4.0) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (l <= 210.0) {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0))));
} else if (l <= 3.2e+93) {
tmp = U + ((Math.exp(l) - t_1) * J);
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(-l) tmp = 0 if l <= -4.0: tmp = ((J * (27.0 - t_1)) * t_0) + U elif l <= 210.0: tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0)))) elif l <= 3.2e+93: tmp = U + ((math.exp(l) - t_1) * J) else: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) 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 <= -4.0) tmp = Float64(Float64(Float64(J * Float64(27.0 - t_1)) * t_0) + U); elseif (l <= 210.0) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * Float64(l * l))) + Float64(J * 2.0))))); elseif (l <= 3.2e+93) tmp = Float64(U + Float64(Float64(exp(l) - t_1) * J)); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))))))); 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 <= -4.0) tmp = ((J * (27.0 - t_1)) * t_0) + U; elseif (l <= 210.0) tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l * l))) + (J * 2.0)))); elseif (l <= 3.2e+93) tmp = U + ((exp(l) - t_1) * J); else tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); 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, -4.0], N[(N[(N[(J * N[(27.0 - t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 210.0], N[(U + N[(t$95$0 * N[(l * N[(N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.2e+93], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - t$95$1), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $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}\\
\mathbf{if}\;\ell \leq -4:\\
\;\;\;\;\left(J \cdot \left(27 - t\_1\right)\right) \cdot t\_0 + U\\
\mathbf{elif}\;\ell \leq 210:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right) + J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+93}:\\
\;\;\;\;U + \left(e^{\ell} - t\_1\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\end{array}
\end{array}
if l < -4Initial program 100.0%
Applied egg-rr100.0%
if -4 < l < 210Initial program 71.9%
Taylor expanded in l around 0 99.1%
unpow299.1%
Applied egg-rr99.1%
if 210 < l < 3.2000000000000001e93Initial program 100.0%
Taylor expanded in K around 0 83.3%
if 3.2000000000000001e93 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
unpow287.4%
Applied egg-rr100.0%
Final simplification98.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.01) (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.01) {
tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(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) :: tmp
if (cos((k / 2.0d0)) <= 0.01d0) then
tmp = u * (1.0d0 + (2.0d0 * (j * ((l * cos((k * 0.5d0))) / u))))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
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.01) {
tmp = U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.01: tmp = U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U)))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.01) 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(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.01) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.01], 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[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.01:\\
\;\;\;\;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 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0100000000000000002Initial program 79.9%
Taylor expanded in l around 0 64.9%
*-commutative64.9%
associate-*l*64.9%
Simplified64.9%
Taylor expanded in l around inf 51.6%
Taylor expanded in U around inf 69.7%
associate-/l*74.7%
*-commutative74.7%
Simplified74.7%
if 0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.1%
Taylor expanded in l around 0 89.8%
Taylor expanded in K around 0 85.9%
Final simplification83.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.01) (* J (+ (* 2.0 (* l (cos (* K 0.5)))) (/ U J))) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.01) {
tmp = J * ((2.0 * (l * cos((K * 0.5)))) + (U / J));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(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) :: tmp
if (cos((k / 2.0d0)) <= 0.01d0) then
tmp = j * ((2.0d0 * (l * cos((k * 0.5d0)))) + (u / j))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
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.01) {
tmp = J * ((2.0 * (l * Math.cos((K * 0.5)))) + (U / J));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.01: tmp = J * ((2.0 * (l * math.cos((K * 0.5)))) + (U / J)) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.01) tmp = Float64(J * Float64(Float64(2.0 * Float64(l * cos(Float64(K * 0.5)))) + Float64(U / J))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.01) tmp = J * ((2.0 * (l * cos((K * 0.5)))) + (U / J)); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.01], N[(J * N[(N[(2.0 * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.01:\\
\;\;\;\;J \cdot \left(2 \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right) + \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0100000000000000002Initial program 79.9%
Taylor expanded in l around 0 64.9%
*-commutative64.9%
associate-*l*64.9%
Simplified64.9%
Taylor expanded in J around inf 68.0%
if 0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.1%
Taylor expanded in l around 0 89.8%
Taylor expanded in K around 0 85.9%
Final simplification81.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.01)
(+ U (* t_0 (* J (* l 2.0))))
(+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.01) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= 0.01d0) then
tmp = u + (t_0 * (j * (l * 2.0d0)))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.01) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.01: tmp = U + (t_0 * (J * (l * 2.0))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.01) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0)))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.01) tmp = U + (t_0 * (J * (l * 2.0))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.01], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.01:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0100000000000000002Initial program 79.9%
Taylor expanded in l around 0 64.9%
*-commutative64.9%
associate-*l*64.9%
Simplified64.9%
if 0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.1%
Taylor expanded in l around 0 89.8%
Taylor expanded in K around 0 85.9%
Final simplification81.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* l (* J 2.0)))
(t_1 (* U (+ 1.0 (* 2.0 (* J (/ l U))))))
(t_2 (* l (/ U l))))
(if (<= l -6.5e+136)
t_1
(if (<= l -1.75e+19)
(/ (- (* t_0 t_0) (* t_2 t_2)) (- t_0 t_2))
(if (<= l 100.0) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0)))) t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = l * (J * 2.0);
double t_1 = U * (1.0 + (2.0 * (J * (l / U))));
double t_2 = l * (U / l);
double tmp;
if (l <= -6.5e+136) {
tmp = t_1;
} else if (l <= -1.75e+19) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else if (l <= 100.0) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = l * (j * 2.0d0)
t_1 = u * (1.0d0 + (2.0d0 * (j * (l / u))))
t_2 = l * (u / l)
if (l <= (-6.5d+136)) then
tmp = t_1
else if (l <= (-1.75d+19)) then
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2)
else if (l <= 100.0d0) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
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 = l * (J * 2.0);
double t_1 = U * (1.0 + (2.0 * (J * (l / U))));
double t_2 = l * (U / l);
double tmp;
if (l <= -6.5e+136) {
tmp = t_1;
} else if (l <= -1.75e+19) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else if (l <= 100.0) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = l * (J * 2.0) t_1 = U * (1.0 + (2.0 * (J * (l / U)))) t_2 = l * (U / l) tmp = 0 if l <= -6.5e+136: tmp = t_1 elif l <= -1.75e+19: tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2) elif l <= 100.0: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(l * Float64(J * 2.0)) t_1 = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))) t_2 = Float64(l * Float64(U / l)) tmp = 0.0 if (l <= -6.5e+136) tmp = t_1; elseif (l <= -1.75e+19) tmp = Float64(Float64(Float64(t_0 * t_0) - Float64(t_2 * t_2)) / Float64(t_0 - t_2)); elseif (l <= 100.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = l * (J * 2.0); t_1 = U * (1.0 + (2.0 * (J * (l / U)))); t_2 = l * (U / l); tmp = 0.0; if (l <= -6.5e+136) tmp = t_1; elseif (l <= -1.75e+19) tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2); elseif (l <= 100.0) tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(l * N[(U / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -6.5e+136], t$95$1, If[LessEqual[l, -1.75e+19], N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 100.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \ell \cdot \left(J \cdot 2\right)\\
t_1 := U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
t_2 := \ell \cdot \frac{U}{\ell}\\
\mathbf{if}\;\ell \leq -6.5 \cdot 10^{+136}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -1.75 \cdot 10^{+19}:\\
\;\;\;\;\frac{t\_0 \cdot t\_0 - t\_2 \cdot t\_2}{t\_0 - t\_2}\\
\mathbf{elif}\;\ell \leq 100:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -6.4999999999999998e136 or 100 < l Initial program 100.0%
Taylor expanded in l around 0 26.0%
*-commutative26.0%
associate-*l*26.9%
Simplified26.9%
Taylor expanded in l around inf 26.0%
Taylor expanded in K around 0 19.6%
Taylor expanded in U around inf 33.4%
associate-/l*41.8%
Simplified41.8%
if -6.4999999999999998e136 < l < -1.75e19Initial program 100.0%
Taylor expanded in l around 0 4.7%
*-commutative4.7%
associate-*l*4.7%
Simplified4.7%
Taylor expanded in l around inf 4.7%
Taylor expanded in K around 0 3.9%
distribute-lft-in3.9%
flip-+34.6%
*-commutative34.6%
*-commutative34.6%
*-commutative34.6%
Applied egg-rr34.6%
if -1.75e19 < l < 100Initial program 72.4%
Taylor expanded in l around 0 98.0%
*-commutative98.0%
associate-*l*98.0%
Simplified98.0%
Final simplification67.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* l (* J 2.0)))
(t_1 (* U (+ 1.0 (* 2.0 (* J (/ l U))))))
(t_2 (* l (/ U l))))
(if (<= l -3.05e+131)
t_1
(if (<= l -1.5e+19)
(/ (- (* t_0 t_0) (* t_2 t_2)) (- t_0 t_2))
(if (<= l 30.0) (+ U (* J (* 2.0 (* l (cos (* K 0.5)))))) t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = l * (J * 2.0);
double t_1 = U * (1.0 + (2.0 * (J * (l / U))));
double t_2 = l * (U / l);
double tmp;
if (l <= -3.05e+131) {
tmp = t_1;
} else if (l <= -1.5e+19) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else if (l <= 30.0) {
tmp = U + (J * (2.0 * (l * cos((K * 0.5)))));
} 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 = l * (j * 2.0d0)
t_1 = u * (1.0d0 + (2.0d0 * (j * (l / u))))
t_2 = l * (u / l)
if (l <= (-3.05d+131)) then
tmp = t_1
else if (l <= (-1.5d+19)) then
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2)
else if (l <= 30.0d0) then
tmp = u + (j * (2.0d0 * (l * cos((k * 0.5d0)))))
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 = l * (J * 2.0);
double t_1 = U * (1.0 + (2.0 * (J * (l / U))));
double t_2 = l * (U / l);
double tmp;
if (l <= -3.05e+131) {
tmp = t_1;
} else if (l <= -1.5e+19) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else if (l <= 30.0) {
tmp = U + (J * (2.0 * (l * Math.cos((K * 0.5)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = l * (J * 2.0) t_1 = U * (1.0 + (2.0 * (J * (l / U)))) t_2 = l * (U / l) tmp = 0 if l <= -3.05e+131: tmp = t_1 elif l <= -1.5e+19: tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2) elif l <= 30.0: tmp = U + (J * (2.0 * (l * math.cos((K * 0.5))))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(l * Float64(J * 2.0)) t_1 = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))) t_2 = Float64(l * Float64(U / l)) tmp = 0.0 if (l <= -3.05e+131) tmp = t_1; elseif (l <= -1.5e+19) tmp = Float64(Float64(Float64(t_0 * t_0) - Float64(t_2 * t_2)) / Float64(t_0 - t_2)); elseif (l <= 30.0) tmp = Float64(U + Float64(J * Float64(2.0 * Float64(l * cos(Float64(K * 0.5)))))); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = l * (J * 2.0); t_1 = U * (1.0 + (2.0 * (J * (l / U)))); t_2 = l * (U / l); tmp = 0.0; if (l <= -3.05e+131) tmp = t_1; elseif (l <= -1.5e+19) tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2); elseif (l <= 30.0) tmp = U + (J * (2.0 * (l * cos((K * 0.5))))); else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(l * N[(U / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.05e+131], t$95$1, If[LessEqual[l, -1.5e+19], N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 30.0], N[(U + N[(J * N[(2.0 * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \ell \cdot \left(J \cdot 2\right)\\
t_1 := U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
t_2 := \ell \cdot \frac{U}{\ell}\\
\mathbf{if}\;\ell \leq -3.05 \cdot 10^{+131}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -1.5 \cdot 10^{+19}:\\
\;\;\;\;\frac{t\_0 \cdot t\_0 - t\_2 \cdot t\_2}{t\_0 - t\_2}\\
\mathbf{elif}\;\ell \leq 30:\\
\;\;\;\;U + J \cdot \left(2 \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -3.0499999999999999e131 or 30 < l Initial program 100.0%
Taylor expanded in l around 0 26.0%
*-commutative26.0%
associate-*l*26.9%
Simplified26.9%
Taylor expanded in l around inf 26.0%
Taylor expanded in K around 0 19.6%
Taylor expanded in U around inf 33.4%
associate-/l*41.8%
Simplified41.8%
if -3.0499999999999999e131 < l < -1.5e19Initial program 100.0%
Taylor expanded in l around 0 4.7%
*-commutative4.7%
associate-*l*4.7%
Simplified4.7%
Taylor expanded in l around inf 4.7%
Taylor expanded in K around 0 3.9%
distribute-lft-in3.9%
flip-+34.6%
*-commutative34.6%
*-commutative34.6%
*-commutative34.6%
Applied egg-rr34.6%
if -1.5e19 < l < 30Initial program 72.4%
Taylor expanded in l around 0 97.9%
*-commutative97.9%
associate-*l*97.9%
*-commutative97.9%
*-commutative97.9%
Simplified97.9%
Final simplification67.5%
(FPCore (J l K U) :precision binary64 (+ U (* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (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 + (0.3333333333333333d0 * (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 + (0.3333333333333333 * (l * l))))));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (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(0.3333333333333333 * Float64(l * l))))))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (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[(0.3333333333333333 * N[(l * l), $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 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)
\end{array}
Initial program 87.1%
Taylor expanded in l around 0 89.1%
unpow285.3%
Applied egg-rr89.1%
Final simplification89.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* l (* J 2.0)))
(t_1 (* U (+ 1.0 (* 2.0 (* J (/ l U))))))
(t_2 (* l (/ U l))))
(if (<= l -2.25e+128)
t_1
(if (<= l -1.5e+19)
(/ (- (* t_0 t_0) (* t_2 t_2)) (- t_0 t_2))
(if (<= l 2e-39) (+ U (* 2.0 (* l J))) t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = l * (J * 2.0);
double t_1 = U * (1.0 + (2.0 * (J * (l / U))));
double t_2 = l * (U / l);
double tmp;
if (l <= -2.25e+128) {
tmp = t_1;
} else if (l <= -1.5e+19) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else if (l <= 2e-39) {
tmp = U + (2.0 * (l * J));
} 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 = l * (j * 2.0d0)
t_1 = u * (1.0d0 + (2.0d0 * (j * (l / u))))
t_2 = l * (u / l)
if (l <= (-2.25d+128)) then
tmp = t_1
else if (l <= (-1.5d+19)) then
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2)
else if (l <= 2d-39) then
tmp = u + (2.0d0 * (l * j))
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 = l * (J * 2.0);
double t_1 = U * (1.0 + (2.0 * (J * (l / U))));
double t_2 = l * (U / l);
double tmp;
if (l <= -2.25e+128) {
tmp = t_1;
} else if (l <= -1.5e+19) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else if (l <= 2e-39) {
tmp = U + (2.0 * (l * J));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = l * (J * 2.0) t_1 = U * (1.0 + (2.0 * (J * (l / U)))) t_2 = l * (U / l) tmp = 0 if l <= -2.25e+128: tmp = t_1 elif l <= -1.5e+19: tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2) elif l <= 2e-39: tmp = U + (2.0 * (l * J)) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(l * Float64(J * 2.0)) t_1 = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))) t_2 = Float64(l * Float64(U / l)) tmp = 0.0 if (l <= -2.25e+128) tmp = t_1; elseif (l <= -1.5e+19) tmp = Float64(Float64(Float64(t_0 * t_0) - Float64(t_2 * t_2)) / Float64(t_0 - t_2)); elseif (l <= 2e-39) tmp = Float64(U + Float64(2.0 * Float64(l * J))); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = l * (J * 2.0); t_1 = U * (1.0 + (2.0 * (J * (l / U)))); t_2 = l * (U / l); tmp = 0.0; if (l <= -2.25e+128) tmp = t_1; elseif (l <= -1.5e+19) tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2); elseif (l <= 2e-39) tmp = U + (2.0 * (l * J)); else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(l * N[(U / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.25e+128], t$95$1, If[LessEqual[l, -1.5e+19], N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2e-39], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \ell \cdot \left(J \cdot 2\right)\\
t_1 := U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
t_2 := \ell \cdot \frac{U}{\ell}\\
\mathbf{if}\;\ell \leq -2.25 \cdot 10^{+128}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -1.5 \cdot 10^{+19}:\\
\;\;\;\;\frac{t\_0 \cdot t\_0 - t\_2 \cdot t\_2}{t\_0 - t\_2}\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{-39}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -2.2500000000000001e128 or 1.99999999999999986e-39 < l Initial program 97.4%
Taylor expanded in l around 0 29.4%
*-commutative29.4%
associate-*l*30.1%
Simplified30.1%
Taylor expanded in l around inf 29.4%
Taylor expanded in K around 0 20.7%
Taylor expanded in U around inf 33.8%
associate-/l*41.8%
Simplified41.8%
if -2.2500000000000001e128 < l < -1.5e19Initial program 100.0%
Taylor expanded in l around 0 4.7%
*-commutative4.7%
associate-*l*4.7%
Simplified4.7%
Taylor expanded in l around inf 4.7%
Taylor expanded in K around 0 3.9%
distribute-lft-in3.9%
flip-+34.6%
*-commutative34.6%
*-commutative34.6%
*-commutative34.6%
Applied egg-rr34.6%
if -1.5e19 < l < 1.99999999999999986e-39Initial program 73.7%
Taylor expanded in l around 0 98.2%
*-commutative98.2%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in K around 0 84.4%
Final simplification60.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1150.0) (not (<= l 0.00013))) (* J (* l 2.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1150.0) || !(l <= 0.00013)) {
tmp = J * (l * 2.0);
} 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 <= (-1150.0d0)) .or. (.not. (l <= 0.00013d0))) then
tmp = j * (l * 2.0d0)
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 <= -1150.0) || !(l <= 0.00013)) {
tmp = J * (l * 2.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1150.0) or not (l <= 0.00013): tmp = J * (l * 2.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1150.0) || !(l <= 0.00013)) tmp = Float64(J * Float64(l * 2.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1150.0) || ~((l <= 0.00013))) tmp = J * (l * 2.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1150.0], N[Not[LessEqual[l, 0.00013]], $MachinePrecision]], N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1150 \lor \neg \left(\ell \leq 0.00013\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -1150 or 1.29999999999999989e-4 < l Initial program 99.9%
Taylor expanded in l around 0 23.3%
*-commutative23.3%
associate-*l*24.0%
Simplified24.0%
Taylor expanded in l around inf 23.3%
Taylor expanded in K around 0 17.6%
Taylor expanded in l around inf 17.6%
associate-*r*17.6%
*-commutative17.6%
associate-*r*18.3%
Simplified18.3%
if -1150 < l < 1.29999999999999989e-4Initial program 71.6%
Applied egg-rr50.0%
Taylor expanded in U around inf 71.6%
Final simplification42.4%
(FPCore (J l K U) :precision binary64 (if (<= l -1e+19) (* J (+ (/ U J) (* l 2.0))) (+ U (* 2.0 (* l J)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1e+19) {
tmp = J * ((U / J) + (l * 2.0));
} else {
tmp = U + (2.0 * (l * J));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-1d+19)) then
tmp = j * ((u / j) + (l * 2.0d0))
else
tmp = u + (2.0d0 * (l * j))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1e+19) {
tmp = J * ((U / J) + (l * 2.0));
} else {
tmp = U + (2.0 * (l * J));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1e+19: tmp = J * ((U / J) + (l * 2.0)) else: tmp = U + (2.0 * (l * J)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1e+19) tmp = Float64(J * Float64(Float64(U / J) + Float64(l * 2.0))); else tmp = Float64(U + Float64(2.0 * Float64(l * J))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1e+19) tmp = J * ((U / J) + (l * 2.0)); else tmp = U + (2.0 * (l * J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1e+19], N[(J * N[(N[(U / J), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{+19}:\\
\;\;\;\;J \cdot \left(\frac{U}{J} + \ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\
\end{array}
\end{array}
if l < -1e19Initial program 100.0%
Taylor expanded in l around 0 24.8%
*-commutative24.8%
associate-*l*26.2%
Simplified26.2%
Taylor expanded in l around inf 24.8%
Taylor expanded in K around 0 18.6%
Taylor expanded in J around inf 30.7%
if -1e19 < l Initial program 82.2%
Taylor expanded in l around 0 70.5%
*-commutative70.5%
associate-*l*70.5%
Simplified70.5%
Taylor expanded in K around 0 58.7%
Final simplification51.0%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (* J (/ l U))))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / 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 * (1.0d0 + (2.0d0 * (j * (l / u))))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / U))));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * (J * (l / U))))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * (J * (l / U)))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)
\end{array}
Initial program 87.1%
Taylor expanded in l around 0 58.0%
*-commutative58.0%
associate-*l*58.4%
Simplified58.4%
Taylor expanded in l around inf 47.7%
Taylor expanded in K around 0 37.5%
Taylor expanded in U around inf 51.6%
associate-/l*55.3%
Simplified55.3%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* l J))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (2.0d0 * (l * j))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
def code(J, l, K, U): return U + (2.0 * (l * J))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(l * J))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (l * J)); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(\ell \cdot J\right)
\end{array}
Initial program 87.1%
Taylor expanded in l around 0 58.0%
*-commutative58.0%
associate-*l*58.4%
Simplified58.4%
Taylor expanded in K around 0 47.7%
Final simplification47.7%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 87.1%
Applied egg-rr24.0%
Taylor expanded in U around inf 33.7%
(FPCore (J l K U) :precision binary64 8.0)
double code(double J, double l, double K, double U) {
return 8.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 = 8.0d0
end function
public static double code(double J, double l, double K, double U) {
return 8.0;
}
def code(J, l, K, U): return 8.0
function code(J, l, K, U) return 8.0 end
function tmp = code(J, l, K, U) tmp = 8.0; end
code[J_, l_, K_, U_] := 8.0
\begin{array}{l}
\\
8
\end{array}
Initial program 87.1%
Applied egg-rr24.1%
Taylor expanded in U around 0 2.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 87.1%
Applied egg-rr24.0%
Taylor expanded in U around 0 2.7%
herbie shell --seed 2024145
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))