
(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 19 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 85.9%
Taylor expanded in l around 0 71.1%
log1p-expm1-u99.6%
*-commutative99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* J (- (exp l) (exp (- l))))))
(if (<= l -1.9e+123)
(+ U (* (* (* J 0.3333333333333333) (pow l 3.0)) t_0))
(if (<= l -110.0)
t_1
(if (or (<= l 0.00069) (not (<= l 2.9e+84)))
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 2.0 l)))))
(+ U t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = J * (exp(l) - exp(-l));
double tmp;
if (l <= -1.9e+123) {
tmp = U + (((J * 0.3333333333333333) * pow(l, 3.0)) * t_0);
} else if (l <= -110.0) {
tmp = t_1;
} else if ((l <= 0.00069) || !(l <= 2.9e+84)) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (2.0 * l))));
} else {
tmp = U + 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) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = j * (exp(l) - exp(-l))
if (l <= (-1.9d+123)) then
tmp = u + (((j * 0.3333333333333333d0) * (l ** 3.0d0)) * t_0)
else if (l <= (-110.0d0)) then
tmp = t_1
else if ((l <= 0.00069d0) .or. (.not. (l <= 2.9d+84))) then
tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (2.0d0 * l))))
else
tmp = u + 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 = J * (Math.exp(l) - Math.exp(-l));
double tmp;
if (l <= -1.9e+123) {
tmp = U + (((J * 0.3333333333333333) * Math.pow(l, 3.0)) * t_0);
} else if (l <= -110.0) {
tmp = t_1;
} else if ((l <= 0.00069) || !(l <= 2.9e+84)) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (2.0 * l))));
} else {
tmp = U + t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = J * (math.exp(l) - math.exp(-l)) tmp = 0 if l <= -1.9e+123: tmp = U + (((J * 0.3333333333333333) * math.pow(l, 3.0)) * t_0) elif l <= -110.0: tmp = t_1 elif (l <= 0.00069) or not (l <= 2.9e+84): tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (2.0 * l)))) else: tmp = U + t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if (l <= -1.9e+123) tmp = Float64(U + Float64(Float64(Float64(J * 0.3333333333333333) * (l ^ 3.0)) * t_0)); elseif (l <= -110.0) tmp = t_1; elseif ((l <= 0.00069) || !(l <= 2.9e+84)) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(2.0 * l))))); else tmp = Float64(U + t_1); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = J * (exp(l) - exp(-l)); tmp = 0.0; if (l <= -1.9e+123) tmp = U + (((J * 0.3333333333333333) * (l ^ 3.0)) * t_0); elseif (l <= -110.0) tmp = t_1; elseif ((l <= 0.00069) || ~((l <= 2.9e+84))) tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (2.0 * l)))); else tmp = U + 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[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e+123], N[(U + N[(N[(N[(J * 0.3333333333333333), $MachinePrecision] * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -110.0], t$95$1, If[Or[LessEqual[l, 0.00069], N[Not[LessEqual[l, 2.9e+84]], $MachinePrecision]], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+123}:\\
\;\;\;\;U + \left(\left(J \cdot 0.3333333333333333\right) \cdot {\ell}^{3}\right) \cdot t_0\\
\mathbf{elif}\;\ell \leq -110:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.00069 \lor \neg \left(\ell \leq 2.9 \cdot 10^{+84}\right):\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t_1\\
\end{array}
\end{array}
if l < -1.89999999999999997e123Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
associate-*r*100.0%
Simplified100.0%
if -1.89999999999999997e123 < l < -110Initial program 100.0%
Taylor expanded in K around 0 81.5%
Taylor expanded in J around inf 81.5%
if -110 < l < 6.89999999999999967e-4 or 2.89999999999999989e84 < l Initial program 79.6%
Taylor expanded in l around 0 98.8%
if 6.89999999999999967e-4 < l < 2.89999999999999989e84Initial program 100.0%
Taylor expanded in K around 0 73.3%
Final simplification95.7%
(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 -1.9e+123)
t_1
(if (<= l -0.00035)
t_2
(if (<= l 4.4e-47)
(+ U (* t_0 (* l (* 2.0 J))))
(if (<= l 2.9e+84) (+ U 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 <= -1.9e+123) {
tmp = t_1;
} else if (l <= -0.00035) {
tmp = t_2;
} else if (l <= 4.4e-47) {
tmp = U + (t_0 * (l * (2.0 * J)));
} else if (l <= 2.9e+84) {
tmp = U + 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 <= (-1.9d+123)) then
tmp = t_1
else if (l <= (-0.00035d0)) then
tmp = t_2
else if (l <= 4.4d-47) then
tmp = u + (t_0 * (l * (2.0d0 * j)))
else if (l <= 2.9d+84) then
tmp = u + 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 <= -1.9e+123) {
tmp = t_1;
} else if (l <= -0.00035) {
tmp = t_2;
} else if (l <= 4.4e-47) {
tmp = U + (t_0 * (l * (2.0 * J)));
} else if (l <= 2.9e+84) {
tmp = U + 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 <= -1.9e+123: tmp = t_1 elif l <= -0.00035: tmp = t_2 elif l <= 4.4e-47: tmp = U + (t_0 * (l * (2.0 * J))) elif l <= 2.9e+84: tmp = U + 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(Float64(J * 0.3333333333333333) * (l ^ 3.0)) * t_0)) t_2 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if (l <= -1.9e+123) tmp = t_1; elseif (l <= -0.00035) tmp = t_2; elseif (l <= 4.4e-47) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(2.0 * J)))); elseif (l <= 2.9e+84) tmp = Float64(U + 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 <= -1.9e+123) tmp = t_1; elseif (l <= -0.00035) tmp = t_2; elseif (l <= 4.4e-47) tmp = U + (t_0 * (l * (2.0 * J))); elseif (l <= 2.9e+84) tmp = U + 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[(N[(J * 0.3333333333333333), $MachinePrecision] * N[Power[l, 3.0], $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, -1.9e+123], t$95$1, If[LessEqual[l, -0.00035], t$95$2, If[LessEqual[l, 4.4e-47], N[(U + N[(t$95$0 * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.9e+84], N[(U + t$95$2), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + \left(\left(J \cdot 0.3333333333333333\right) \cdot {\ell}^{3}\right) \cdot t_0\\
t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+123}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.00035:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 4.4 \cdot 10^{-47}:\\
\;\;\;\;U + t_0 \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\
\mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+84}:\\
\;\;\;\;U + t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -1.89999999999999997e123 or 2.89999999999999989e84 < l Initial program 100.0%
Taylor expanded in l around 0 97.6%
Taylor expanded in l around inf 97.6%
associate-*r*97.6%
Simplified97.6%
if -1.89999999999999997e123 < l < -3.49999999999999996e-4Initial program 99.4%
Taylor expanded in K around 0 81.6%
Taylor expanded in J around inf 81.6%
if -3.49999999999999996e-4 < l < 4.40000000000000037e-47Initial program 71.1%
Taylor expanded in l around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
Simplified99.9%
if 4.40000000000000037e-47 < l < 2.89999999999999989e84Initial program 99.3%
Taylor expanded in K around 0 83.3%
Final simplification95.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.522)
(+ U (* t_0 (* l (* 2.0 J))))
(+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 2.0 l)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.522) {
tmp = U + (t_0 * (l * (2.0 * J)));
} else {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (2.0 * 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) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= 0.522d0) then
tmp = u + (t_0 * (l * (2.0d0 * j)))
else
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (2.0d0 * 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 tmp;
if (t_0 <= 0.522) {
tmp = U + (t_0 * (l * (2.0 * J)));
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (2.0 * l)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.522: tmp = U + (t_0 * (l * (2.0 * J))) else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (2.0 * l))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.522) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(2.0 * J)))); else tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(2.0 * l)))); 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.522) tmp = U + (t_0 * (l * (2.0 * J))); else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (2.0 * l))); 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.522], N[(U + N[(t$95$0 * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.522:\\
\;\;\;\;U + t_0 \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.52200000000000002Initial program 81.4%
Taylor expanded in l around 0 71.0%
associate-*r*71.0%
*-commutative71.0%
Simplified71.0%
if 0.52200000000000002 < (cos.f64 (/.f64 K 2)) Initial program 88.2%
Taylor expanded in l around 0 89.2%
Taylor expanded in K around 0 87.4%
Final simplification81.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (- (exp l) (exp (- l))))))
(if (<= l -0.00035)
t_0
(if (<= l 220.0)
(+ U (* (cos (/ K 2.0)) (* l (* 2.0 J))))
(if (<= l 2.4e+89)
t_0
(+ U (* 2.0 (* J (+ l (* -0.125 (* l (pow K 2.0))))))))))))
double code(double J, double l, double K, double U) {
double t_0 = J * (exp(l) - exp(-l));
double tmp;
if (l <= -0.00035) {
tmp = t_0;
} else if (l <= 220.0) {
tmp = U + (cos((K / 2.0)) * (l * (2.0 * J)));
} else if (l <= 2.4e+89) {
tmp = t_0;
} else {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * pow(K, 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 = j * (exp(l) - exp(-l))
if (l <= (-0.00035d0)) then
tmp = t_0
else if (l <= 220.0d0) then
tmp = u + (cos((k / 2.0d0)) * (l * (2.0d0 * j)))
else if (l <= 2.4d+89) then
tmp = t_0
else
tmp = u + (2.0d0 * (j * (l + ((-0.125d0) * (l * (k ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (Math.exp(l) - Math.exp(-l));
double tmp;
if (l <= -0.00035) {
tmp = t_0;
} else if (l <= 220.0) {
tmp = U + (Math.cos((K / 2.0)) * (l * (2.0 * J)));
} else if (l <= 2.4e+89) {
tmp = t_0;
} else {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * Math.pow(K, 2.0))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (math.exp(l) - math.exp(-l)) tmp = 0 if l <= -0.00035: tmp = t_0 elif l <= 220.0: tmp = U + (math.cos((K / 2.0)) * (l * (2.0 * J))) elif l <= 2.4e+89: tmp = t_0 else: tmp = U + (2.0 * (J * (l + (-0.125 * (l * math.pow(K, 2.0)))))) return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if (l <= -0.00035) tmp = t_0; elseif (l <= 220.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(2.0 * J)))); elseif (l <= 2.4e+89) tmp = t_0; else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * (K ^ 2.0))))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (exp(l) - exp(-l)); tmp = 0.0; if (l <= -0.00035) tmp = t_0; elseif (l <= 220.0) tmp = U + (cos((K / 2.0)) * (l * (2.0 * J))); elseif (l <= 2.4e+89) tmp = t_0; else tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K ^ 2.0)))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -0.00035], t$95$0, If[LessEqual[l, 220.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+89], t$95$0, N[(U + N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -0.00035:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 220:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\
\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot {K}^{2}\right)\right)\right)\\
\end{array}
\end{array}
if l < -3.49999999999999996e-4 or 220 < l < 2.40000000000000004e89Initial program 99.8%
Taylor expanded in K around 0 77.3%
Taylor expanded in J around inf 77.3%
if -3.49999999999999996e-4 < l < 220Initial program 73.4%
Taylor expanded in l around 0 99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
if 2.40000000000000004e89 < l Initial program 100.0%
Taylor expanded in l around 0 48.8%
Taylor expanded in K around 0 67.1%
Final simplification87.4%
(FPCore (J l K U) :precision binary64 (if (or (<= J -2.6e+80) (not (<= J 5.8e+43))) (+ U (* (cos (/ K 2.0)) (* l (* 2.0 J)))) (+ U (* J (- (exp l) (exp (- l)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((J <= -2.6e+80) || !(J <= 5.8e+43)) {
tmp = U + (cos((K / 2.0)) * (l * (2.0 * J)));
} else {
tmp = U + (J * (exp(l) - exp(-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 ((j <= (-2.6d+80)) .or. (.not. (j <= 5.8d+43))) then
tmp = u + (cos((k / 2.0d0)) * (l * (2.0d0 * j)))
else
tmp = u + (j * (exp(l) - exp(-l)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((J <= -2.6e+80) || !(J <= 5.8e+43)) {
tmp = U + (Math.cos((K / 2.0)) * (l * (2.0 * J)));
} else {
tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (J <= -2.6e+80) or not (J <= 5.8e+43): tmp = U + (math.cos((K / 2.0)) * (l * (2.0 * J))) else: tmp = U + (J * (math.exp(l) - math.exp(-l))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((J <= -2.6e+80) || !(J <= 5.8e+43)) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(2.0 * J)))); else tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((J <= -2.6e+80) || ~((J <= 5.8e+43))) tmp = U + (cos((K / 2.0)) * (l * (2.0 * J))); else tmp = U + (J * (exp(l) - exp(-l))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[J, -2.6e+80], N[Not[LessEqual[J, 5.8e+43]], $MachinePrecision]], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.6 \cdot 10^{+80} \lor \neg \left(J \leq 5.8 \cdot 10^{+43}\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\end{array}
\end{array}
if J < -2.59999999999999982e80 or 5.8000000000000004e43 < J Initial program 73.1%
Taylor expanded in l around 0 92.7%
associate-*r*92.7%
*-commutative92.7%
Simplified92.7%
if -2.59999999999999982e80 < J < 5.8000000000000004e43Initial program 94.3%
Taylor expanded in K around 0 82.7%
Final simplification86.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))))
(if (<= l -4e+91)
t_0
(if (<= l -4150000000000.0)
(fabs (* U (+ U 4.0)))
(if (or (<= l 1.2e+107) (not (<= l 1.5e+261)))
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
double tmp;
if (l <= -4e+91) {
tmp = t_0;
} else if (l <= -4150000000000.0) {
tmp = fabs((U * (U + 4.0)));
} else if ((l <= 1.2e+107) || !(l <= 1.5e+261)) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = 0.3333333333333333d0 * (j * (l ** 3.0d0))
if (l <= (-4d+91)) then
tmp = t_0
else if (l <= (-4150000000000.0d0)) then
tmp = abs((u * (u + 4.0d0)))
else if ((l <= 1.2d+107) .or. (.not. (l <= 1.5d+261))) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = 0.3333333333333333 * (J * Math.pow(l, 3.0));
double tmp;
if (l <= -4e+91) {
tmp = t_0;
} else if (l <= -4150000000000.0) {
tmp = Math.abs((U * (U + 4.0)));
} else if ((l <= 1.2e+107) || !(l <= 1.5e+261)) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = 0.3333333333333333 * (J * math.pow(l, 3.0)) tmp = 0 if l <= -4e+91: tmp = t_0 elif l <= -4150000000000.0: tmp = math.fabs((U * (U + 4.0))) elif (l <= 1.2e+107) or not (l <= 1.5e+261): tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) tmp = 0.0 if (l <= -4e+91) tmp = t_0; elseif (l <= -4150000000000.0) tmp = abs(Float64(U * Float64(U + 4.0))); elseif ((l <= 1.2e+107) || !(l <= 1.5e+261)) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = 0.3333333333333333 * (J * (l ^ 3.0)); tmp = 0.0; if (l <= -4e+91) tmp = t_0; elseif (l <= -4150000000000.0) tmp = abs((U * (U + 4.0))); elseif ((l <= 1.2e+107) || ~((l <= 1.5e+261))) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -4150000000000.0], N[Abs[N[(U * N[(U + 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[l, 1.2e+107], N[Not[LessEqual[l, 1.5e+261]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -4150000000000:\\
\;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\
\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107} \lor \neg \left(\ell \leq 1.5 \cdot 10^{+261}\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -4.00000000000000032e91 or 1.2e107 < l < 1.49999999999999989e261Initial program 100.0%
Taylor expanded in l around 0 98.7%
Taylor expanded in K around 0 74.0%
Taylor expanded in l around inf 74.0%
*-commutative74.0%
Simplified74.0%
if -4.00000000000000032e91 < l < -4.15e12Initial program 100.0%
Applied egg-rr39.3%
add-sqr-sqrt39.2%
sqrt-unprod39.3%
pow239.3%
*-un-lft-identity39.3%
sub-neg39.3%
*-un-lft-identity39.3%
metadata-eval39.3%
Applied egg-rr39.3%
unpow239.3%
rem-sqrt-square39.4%
+-commutative39.4%
Simplified39.4%
if -4.15e12 < l < 1.2e107 or 1.49999999999999989e261 < l Initial program 78.8%
Taylor expanded in l around 0 85.9%
Final simplification80.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))) (t_1 (cos (* K 0.5))))
(if (<= l -4e+91)
t_0
(if (<= l -14600000000000.0)
(fabs (* U (+ U 4.0)))
(if (<= l 1.2e+107)
(+ U (* l (* (* 2.0 J) t_1)))
(if (<= l 1.5e+261) t_0 (+ U (* 2.0 (* J (* l t_1))))))))))
double code(double J, double l, double K, double U) {
double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
double t_1 = cos((K * 0.5));
double tmp;
if (l <= -4e+91) {
tmp = t_0;
} else if (l <= -14600000000000.0) {
tmp = fabs((U * (U + 4.0)));
} else if (l <= 1.2e+107) {
tmp = U + (l * ((2.0 * J) * t_1));
} else if (l <= 1.5e+261) {
tmp = t_0;
} else {
tmp = U + (2.0 * (J * (l * 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) :: tmp
t_0 = 0.3333333333333333d0 * (j * (l ** 3.0d0))
t_1 = cos((k * 0.5d0))
if (l <= (-4d+91)) then
tmp = t_0
else if (l <= (-14600000000000.0d0)) then
tmp = abs((u * (u + 4.0d0)))
else if (l <= 1.2d+107) then
tmp = u + (l * ((2.0d0 * j) * t_1))
else if (l <= 1.5d+261) then
tmp = t_0
else
tmp = u + (2.0d0 * (j * (l * t_1)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = 0.3333333333333333 * (J * Math.pow(l, 3.0));
double t_1 = Math.cos((K * 0.5));
double tmp;
if (l <= -4e+91) {
tmp = t_0;
} else if (l <= -14600000000000.0) {
tmp = Math.abs((U * (U + 4.0)));
} else if (l <= 1.2e+107) {
tmp = U + (l * ((2.0 * J) * t_1));
} else if (l <= 1.5e+261) {
tmp = t_0;
} else {
tmp = U + (2.0 * (J * (l * t_1)));
}
return tmp;
}
def code(J, l, K, U): t_0 = 0.3333333333333333 * (J * math.pow(l, 3.0)) t_1 = math.cos((K * 0.5)) tmp = 0 if l <= -4e+91: tmp = t_0 elif l <= -14600000000000.0: tmp = math.fabs((U * (U + 4.0))) elif l <= 1.2e+107: tmp = U + (l * ((2.0 * J) * t_1)) elif l <= 1.5e+261: tmp = t_0 else: tmp = U + (2.0 * (J * (l * t_1))) return tmp
function code(J, l, K, U) t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) t_1 = cos(Float64(K * 0.5)) tmp = 0.0 if (l <= -4e+91) tmp = t_0; elseif (l <= -14600000000000.0) tmp = abs(Float64(U * Float64(U + 4.0))); elseif (l <= 1.2e+107) tmp = Float64(U + Float64(l * Float64(Float64(2.0 * J) * t_1))); elseif (l <= 1.5e+261) tmp = t_0; else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_1)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = 0.3333333333333333 * (J * (l ^ 3.0)); t_1 = cos((K * 0.5)); tmp = 0.0; if (l <= -4e+91) tmp = t_0; elseif (l <= -14600000000000.0) tmp = abs((U * (U + 4.0))); elseif (l <= 1.2e+107) tmp = U + (l * ((2.0 * J) * t_1)); elseif (l <= 1.5e+261) tmp = t_0; else tmp = U + (2.0 * (J * (l * t_1))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -14600000000000.0], N[Abs[N[(U * N[(U + 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 1.2e+107], N[(U + N[(l * N[(N[(2.0 * J), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.5e+261], t$95$0, N[(U + N[(2.0 * N[(J * N[(l * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
t_1 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -14600000000000:\\
\;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\
\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\
\;\;\;\;U + \ell \cdot \left(\left(2 \cdot J\right) \cdot t_1\right)\\
\mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+261}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_1\right)\right)\\
\end{array}
\end{array}
if l < -4.00000000000000032e91 or 1.2e107 < l < 1.49999999999999989e261Initial program 100.0%
Taylor expanded in l around 0 98.7%
Taylor expanded in K around 0 74.0%
Taylor expanded in l around inf 74.0%
*-commutative74.0%
Simplified74.0%
if -4.00000000000000032e91 < l < -1.46e13Initial program 100.0%
Applied egg-rr39.3%
add-sqr-sqrt39.2%
sqrt-unprod39.3%
pow239.3%
*-un-lft-identity39.3%
sub-neg39.3%
*-un-lft-identity39.3%
metadata-eval39.3%
Applied egg-rr39.3%
unpow239.3%
rem-sqrt-square39.4%
+-commutative39.4%
Simplified39.4%
if -1.46e13 < l < 1.2e107Initial program 77.3%
Taylor expanded in l around 0 86.7%
associate-*r*86.7%
*-commutative86.7%
associate-*l*86.7%
Simplified86.7%
if 1.49999999999999989e261 < l Initial program 100.0%
Taylor expanded in l around 0 73.9%
Final simplification80.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))))
(if (<= l -4e+91)
t_0
(if (<= l -8.4e+14)
(fabs (* U (+ U 4.0)))
(if (<= l 1.2e+107)
(+ U (* (cos (/ K 2.0)) (* l (* 2.0 J))))
(if (<= l 1.35e+261)
t_0
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))))))
double code(double J, double l, double K, double U) {
double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
double tmp;
if (l <= -4e+91) {
tmp = t_0;
} else if (l <= -8.4e+14) {
tmp = fabs((U * (U + 4.0)));
} else if (l <= 1.2e+107) {
tmp = U + (cos((K / 2.0)) * (l * (2.0 * J)));
} else if (l <= 1.35e+261) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 0.3333333333333333d0 * (j * (l ** 3.0d0))
if (l <= (-4d+91)) then
tmp = t_0
else if (l <= (-8.4d+14)) then
tmp = abs((u * (u + 4.0d0)))
else if (l <= 1.2d+107) then
tmp = u + (cos((k / 2.0d0)) * (l * (2.0d0 * j)))
else if (l <= 1.35d+261) then
tmp = t_0
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 t_0 = 0.3333333333333333 * (J * Math.pow(l, 3.0));
double tmp;
if (l <= -4e+91) {
tmp = t_0;
} else if (l <= -8.4e+14) {
tmp = Math.abs((U * (U + 4.0)));
} else if (l <= 1.2e+107) {
tmp = U + (Math.cos((K / 2.0)) * (l * (2.0 * J)));
} else if (l <= 1.35e+261) {
tmp = t_0;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = 0.3333333333333333 * (J * math.pow(l, 3.0)) tmp = 0 if l <= -4e+91: tmp = t_0 elif l <= -8.4e+14: tmp = math.fabs((U * (U + 4.0))) elif l <= 1.2e+107: tmp = U + (math.cos((K / 2.0)) * (l * (2.0 * J))) elif l <= 1.35e+261: tmp = t_0 else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) tmp = 0.0 if (l <= -4e+91) tmp = t_0; elseif (l <= -8.4e+14) tmp = abs(Float64(U * Float64(U + 4.0))); elseif (l <= 1.2e+107) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(2.0 * J)))); elseif (l <= 1.35e+261) tmp = t_0; 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) t_0 = 0.3333333333333333 * (J * (l ^ 3.0)); tmp = 0.0; if (l <= -4e+91) tmp = t_0; elseif (l <= -8.4e+14) tmp = abs((U * (U + 4.0))); elseif (l <= 1.2e+107) tmp = U + (cos((K / 2.0)) * (l * (2.0 * J))); elseif (l <= 1.35e+261) tmp = t_0; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -8.4e+14], N[Abs[N[(U * N[(U + 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 1.2e+107], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.35e+261], t$95$0, 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}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -8.4 \cdot 10^{+14}:\\
\;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\
\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\
\mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+261}:\\
\;\;\;\;t_0\\
\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 < -4.00000000000000032e91 or 1.2e107 < l < 1.35000000000000001e261Initial program 100.0%
Taylor expanded in l around 0 98.7%
Taylor expanded in K around 0 74.0%
Taylor expanded in l around inf 74.0%
*-commutative74.0%
Simplified74.0%
if -4.00000000000000032e91 < l < -8.4e14Initial program 100.0%
Applied egg-rr39.3%
add-sqr-sqrt39.2%
sqrt-unprod39.3%
pow239.3%
*-un-lft-identity39.3%
sub-neg39.3%
*-un-lft-identity39.3%
metadata-eval39.3%
Applied egg-rr39.3%
unpow239.3%
rem-sqrt-square39.4%
+-commutative39.4%
Simplified39.4%
if -8.4e14 < l < 1.2e107Initial program 77.3%
Taylor expanded in l around 0 86.8%
associate-*r*86.8%
*-commutative86.8%
Simplified86.8%
if 1.35000000000000001e261 < l Initial program 100.0%
Taylor expanded in l around 0 73.9%
Final simplification80.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))))
(if (<= l -4e+91)
t_0
(if (<= l -170000.0)
(* U (- U -4.0))
(if (<= l 7600000.0) (fma (* 2.0 J) l U) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
double tmp;
if (l <= -4e+91) {
tmp = t_0;
} else if (l <= -170000.0) {
tmp = U * (U - -4.0);
} else if (l <= 7600000.0) {
tmp = fma((2.0 * J), l, U);
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) tmp = 0.0 if (l <= -4e+91) tmp = t_0; elseif (l <= -170000.0) tmp = Float64(U * Float64(U - -4.0)); elseif (l <= 7600000.0) tmp = fma(Float64(2.0 * J), l, U); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -170000.0], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7600000.0], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -170000:\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\mathbf{elif}\;\ell \leq 7600000:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -4.00000000000000032e91 or 7.6e6 < l Initial program 100.0%
Taylor expanded in l around 0 86.1%
Taylor expanded in K around 0 59.1%
Taylor expanded in l around inf 59.1%
*-commutative59.1%
Simplified59.1%
if -4.00000000000000032e91 < l < -1.7e5Initial program 100.0%
Applied egg-rr34.5%
if -1.7e5 < l < 7.6e6Initial program 73.7%
Taylor expanded in l around 0 98.6%
Taylor expanded in K around 0 84.9%
Taylor expanded in J around 0 84.9%
+-commutative84.9%
associate-*r*84.9%
fma-def84.9%
Simplified84.9%
Final simplification71.5%
(FPCore (J l K U) :precision binary64 (fma (* 2.0 J) l U))
double code(double J, double l, double K, double U) {
return fma((2.0 * J), l, U);
}
function code(J, l, K, U) return fma(Float64(2.0 * J), l, U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2 \cdot J, \ell, U\right)
\end{array}
Initial program 85.9%
Taylor expanded in l around 0 71.1%
Taylor expanded in K around 0 57.7%
Taylor expanded in J around 0 57.7%
+-commutative57.7%
associate-*r*57.7%
fma-def57.7%
Simplified57.7%
Final simplification57.7%
(FPCore (J l K U) :precision binary64 (if (<= l -3.4e+110) (* U (- 16.0 U)) (if (<= l -132000.0) (* U U) (if (<= l 1.4e+70) U (* U (+ U -16.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3.4e+110) {
tmp = U * (16.0 - U);
} else if (l <= -132000.0) {
tmp = U * U;
} else if (l <= 1.4e+70) {
tmp = U;
} else {
tmp = U * (U + -16.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 <= (-3.4d+110)) then
tmp = u * (16.0d0 - u)
else if (l <= (-132000.0d0)) then
tmp = u * u
else if (l <= 1.4d+70) then
tmp = u
else
tmp = u * (u + (-16.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3.4e+110) {
tmp = U * (16.0 - U);
} else if (l <= -132000.0) {
tmp = U * U;
} else if (l <= 1.4e+70) {
tmp = U;
} else {
tmp = U * (U + -16.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -3.4e+110: tmp = U * (16.0 - U) elif l <= -132000.0: tmp = U * U elif l <= 1.4e+70: tmp = U else: tmp = U * (U + -16.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -3.4e+110) tmp = Float64(U * Float64(16.0 - U)); elseif (l <= -132000.0) tmp = Float64(U * U); elseif (l <= 1.4e+70) tmp = U; else tmp = Float64(U * Float64(U + -16.0)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -3.4e+110) tmp = U * (16.0 - U); elseif (l <= -132000.0) tmp = U * U; elseif (l <= 1.4e+70) tmp = U; else tmp = U * (U + -16.0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -3.4e+110], N[(U * N[(16.0 - U), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -132000.0], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.4e+70], U, N[(U * N[(U + -16.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.4 \cdot 10^{+110}:\\
\;\;\;\;U \cdot \left(16 - U\right)\\
\mathbf{elif}\;\ell \leq -132000:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+70}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(U + -16\right)\\
\end{array}
\end{array}
if l < -3.4000000000000001e110Initial program 100.0%
Taylor expanded in l around 0 53.3%
Taylor expanded in K around 0 41.4%
Applied egg-rr22.3%
+-commutative22.3%
distribute-neg-in22.3%
metadata-eval22.3%
sub-neg22.3%
Simplified22.3%
if -3.4000000000000001e110 < l < -132000Initial program 100.0%
Applied egg-rr31.6%
if -132000 < l < 1.39999999999999995e70Initial program 75.8%
Taylor expanded in J around 0 65.8%
if 1.39999999999999995e70 < l Initial program 100.0%
Taylor expanded in l around 0 48.0%
Taylor expanded in K around 0 24.3%
Applied egg-rr15.5%
Final simplification47.2%
(FPCore (J l K U) :precision binary64 (if (<= l -3.7e+110) (* U (/ U -3.0)) (if (<= l -132000.0) (* U U) (if (<= l 5.7e+66) U (* U (+ U -16.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3.7e+110) {
tmp = U * (U / -3.0);
} else if (l <= -132000.0) {
tmp = U * U;
} else if (l <= 5.7e+66) {
tmp = U;
} else {
tmp = U * (U + -16.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 <= (-3.7d+110)) then
tmp = u * (u / (-3.0d0))
else if (l <= (-132000.0d0)) then
tmp = u * u
else if (l <= 5.7d+66) then
tmp = u
else
tmp = u * (u + (-16.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3.7e+110) {
tmp = U * (U / -3.0);
} else if (l <= -132000.0) {
tmp = U * U;
} else if (l <= 5.7e+66) {
tmp = U;
} else {
tmp = U * (U + -16.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -3.7e+110: tmp = U * (U / -3.0) elif l <= -132000.0: tmp = U * U elif l <= 5.7e+66: tmp = U else: tmp = U * (U + -16.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -3.7e+110) tmp = Float64(U * Float64(U / -3.0)); elseif (l <= -132000.0) tmp = Float64(U * U); elseif (l <= 5.7e+66) tmp = U; else tmp = Float64(U * Float64(U + -16.0)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -3.7e+110) tmp = U * (U / -3.0); elseif (l <= -132000.0) tmp = U * U; elseif (l <= 5.7e+66) tmp = U; else tmp = U * (U + -16.0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -3.7e+110], N[(U * N[(U / -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -132000.0], N[(U * U), $MachinePrecision], If[LessEqual[l, 5.7e+66], U, N[(U * N[(U + -16.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.7 \cdot 10^{+110}:\\
\;\;\;\;U \cdot \frac{U}{-3}\\
\mathbf{elif}\;\ell \leq -132000:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 5.7 \cdot 10^{+66}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(U + -16\right)\\
\end{array}
\end{array}
if l < -3.70000000000000012e110Initial program 100.0%
Taylor expanded in l around 0 53.3%
Taylor expanded in K around 0 41.4%
Applied egg-rr22.5%
if -3.70000000000000012e110 < l < -132000Initial program 100.0%
Applied egg-rr31.6%
if -132000 < l < 5.7000000000000003e66Initial program 75.8%
Taylor expanded in J around 0 65.8%
if 5.7000000000000003e66 < l Initial program 100.0%
Taylor expanded in l around 0 48.0%
Taylor expanded in K around 0 24.3%
Applied egg-rr15.5%
Final simplification47.2%
(FPCore (J l K U) :precision binary64 (if (<= l -4.3e+110) (* U (- 16.0 U)) (if (or (<= l -132000.0) (not (<= l 3.1e+66))) (* U U) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.3e+110) {
tmp = U * (16.0 - U);
} else if ((l <= -132000.0) || !(l <= 3.1e+66)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-4.3d+110)) then
tmp = u * (16.0d0 - u)
else if ((l <= (-132000.0d0)) .or. (.not. (l <= 3.1d+66))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.3e+110) {
tmp = U * (16.0 - U);
} else if ((l <= -132000.0) || !(l <= 3.1e+66)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -4.3e+110: tmp = U * (16.0 - U) elif (l <= -132000.0) or not (l <= 3.1e+66): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -4.3e+110) tmp = Float64(U * Float64(16.0 - U)); elseif ((l <= -132000.0) || !(l <= 3.1e+66)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -4.3e+110) tmp = U * (16.0 - U); elseif ((l <= -132000.0) || ~((l <= 3.1e+66))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -4.3e+110], N[(U * N[(16.0 - U), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, -132000.0], N[Not[LessEqual[l, 3.1e+66]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.3 \cdot 10^{+110}:\\
\;\;\;\;U \cdot \left(16 - U\right)\\
\mathbf{elif}\;\ell \leq -132000 \lor \neg \left(\ell \leq 3.1 \cdot 10^{+66}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -4.30000000000000007e110Initial program 100.0%
Taylor expanded in l around 0 53.3%
Taylor expanded in K around 0 41.4%
Applied egg-rr22.3%
+-commutative22.3%
distribute-neg-in22.3%
metadata-eval22.3%
sub-neg22.3%
Simplified22.3%
if -4.30000000000000007e110 < l < -132000 or 3.10000000000000019e66 < l Initial program 100.0%
Applied egg-rr20.5%
if -132000 < l < 3.10000000000000019e66Initial program 75.8%
Taylor expanded in J around 0 65.8%
Final simplification47.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -155000.0) (not (<= l 3.1e+66))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -155000.0) || !(l <= 3.1e+66)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-155000.0d0)) .or. (.not. (l <= 3.1d+66))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -155000.0) || !(l <= 3.1e+66)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -155000.0) or not (l <= 3.1e+66): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -155000.0) || !(l <= 3.1e+66)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -155000.0) || ~((l <= 3.1e+66))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -155000.0], N[Not[LessEqual[l, 3.1e+66]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -155000 \lor \neg \left(\ell \leq 3.1 \cdot 10^{+66}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -155000 or 3.10000000000000019e66 < l Initial program 100.0%
Applied egg-rr14.7%
if -155000 < l < 3.10000000000000019e66Initial program 75.8%
Taylor expanded in J around 0 65.8%
Final simplification44.5%
(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 85.9%
Taylor expanded in l around 0 71.1%
Taylor expanded in K around 0 57.7%
Final simplification57.7%
(FPCore (J l K U) :precision binary64 -15.0)
double code(double J, double l, double K, double U) {
return -15.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 = -15.0d0
end function
public static double code(double J, double l, double K, double U) {
return -15.0;
}
def code(J, l, K, U): return -15.0
function code(J, l, K, U) return -15.0 end
function tmp = code(J, l, K, U) tmp = -15.0; end
code[J_, l_, K_, U_] := -15.0
\begin{array}{l}
\\
-15
\end{array}
Initial program 85.9%
Taylor expanded in l around 0 71.1%
Taylor expanded in K around 0 57.7%
Applied egg-rr2.9%
associate-*l/2.9%
+-commutative2.9%
associate-+r-2.9%
distribute-lft-in2.9%
metadata-eval2.9%
*-commutative2.9%
cancel-sign-sub-inv2.9%
metadata-eval2.9%
distribute-lft-in2.9%
associate-*r*2.9%
distribute-rgt-out2.9%
metadata-eval2.9%
metadata-eval2.9%
Simplified2.9%
Taylor expanded in U around inf 2.9%
Final simplification2.9%
(FPCore (J l K U) :precision binary64 -0.3333333333333333)
double code(double J, double l, double K, double U) {
return -0.3333333333333333;
}
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.3333333333333333d0
end function
public static double code(double J, double l, double K, double U) {
return -0.3333333333333333;
}
def code(J, l, K, U): return -0.3333333333333333
function code(J, l, K, U) return -0.3333333333333333 end
function tmp = code(J, l, K, U) tmp = -0.3333333333333333; end
code[J_, l_, K_, U_] := -0.3333333333333333
\begin{array}{l}
\\
-0.3333333333333333
\end{array}
Initial program 85.9%
Taylor expanded in l around 0 71.1%
Taylor expanded in K around 0 57.7%
Applied egg-rr2.9%
associate-/l/2.9%
associate-/r*2.9%
*-inverses2.9%
metadata-eval2.9%
Simplified2.9%
Final simplification2.9%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 85.9%
Taylor expanded in J around 0 39.3%
Final simplification39.3%
herbie shell --seed 2023330
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))