
(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 (+ (* 2.0 (* J (log1p (expm1 (* l (cos (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * log1p(expm1((l * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * Math.log1p(Math.expm1((l * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U): return (2.0 * (J * math.log1p(math.expm1((l * math.cos((K * 0.5))))))) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * log1p(expm1(Float64(l * cos(Float64(K * 0.5))))))) + U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Initial program 84.9%
Taylor expanded in l around 0 58.7%
log1p-expm1-u99.6%
*-commutative99.6%
Applied egg-rr99.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* (* J (* 0.3333333333333333 (pow l 3.0))) t_0)))
(t_2 (* J (- (exp l) (exp (- l))))))
(if (<= l -5.4e+124)
t_1
(if (<= l -14500.0)
t_2
(if (<= l 0.39)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
(if (<= l 5e+93) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + ((J * (0.3333333333333333 * pow(l, 3.0))) * t_0);
double t_2 = J * (exp(l) - exp(-l));
double tmp;
if (l <= -5.4e+124) {
tmp = t_1;
} else if (l <= -14500.0) {
tmp = t_2;
} else if (l <= 0.39) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else if (l <= 5e+93) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u + ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * t_0)
t_2 = j * (exp(l) - exp(-l))
if (l <= (-5.4d+124)) then
tmp = t_1
else if (l <= (-14500.0d0)) then
tmp = t_2
else if (l <= 0.39d0) then
tmp = u + (t_0 * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))))
else if (l <= 5d+93) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = U + ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * t_0);
double t_2 = J * (Math.exp(l) - Math.exp(-l));
double tmp;
if (l <= -5.4e+124) {
tmp = t_1;
} else if (l <= -14500.0) {
tmp = t_2;
} else if (l <= 0.39) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else if (l <= 5e+93) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + ((J * (0.3333333333333333 * math.pow(l, 3.0))) * t_0) t_2 = J * (math.exp(l) - math.exp(-l)) tmp = 0 if l <= -5.4e+124: tmp = t_1 elif l <= -14500.0: tmp = t_2 elif l <= 0.39: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) elif l <= 5e+93: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * t_0)) t_2 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if (l <= -5.4e+124) tmp = t_1; elseif (l <= -14500.0) tmp = t_2; elseif (l <= 0.39) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); elseif (l <= 5e+93) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = U + ((J * (0.3333333333333333 * (l ^ 3.0))) * t_0); t_2 = J * (exp(l) - exp(-l)); tmp = 0.0; if (l <= -5.4e+124) tmp = t_1; elseif (l <= -14500.0) tmp = t_2; elseif (l <= 0.39) tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))))); elseif (l <= 5e+93) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.4e+124], t$95$1, If[LessEqual[l, -14500.0], t$95$2, If[LessEqual[l, 0.39], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e+93], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0\\
t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -5.4 \cdot 10^{+124}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -14500:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 0.39:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{+93}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -5.39999999999999956e124 or 5.0000000000000001e93 < l Initial program 100.0%
Taylor expanded in l around 0 97.8%
Taylor expanded in l around inf 97.8%
associate-*r*97.8%
*-commutative97.8%
associate-*r*97.8%
Simplified97.8%
if -5.39999999999999956e124 < l < -14500 or 0.39000000000000001 < l < 5.0000000000000001e93Initial program 100.0%
Taylor expanded in K around 0 78.3%
Taylor expanded in J around inf 78.3%
if -14500 < l < 0.39000000000000001Initial program 64.2%
Taylor expanded in l around 0 99.0%
Final simplification93.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (* J (* 0.3333333333333333 (pow l 3.0))) (cos (/ K 2.0)))))
(t_1 (* J (- (exp l) (exp (- l))))))
(if (<= l -5.4e+124)
t_0
(if (<= l -14500.0)
t_1
(if (<= l 0.39)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(if (<= l 5e+93) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((J * (0.3333333333333333 * pow(l, 3.0))) * cos((K / 2.0)));
double t_1 = J * (exp(l) - exp(-l));
double tmp;
if (l <= -5.4e+124) {
tmp = t_0;
} else if (l <= -14500.0) {
tmp = t_1;
} else if (l <= 0.39) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else if (l <= 5e+93) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = u + ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * cos((k / 2.0d0)))
t_1 = j * (exp(l) - exp(-l))
if (l <= (-5.4d+124)) then
tmp = t_0
else if (l <= (-14500.0d0)) then
tmp = t_1
else if (l <= 0.39d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else if (l <= 5d+93) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * Math.cos((K / 2.0)));
double t_1 = J * (Math.exp(l) - Math.exp(-l));
double tmp;
if (l <= -5.4e+124) {
tmp = t_0;
} else if (l <= -14500.0) {
tmp = t_1;
} else if (l <= 0.39) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else if (l <= 5e+93) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((J * (0.3333333333333333 * math.pow(l, 3.0))) * math.cos((K / 2.0))) t_1 = J * (math.exp(l) - math.exp(-l)) tmp = 0 if l <= -5.4e+124: tmp = t_0 elif l <= -14500.0: tmp = t_1 elif l <= 0.39: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) elif l <= 5e+93: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * cos(Float64(K / 2.0)))) t_1 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if (l <= -5.4e+124) tmp = t_0; elseif (l <= -14500.0) tmp = t_1; elseif (l <= 0.39) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); elseif (l <= 5e+93) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((J * (0.3333333333333333 * (l ^ 3.0))) * cos((K / 2.0))); t_1 = J * (exp(l) - exp(-l)); tmp = 0.0; if (l <= -5.4e+124) tmp = t_0; elseif (l <= -14500.0) tmp = t_1; elseif (l <= 0.39) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); elseif (l <= 5e+93) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.4e+124], t$95$0, If[LessEqual[l, -14500.0], t$95$1, If[LessEqual[l, 0.39], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e+93], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_1 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -5.4 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -14500:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq 0.39:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{+93}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -5.39999999999999956e124 or 5.0000000000000001e93 < l Initial program 100.0%
Taylor expanded in l around 0 97.8%
Taylor expanded in l around inf 97.8%
associate-*r*97.8%
*-commutative97.8%
associate-*r*97.8%
Simplified97.8%
if -5.39999999999999956e124 < l < -14500 or 0.39000000000000001 < l < 5.0000000000000001e93Initial program 100.0%
Taylor expanded in K around 0 78.3%
Taylor expanded in J around inf 78.3%
if -14500 < l < 0.39000000000000001Initial program 64.2%
Taylor expanded in l around 0 98.8%
Final simplification93.7%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.11) (* U (+ 1.0 (* 2.0 (/ (* J (+ l (* -0.125 (* l (pow K 2.0))))) U)))) (* U (+ 1.0 (/ (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) U)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.11) {
tmp = U * (1.0 + (2.0 * ((J * (l + (-0.125 * (l * pow(K, 2.0))))) / U)));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))) / 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 (cos((k / 2.0d0)) <= (-0.11d0)) then
tmp = u * (1.0d0 + (2.0d0 * ((j * (l + ((-0.125d0) * (l * (k ** 2.0d0))))) / u)))
else
tmp = u * (1.0d0 + ((j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))) / u))
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.11) {
tmp = U * (1.0 + (2.0 * ((J * (l + (-0.125 * (l * Math.pow(K, 2.0))))) / U)));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) / U));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.11: tmp = U * (1.0 + (2.0 * ((J * (l + (-0.125 * (l * math.pow(K, 2.0))))) / U))) else: tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) / U)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.11) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(Float64(J * Float64(l + Float64(-0.125 * Float64(l * (K ^ 2.0))))) / U)))); else tmp = Float64(U * Float64(1.0 + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) / U))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.11) tmp = U * (1.0 + (2.0 * ((J * (l + (-0.125 * (l * (K ^ 2.0))))) / U))); else tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))) / U)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.11], N[(U * N[(1.0 + N[(2.0 * N[(N[(J * N[(l + N[(-0.125 * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.11:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \frac{J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot {K}^{2}\right)\right)}{U}\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.110000000000000001Initial program 87.6%
Taylor expanded in l around 0 51.0%
Taylor expanded in K around 0 64.6%
Taylor expanded in U around inf 66.2%
if -0.110000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.1%
Taylor expanded in l around 0 82.2%
Taylor expanded in K around 0 74.3%
Taylor expanded in U around inf 76.9%
Final simplification74.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.11) (+ U (* (* J -0.25) (* l (pow K 2.0)))) (* U (+ 1.0 (/ (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) U)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.11) {
tmp = U + ((J * -0.25) * (l * pow(K, 2.0)));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))) / 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 (cos((k / 2.0d0)) <= (-0.11d0)) then
tmp = u + ((j * (-0.25d0)) * (l * (k ** 2.0d0)))
else
tmp = u * (1.0d0 + ((j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))) / u))
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.11) {
tmp = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) / U));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.11: tmp = U + ((J * -0.25) * (l * math.pow(K, 2.0))) else: tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) / U)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.11) tmp = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 2.0)))); else tmp = Float64(U * Float64(1.0 + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) / U))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.11) tmp = U + ((J * -0.25) * (l * (K ^ 2.0))); else tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))) / U)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.11], N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.11:\\
\;\;\;\;U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.110000000000000001Initial program 87.6%
Taylor expanded in l around 0 51.0%
Taylor expanded in K around 0 64.6%
Taylor expanded in K around inf 64.6%
associate-*r*64.6%
*-commutative64.6%
Simplified64.6%
if -0.110000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.1%
Taylor expanded in l around 0 82.2%
Taylor expanded in K around 0 74.3%
Taylor expanded in U around inf 76.9%
Final simplification74.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.11) (+ U (* (* J -0.25) (* l (pow K 2.0)))) (+ 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.11) {
tmp = U + ((J * -0.25) * (l * pow(K, 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) :: tmp
if (cos((k / 2.0d0)) <= (-0.11d0)) then
tmp = u + ((j * (-0.25d0)) * (l * (k ** 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 tmp;
if (Math.cos((K / 2.0)) <= -0.11) {
tmp = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
} 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.11: tmp = U + ((J * -0.25) * (l * math.pow(K, 2.0))) 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.11) tmp = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 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) tmp = 0.0; if (cos((K / 2.0)) <= -0.11) tmp = U + ((J * -0.25) * (l * (K ^ 2.0))); 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.11], N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 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}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.11:\\
\;\;\;\;U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\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.110000000000000001Initial program 87.6%
Taylor expanded in l around 0 51.0%
Taylor expanded in K around 0 64.6%
Taylor expanded in K around inf 64.6%
associate-*r*64.6%
*-commutative64.6%
Simplified64.6%
if -0.110000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.1%
Taylor expanded in l around 0 82.2%
Taylor expanded in K around 0 74.3%
Final simplification72.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.11) (+ U (* (* J -0.25) (* l (pow K 2.0)))) (+ U (* J (* 0.3333333333333333 (pow l 3.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.11) {
tmp = U + ((J * -0.25) * (l * pow(K, 2.0)));
} else {
tmp = U + (J * (0.3333333333333333 * pow(l, 3.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.11d0)) then
tmp = u + ((j * (-0.25d0)) * (l * (k ** 2.0d0)))
else
tmp = u + (j * (0.3333333333333333d0 * (l ** 3.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.11) {
tmp = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
} else {
tmp = U + (J * (0.3333333333333333 * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.11: tmp = U + ((J * -0.25) * (l * math.pow(K, 2.0))) else: tmp = U + (J * (0.3333333333333333 * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.11) tmp = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 2.0)))); else tmp = Float64(U + Float64(J * Float64(0.3333333333333333 * (l ^ 3.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.11) tmp = U + ((J * -0.25) * (l * (K ^ 2.0))); else tmp = U + (J * (0.3333333333333333 * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.11], N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.11:\\
\;\;\;\;U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.110000000000000001Initial program 87.6%
Taylor expanded in l around 0 51.0%
Taylor expanded in K around 0 64.6%
Taylor expanded in K around inf 64.6%
associate-*r*64.6%
*-commutative64.6%
Simplified64.6%
if -0.110000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.1%
Taylor expanded in l around 0 82.2%
Taylor expanded in K around 0 74.3%
Taylor expanded in l around inf 65.4%
associate-*r*65.9%
*-commutative65.9%
associate-*r*65.9%
Simplified65.4%
Final simplification65.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -14500.0) (not (<= l 0.39))) (* J (- (exp l) (exp (- l)))) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -14500.0) || !(l <= 0.39)) {
tmp = J * (exp(l) - exp(-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 <= (-14500.0d0)) .or. (.not. (l <= 0.39d0))) then
tmp = j * (exp(l) - exp(-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 <= -14500.0) || !(l <= 0.39)) {
tmp = J * (Math.exp(l) - Math.exp(-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 <= -14500.0) or not (l <= 0.39): tmp = J * (math.exp(l) - math.exp(-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 <= -14500.0) || !(l <= 0.39)) tmp = Float64(J * Float64(exp(l) - exp(Float64(-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 <= -14500.0) || ~((l <= 0.39))) tmp = J * (exp(l) - exp(-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, -14500.0], N[Not[LessEqual[l, 0.39]], $MachinePrecision]], N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $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 -14500 \lor \neg \left(\ell \leq 0.39\right):\\
\;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\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 < -14500 or 0.39000000000000001 < l Initial program 100.0%
Taylor expanded in K around 0 75.0%
Taylor expanded in J around inf 75.0%
if -14500 < l < 0.39000000000000001Initial program 64.2%
Taylor expanded in l around 0 98.8%
Final simplification85.1%
(FPCore (J l K U)
:precision binary64
(if (<= l -1.55e-6)
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))
(if (<= l 310.0)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(if (<= l 1.6e+37)
(* 2.0 (* J (+ l (* -0.125 (* l (pow K 2.0))))))
(* 0.3333333333333333 (* J (pow l 3.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.55e-6) {
tmp = J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))));
} else if (l <= 310.0) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else if (l <= 1.6e+37) {
tmp = 2.0 * (J * (l + (-0.125 * (l * pow(K, 2.0)))));
} else {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-1.55d-6)) then
tmp = j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))
else if (l <= 310.0d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else if (l <= 1.6d+37) then
tmp = 2.0d0 * (j * (l + ((-0.125d0) * (l * (k ** 2.0d0)))))
else
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.55e-6) {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
} else if (l <= 310.0) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else if (l <= 1.6e+37) {
tmp = 2.0 * (J * (l + (-0.125 * (l * Math.pow(K, 2.0)))));
} else {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.55e-6: tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) elif l <= 310.0: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) elif l <= 1.6e+37: tmp = 2.0 * (J * (l + (-0.125 * (l * math.pow(K, 2.0))))) else: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.55e-6) tmp = Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))); elseif (l <= 310.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); elseif (l <= 1.6e+37) tmp = Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * (K ^ 2.0)))))); else tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.55e-6) tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); elseif (l <= 310.0) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); elseif (l <= 1.6e+37) tmp = 2.0 * (J * (l + (-0.125 * (l * (K ^ 2.0))))); else tmp = 0.3333333333333333 * (J * (l ^ 3.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.55e-6], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 310.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.6e+37], N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.55 \cdot 10^{-6}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\mathbf{elif}\;\ell \leq 310:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 1.6 \cdot 10^{+37}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot {K}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if l < -1.55e-6Initial program 99.6%
Taylor expanded in l around 0 67.9%
Taylor expanded in K around 0 51.8%
Taylor expanded in J around inf 51.9%
if -1.55e-6 < l < 310Initial program 64.2%
Taylor expanded in l around 0 99.2%
if 310 < l < 1.60000000000000007e37Initial program 100.0%
Taylor expanded in l around 0 3.3%
Taylor expanded in K around 0 60.8%
Taylor expanded in J around inf 61.1%
if 1.60000000000000007e37 < l Initial program 100.0%
Taylor expanded in l around 0 76.0%
Taylor expanded in K around 0 58.5%
Taylor expanded in l around inf 58.6%
Final simplification73.7%
(FPCore (J l K U)
:precision binary64
(if (<= l -1.55e-6)
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))
(if (<= l 320.0)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(if (<= l 2.5e+37)
(+ U (* (* J -0.25) (* l (pow K 2.0))))
(* 0.3333333333333333 (* J (pow l 3.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.55e-6) {
tmp = J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))));
} else if (l <= 320.0) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else if (l <= 2.5e+37) {
tmp = U + ((J * -0.25) * (l * pow(K, 2.0)));
} else {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-1.55d-6)) then
tmp = j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))
else if (l <= 320.0d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else if (l <= 2.5d+37) then
tmp = u + ((j * (-0.25d0)) * (l * (k ** 2.0d0)))
else
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.55e-6) {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
} else if (l <= 320.0) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else if (l <= 2.5e+37) {
tmp = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
} else {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.55e-6: tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) elif l <= 320.0: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) elif l <= 2.5e+37: tmp = U + ((J * -0.25) * (l * math.pow(K, 2.0))) else: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.55e-6) tmp = Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))); elseif (l <= 320.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); elseif (l <= 2.5e+37) tmp = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 2.0)))); else tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.55e-6) tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); elseif (l <= 320.0) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); elseif (l <= 2.5e+37) tmp = U + ((J * -0.25) * (l * (K ^ 2.0))); else tmp = 0.3333333333333333 * (J * (l ^ 3.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.55e-6], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 320.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.5e+37], N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.55 \cdot 10^{-6}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\mathbf{elif}\;\ell \leq 320:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+37}:\\
\;\;\;\;U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if l < -1.55e-6Initial program 99.6%
Taylor expanded in l around 0 67.9%
Taylor expanded in K around 0 51.8%
Taylor expanded in J around inf 51.9%
if -1.55e-6 < l < 320Initial program 64.2%
Taylor expanded in l around 0 99.2%
if 320 < l < 2.49999999999999994e37Initial program 100.0%
Taylor expanded in l around 0 3.3%
Taylor expanded in K around 0 60.8%
Taylor expanded in K around inf 60.1%
associate-*r*60.1%
*-commutative60.1%
Simplified60.1%
if 2.49999999999999994e37 < l Initial program 100.0%
Taylor expanded in l around 0 76.0%
Taylor expanded in K around 0 58.5%
Taylor expanded in l around inf 58.6%
Final simplification73.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.55e-6) (not (<= l 9e-18))) (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) (+ U (* 2.0 (* J l)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.55e-6) || !(l <= 9e-18)) {
tmp = J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))));
} else {
tmp = U + (2.0 * (J * 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 ((l <= (-1.55d-6)) .or. (.not. (l <= 9d-18))) then
tmp = j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))
else
tmp = u + (2.0d0 * (j * l))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.55e-6) || !(l <= 9e-18)) {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
} else {
tmp = U + (2.0 * (J * l));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.55e-6) or not (l <= 9e-18): tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) else: tmp = U + (2.0 * (J * l)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.55e-6) || !(l <= 9e-18)) tmp = Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))); else tmp = Float64(U + Float64(2.0 * Float64(J * l))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.55e-6) || ~((l <= 9e-18))) tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); else tmp = U + (2.0 * (J * l)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.55e-6], N[Not[LessEqual[l, 9e-18]], $MachinePrecision]], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.55 \cdot 10^{-6} \lor \neg \left(\ell \leq 9 \cdot 10^{-18}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \ell\right)\\
\end{array}
\end{array}
if l < -1.55e-6 or 8.99999999999999987e-18 < l Initial program 98.8%
Taylor expanded in l around 0 67.3%
Taylor expanded in K around 0 51.2%
Taylor expanded in J around inf 51.3%
if -1.55e-6 < l < 8.99999999999999987e-18Initial program 64.6%
Taylor expanded in l around 0 99.9%
Taylor expanded in K around 0 79.6%
Final simplification62.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -6.9e+25) (not (<= l 4.3e+22))) (* 0.3333333333333333 (* J (pow l 3.0))) (+ U (* 2.0 (* J l)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6.9e+25) || !(l <= 4.3e+22)) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else {
tmp = U + (2.0 * (J * 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 ((l <= (-6.9d+25)) .or. (.not. (l <= 4.3d+22))) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else
tmp = u + (2.0d0 * (j * l))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6.9e+25) || !(l <= 4.3e+22)) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else {
tmp = U + (2.0 * (J * l));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -6.9e+25) or not (l <= 4.3e+22): tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) else: tmp = U + (2.0 * (J * l)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -6.9e+25) || !(l <= 4.3e+22)) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); else tmp = Float64(U + Float64(2.0 * Float64(J * l))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -6.9e+25) || ~((l <= 4.3e+22))) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); else tmp = U + (2.0 * (J * l)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6.9e+25], N[Not[LessEqual[l, 4.3e+22]], $MachinePrecision]], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.9 \cdot 10^{+25} \lor \neg \left(\ell \leq 4.3 \cdot 10^{+22}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \ell\right)\\
\end{array}
\end{array}
if l < -6.8999999999999998e25 or 4.3000000000000002e22 < l Initial program 100.0%
Taylor expanded in l around 0 72.4%
Taylor expanded in K around 0 55.2%
Taylor expanded in l around inf 55.4%
if -6.8999999999999998e25 < l < 4.3000000000000002e22Initial program 67.8%
Taylor expanded in l around 0 89.5%
Taylor expanded in K around 0 71.1%
Final simplification62.7%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J l))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * 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 + (2.0d0 * (j * l))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * l));
}
def code(J, l, K, U): return U + (2.0 * (J * l))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * l))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * l)); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \ell\right)
\end{array}
Initial program 84.9%
Taylor expanded in l around 0 58.7%
Taylor expanded in K around 0 46.6%
Final simplification46.6%
(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.9%
Applied egg-rr19.2%
Taylor expanded in J around 0 27.5%
(FPCore (J l K U) :precision binary64 0.125)
double code(double J, double l, double K, double U) {
return 0.125;
}
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 = 0.125d0
end function
public static double code(double J, double l, double K, double U) {
return 0.125;
}
def code(J, l, K, U): return 0.125
function code(J, l, K, U) return 0.125 end
function tmp = code(J, l, K, U) tmp = 0.125; end
code[J_, l_, K_, U_] := 0.125
\begin{array}{l}
\\
0.125
\end{array}
Initial program 84.9%
Taylor expanded in K around 0 70.1%
Applied egg-rr2.8%
(FPCore (J l K U) :precision binary64 0.037037037037037035)
double code(double J, double l, double K, double U) {
return 0.037037037037037035;
}
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 = 0.037037037037037035d0
end function
public static double code(double J, double l, double K, double U) {
return 0.037037037037037035;
}
def code(J, l, K, U): return 0.037037037037037035
function code(J, l, K, U) return 0.037037037037037035 end
function tmp = code(J, l, K, U) tmp = 0.037037037037037035; end
code[J_, l_, K_, U_] := 0.037037037037037035
\begin{array}{l}
\\
0.037037037037037035
\end{array}
Initial program 84.9%
Taylor expanded in K around 0 70.1%
Applied egg-rr2.8%
(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 84.9%
Taylor expanded in K around 0 70.1%
Applied egg-rr2.6%
herbie shell --seed 2024096
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))