
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 0.001)))
(+ (* (* t_1 J) t_0) U)
(+
U
(* t_0 (+ (* J (* l 2.0)) (* 0.3333333333333333 (* J (pow l 3.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 0.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((J * (l * 2.0)) + (0.3333333333333333 * (J * pow(l, 3.0)))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 0.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((J * (l * 2.0)) + (0.3333333333333333 * (J * Math.pow(l, 3.0)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 0.001): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * ((J * (l * 2.0)) + (0.3333333333333333 * (J * math.pow(l, 3.0))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 0.001)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(Float64(J * Float64(l * 2.0)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 0.001))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * ((J * (l * 2.0)) + (0.3333333333333333 * (J * (l ^ 3.0))))); 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[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 0.001]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 0.001\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3Initial program 67.7%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.001)))
(+ (* t_0 J) U)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.001)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.001)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 0.001): tmp = (t_0 * J) + U else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.001)) tmp = Float64(Float64(t_0 * J) + U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 0.001))) tmp = (t_0 * J) + U; else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(N[(t$95$0 * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;t_0 \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 69.2%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3Initial program 67.7%
Taylor expanded in l around 0 99.5%
Final simplification85.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (* (pow l 3.0) t_0) (* J 0.3333333333333333)))))
(if (<= l -1.7e+48)
t_1
(if (<= l -95.0)
(+ U (log1p (expm1 (* J (* t_0 -0.5)))))
(if (<= l 0.098)
(+
U
(*
(cos (/ K 2.0))
(+ (* J (* l 2.0)) (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l 5.5e+102) (+ (* (- (exp l) (exp (- l))) J) U) t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + ((pow(l, 3.0) * t_0) * (J * 0.3333333333333333));
double tmp;
if (l <= -1.7e+48) {
tmp = t_1;
} else if (l <= -95.0) {
tmp = U + log1p(expm1((J * (t_0 * -0.5))));
} else if (l <= 0.098) {
tmp = U + (cos((K / 2.0)) * ((J * (l * 2.0)) + (0.3333333333333333 * (J * pow(l, 3.0)))));
} else if (l <= 5.5e+102) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K * 0.5));
double t_1 = U + ((Math.pow(l, 3.0) * t_0) * (J * 0.3333333333333333));
double tmp;
if (l <= -1.7e+48) {
tmp = t_1;
} else if (l <= -95.0) {
tmp = U + Math.log1p(Math.expm1((J * (t_0 * -0.5))));
} else if (l <= 0.098) {
tmp = U + (Math.cos((K / 2.0)) * ((J * (l * 2.0)) + (0.3333333333333333 * (J * Math.pow(l, 3.0)))));
} else if (l <= 5.5e+102) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + ((math.pow(l, 3.0) * t_0) * (J * 0.3333333333333333)) tmp = 0 if l <= -1.7e+48: tmp = t_1 elif l <= -95.0: tmp = U + math.log1p(math.expm1((J * (t_0 * -0.5)))) elif l <= 0.098: tmp = U + (math.cos((K / 2.0)) * ((J * (l * 2.0)) + (0.3333333333333333 * (J * math.pow(l, 3.0))))) elif l <= 5.5e+102: tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64(Float64((l ^ 3.0) * t_0) * Float64(J * 0.3333333333333333))) tmp = 0.0 if (l <= -1.7e+48) tmp = t_1; elseif (l <= -95.0) tmp = Float64(U + log1p(expm1(Float64(J * Float64(t_0 * -0.5))))); elseif (l <= 0.098) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(Float64(J * Float64(l * 2.0)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))))); elseif (l <= 5.5e+102) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(N[Power[l, 3.0], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.7e+48], t$95$1, If[LessEqual[l, -95.0], N[(U + N[Log[1 + N[(Exp[N[(J * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.098], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.5e+102], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + \left({\ell}^{3} \cdot t_0\right) \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{+48}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -95:\\
\;\;\;\;U + \mathsf{log1p}\left(\mathsf{expm1}\left(J \cdot \left(t_0 \cdot -0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 0.098:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\mathbf{elif}\;\ell \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -1.7000000000000002e48 or 5.49999999999999981e102 < l Initial program 100.0%
Taylor expanded in l around 0 97.7%
Taylor expanded in l around inf 97.7%
*-commutative97.7%
*-commutative97.7%
associate-*l*97.7%
Simplified97.7%
if -1.7000000000000002e48 < l < -95Initial program 100.0%
Applied egg-rr4.2%
log1p-expm1-u65.7%
associate-*l*65.7%
div-inv65.7%
metadata-eval65.7%
*-commutative65.7%
Applied egg-rr65.7%
if -95 < l < 0.098000000000000004Initial program 67.7%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Applied egg-rr99.9%
if 0.098000000000000004 < l < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in K around 0 82.4%
Final simplification96.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (* (pow l 3.0) (cos (* K 0.5))) (* J 0.3333333333333333))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -1.15e+47)
t_0
(if (<= l -0.122)
t_1
(if (<= l 0.23)
(+
U
(*
(cos (/ K 2.0))
(+ (* J (* l 2.0)) (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l 4.1e+102) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((pow(l, 3.0) * cos((K * 0.5))) * (J * 0.3333333333333333));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -1.15e+47) {
tmp = t_0;
} else if (l <= -0.122) {
tmp = t_1;
} else if (l <= 0.23) {
tmp = U + (cos((K / 2.0)) * ((J * (l * 2.0)) + (0.3333333333333333 * (J * pow(l, 3.0)))));
} else if (l <= 4.1e+102) {
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 + (((l ** 3.0d0) * cos((k * 0.5d0))) * (j * 0.3333333333333333d0))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-1.15d+47)) then
tmp = t_0
else if (l <= (-0.122d0)) then
tmp = t_1
else if (l <= 0.23d0) then
tmp = u + (cos((k / 2.0d0)) * ((j * (l * 2.0d0)) + (0.3333333333333333d0 * (j * (l ** 3.0d0)))))
else if (l <= 4.1d+102) 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 + ((Math.pow(l, 3.0) * Math.cos((K * 0.5))) * (J * 0.3333333333333333));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -1.15e+47) {
tmp = t_0;
} else if (l <= -0.122) {
tmp = t_1;
} else if (l <= 0.23) {
tmp = U + (Math.cos((K / 2.0)) * ((J * (l * 2.0)) + (0.3333333333333333 * (J * Math.pow(l, 3.0)))));
} else if (l <= 4.1e+102) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.pow(l, 3.0) * math.cos((K * 0.5))) * (J * 0.3333333333333333)) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -1.15e+47: tmp = t_0 elif l <= -0.122: tmp = t_1 elif l <= 0.23: tmp = U + (math.cos((K / 2.0)) * ((J * (l * 2.0)) + (0.3333333333333333 * (J * math.pow(l, 3.0))))) elif l <= 4.1e+102: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64((l ^ 3.0) * cos(Float64(K * 0.5))) * Float64(J * 0.3333333333333333))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -1.15e+47) tmp = t_0; elseif (l <= -0.122) tmp = t_1; elseif (l <= 0.23) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(Float64(J * Float64(l * 2.0)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))))); elseif (l <= 4.1e+102) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (((l ^ 3.0) * cos((K * 0.5))) * (J * 0.3333333333333333)); t_1 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -1.15e+47) tmp = t_0; elseif (l <= -0.122) tmp = t_1; elseif (l <= 0.23) tmp = U + (cos((K / 2.0)) * ((J * (l * 2.0)) + (0.3333333333333333 * (J * (l ^ 3.0))))); elseif (l <= 4.1e+102) 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[(N[Power[l, 3.0], $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -1.15e+47], t$95$0, If[LessEqual[l, -0.122], t$95$1, If[LessEqual[l, 0.23], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.1e+102], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left({\ell}^{3} \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot 0.3333333333333333\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -1.15 \cdot 10^{+47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.122:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.23:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\mathbf{elif}\;\ell \leq 4.1 \cdot 10^{+102}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -1.1499999999999999e47 or 4.1e102 < l Initial program 100.0%
Taylor expanded in l around 0 97.8%
Taylor expanded in l around inf 97.8%
*-commutative97.8%
*-commutative97.8%
associate-*l*97.8%
Simplified97.8%
if -1.1499999999999999e47 < l < -0.122 or 0.23000000000000001 < l < 4.1e102Initial program 100.0%
Taylor expanded in K around 0 73.3%
if -0.122 < l < 0.23000000000000001Initial program 67.7%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Applied egg-rr99.9%
Final simplification96.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (* (pow l 3.0) (cos (* K 0.5))) (* J 0.3333333333333333))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -1.15e+47)
t_0
(if (<= l -0.045)
t_1
(if (<= l 0.23)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 5e+102) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((pow(l, 3.0) * cos((K * 0.5))) * (J * 0.3333333333333333));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -1.15e+47) {
tmp = t_0;
} else if (l <= -0.045) {
tmp = t_1;
} else if (l <= 0.23) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 5e+102) {
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 + (((l ** 3.0d0) * cos((k * 0.5d0))) * (j * 0.3333333333333333d0))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-1.15d+47)) then
tmp = t_0
else if (l <= (-0.045d0)) then
tmp = t_1
else if (l <= 0.23d0) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
else if (l <= 5d+102) 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 + ((Math.pow(l, 3.0) * Math.cos((K * 0.5))) * (J * 0.3333333333333333));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -1.15e+47) {
tmp = t_0;
} else if (l <= -0.045) {
tmp = t_1;
} else if (l <= 0.23) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 5e+102) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.pow(l, 3.0) * math.cos((K * 0.5))) * (J * 0.3333333333333333)) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -1.15e+47: tmp = t_0 elif l <= -0.045: tmp = t_1 elif l <= 0.23: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) elif l <= 5e+102: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64((l ^ 3.0) * cos(Float64(K * 0.5))) * Float64(J * 0.3333333333333333))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -1.15e+47) tmp = t_0; elseif (l <= -0.045) tmp = t_1; elseif (l <= 0.23) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 5e+102) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (((l ^ 3.0) * cos((K * 0.5))) * (J * 0.3333333333333333)); t_1 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -1.15e+47) tmp = t_0; elseif (l <= -0.045) tmp = t_1; elseif (l <= 0.23) tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); elseif (l <= 5e+102) 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[(N[Power[l, 3.0], $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -1.15e+47], t$95$0, If[LessEqual[l, -0.045], t$95$1, If[LessEqual[l, 0.23], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e+102], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left({\ell}^{3} \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot 0.3333333333333333\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -1.15 \cdot 10^{+47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.045:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.23:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{+102}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -1.1499999999999999e47 or 5e102 < l Initial program 100.0%
Taylor expanded in l around 0 97.8%
Taylor expanded in l around inf 97.8%
*-commutative97.8%
*-commutative97.8%
associate-*l*97.8%
Simplified97.8%
if -1.1499999999999999e47 < l < -0.044999999999999998 or 0.23000000000000001 < l < 5e102Initial program 100.0%
Taylor expanded in K around 0 73.3%
if -0.044999999999999998 < l < 0.23000000000000001Initial program 67.7%
Taylor expanded in l around 0 99.5%
Final simplification95.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (* (pow l 3.0) (cos (* K 0.5))) (* J 0.3333333333333333))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -1.05e+47)
t_0
(if (<= l -0.2)
t_1
(if (<= l 0.52)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 5.2e+102) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((pow(l, 3.0) * cos((K * 0.5))) * (J * 0.3333333333333333));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -1.05e+47) {
tmp = t_0;
} else if (l <= -0.2) {
tmp = t_1;
} else if (l <= 0.52) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5.2e+102) {
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 + (((l ** 3.0d0) * cos((k * 0.5d0))) * (j * 0.3333333333333333d0))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-1.05d+47)) then
tmp = t_0
else if (l <= (-0.2d0)) then
tmp = t_1
else if (l <= 0.52d0) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 5.2d+102) 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 + ((Math.pow(l, 3.0) * Math.cos((K * 0.5))) * (J * 0.3333333333333333));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -1.05e+47) {
tmp = t_0;
} else if (l <= -0.2) {
tmp = t_1;
} else if (l <= 0.52) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5.2e+102) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.pow(l, 3.0) * math.cos((K * 0.5))) * (J * 0.3333333333333333)) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -1.05e+47: tmp = t_0 elif l <= -0.2: tmp = t_1 elif l <= 0.52: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 5.2e+102: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64((l ^ 3.0) * cos(Float64(K * 0.5))) * Float64(J * 0.3333333333333333))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -1.05e+47) tmp = t_0; elseif (l <= -0.2) tmp = t_1; elseif (l <= 0.52) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 5.2e+102) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (((l ^ 3.0) * cos((K * 0.5))) * (J * 0.3333333333333333)); t_1 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -1.05e+47) tmp = t_0; elseif (l <= -0.2) tmp = t_1; elseif (l <= 0.52) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 5.2e+102) 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[(N[Power[l, 3.0], $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -1.05e+47], t$95$0, If[LessEqual[l, -0.2], t$95$1, If[LessEqual[l, 0.52], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.2e+102], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left({\ell}^{3} \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot 0.3333333333333333\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -1.05 \cdot 10^{+47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.2:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.52:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+102}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -1.05e47 or 5.20000000000000013e102 < l Initial program 100.0%
Taylor expanded in l around 0 97.8%
Taylor expanded in l around inf 97.8%
*-commutative97.8%
*-commutative97.8%
associate-*l*97.8%
Simplified97.8%
if -1.05e47 < l < -0.20000000000000001 or 0.52000000000000002 < l < 5.20000000000000013e102Initial program 100.0%
Taylor expanded in K around 0 73.3%
if -0.20000000000000001 < l < 0.52000000000000002Initial program 67.7%
Taylor expanded in l around 0 99.9%
Final simplification96.1%
(FPCore (J l K U) :precision binary64 (if (or (<= J -120000000000.0) (not (<= J 1.65e-81))) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((J <= -120000000000.0) || !(J <= 1.65e-81)) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (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 ((j <= (-120000000000.0d0)) .or. (.not. (j <= 1.65d-81))) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + (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 ((J <= -120000000000.0) || !(J <= 1.65e-81)) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (J <= -120000000000.0) or not (J <= 1.65e-81): tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((J <= -120000000000.0) || !(J <= 1.65e-81)) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((J <= -120000000000.0) || ~((J <= 1.65e-81))) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[J, -120000000000.0], N[Not[LessEqual[J, 1.65e-81]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -120000000000 \lor \neg \left(J \leq 1.65 \cdot 10^{-81}\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if J < -1.2e11 or 1.64999999999999994e-81 < J Initial program 72.7%
Taylor expanded in l around 0 77.1%
if -1.2e11 < J < 1.64999999999999994e-81Initial program 96.5%
Taylor expanded in l around 0 88.1%
Taylor expanded in K around 0 79.9%
Taylor expanded in l around inf 78.9%
Final simplification77.9%
(FPCore (J l K U)
:precision binary64
(if (<= J -120000000000.0)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(if (<= J 1.6e-81)
(+ U (* 0.3333333333333333 (* J (pow l 3.0))))
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (J <= -120000000000.0) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else if (J <= 1.6e-81) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + (cos((K / 2.0)) * (J * (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 (j <= (-120000000000.0d0)) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else if (j <= 1.6d-81) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (J <= -120000000000.0) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else if (J <= 1.6e-81) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if J <= -120000000000.0: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) elif J <= 1.6e-81: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (J <= -120000000000.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); elseif (J <= 1.6e-81) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (J <= -120000000000.0) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); elseif (J <= 1.6e-81) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[J, -120000000000.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.6e-81], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -120000000000:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;J \leq 1.6 \cdot 10^{-81}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if J < -1.2e11Initial program 74.1%
Taylor expanded in l around 0 81.3%
if -1.2e11 < J < 1.6e-81Initial program 96.5%
Taylor expanded in l around 0 88.1%
Taylor expanded in K around 0 79.9%
Taylor expanded in l around inf 78.9%
if 1.6e-81 < J Initial program 72.0%
Taylor expanded in l around 0 75.0%
Final simplification77.9%
(FPCore (J l K U) :precision binary64 (if (<= (/ K 2.0) 50.0) (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 50.0) {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
} else {
tmp = U + (cos((K / 2.0)) * (J * (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 ((k / 2.0d0) <= 50.0d0) then
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))
else
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 50.0) {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 50.0: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 50.0) tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((K / 2.0) <= 50.0) tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))); else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 50.0], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 50:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (/.f64 K 2) < 50Initial program 82.9%
Taylor expanded in l around 0 87.5%
Taylor expanded in K around 0 72.5%
if 50 < (/.f64 K 2) Initial program 81.4%
Taylor expanded in l around 0 78.6%
Final simplification74.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3.1) (not (<= l 2.45))) (+ U (* 0.3333333333333333 (* J (pow l 3.0)))) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.1) || !(l <= 2.45)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + (l * (J * 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 ((l <= (-3.1d0)) .or. (.not. (l <= 2.45d0))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + (l * (j * 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.1) || !(l <= 2.45)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -3.1) or not (l <= 2.45): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -3.1) || !(l <= 2.45)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(l * Float64(J * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -3.1) || ~((l <= 2.45))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.1], N[Not[LessEqual[l, 2.45]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.1 \lor \neg \left(\ell \leq 2.45\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if l < -3.10000000000000009 or 2.4500000000000002 < l Initial program 100.0%
Taylor expanded in l around 0 75.7%
Taylor expanded in K around 0 51.5%
Taylor expanded in l around inf 51.5%
if -3.10000000000000009 < l < 2.4500000000000002Initial program 67.7%
Taylor expanded in l around 0 99.5%
Taylor expanded in K around 0 79.6%
*-commutative79.6%
*-commutative79.6%
associate-*r*79.6%
Simplified79.6%
Final simplification66.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -6.8e+16) (not (<= l 1.3e-22))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6.8e+16) || !(l <= 1.3e-22)) {
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 <= (-6.8d+16)) .or. (.not. (l <= 1.3d-22))) 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 <= -6.8e+16) || !(l <= 1.3e-22)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -6.8e+16) or not (l <= 1.3e-22): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -6.8e+16) || !(l <= 1.3e-22)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -6.8e+16) || ~((l <= 1.3e-22))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6.8e+16], N[Not[LessEqual[l, 1.3e-22]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.8 \cdot 10^{+16} \lor \neg \left(\ell \leq 1.3 \cdot 10^{-22}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -6.8e16 or 1.3e-22 < l Initial program 97.5%
associate-*l*97.5%
fma-def97.5%
Simplified97.5%
Applied egg-rr15.0%
if -6.8e16 < l < 1.3e-22Initial program 69.8%
associate-*l*69.8%
fma-def69.8%
Simplified69.8%
Taylor expanded in J around 0 66.1%
Final simplification42.8%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 82.5%
Taylor expanded in l around 0 69.9%
Taylor expanded in K around 0 52.7%
*-commutative52.7%
*-commutative52.7%
associate-*r*52.7%
Simplified52.7%
Final simplification52.7%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.0;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 82.5%
associate-*l*82.5%
fma-def82.5%
Simplified82.5%
Applied egg-rr2.7%
*-inverses2.7%
Simplified2.7%
Final simplification2.7%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 82.5%
associate-*l*82.5%
fma-def82.5%
Simplified82.5%
Taylor expanded in J around 0 37.1%
Final simplification37.1%
herbie shell --seed 2024019
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))