
(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 16 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 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e-6)))
(+ (* J (* t_0 (cos (* K 0.5)))) U)
(+
U
(*
(cos (/ K 2.0))
(*
J
(+
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))
(* 0.016666666666666666 (pow l 5.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 <= 5e-6)) {
tmp = (J * (t_0 * cos((K * 0.5)))) + U;
} else {
tmp = U + (cos((K / 2.0)) * (J * (((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)) + (0.016666666666666666 * pow(l, 5.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 <= 5e-6)) {
tmp = (J * (t_0 * Math.cos((K * 0.5)))) + U;
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)) + (0.016666666666666666 * Math.pow(l, 5.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 <= 5e-6): tmp = (J * (t_0 * math.cos((K * 0.5)))) + U else: tmp = U + (math.cos((K / 2.0)) * (J * (((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)) + (0.016666666666666666 * math.pow(l, 5.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 <= 5e-6)) tmp = Float64(Float64(J * Float64(t_0 * cos(Float64(K * 0.5)))) + U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)) + Float64(0.016666666666666666 * (l ^ 5.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 <= 5e-6))) tmp = (J * (t_0 * cos((K * 0.5)))) + U; else tmp = U + (cos((K / 2.0)) * (J * (((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)) + (0.016666666666666666 * (l ^ 5.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, 5e-6]], $MachinePrecision]], N[(N[(J * N[(t$95$0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $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 5 \cdot 10^{-6}\right):\\
\;\;\;\;J \cdot \left(t_0 \cdot \cos \left(K \cdot 0.5\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right) + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.00000000000000041e-6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
Taylor expanded in J around 0 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000041e-6Initial program 67.2%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5))) (t_1 (- (exp l) (exp (- l)))))
(if (<= (* (* J t_1) (cos (/ K 2.0))) (- INFINITY))
(+ (* J (* t_1 t_0)) U)
(+
U
(+
(* J (* t_0 (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))
(*
J
(*
t_0
(+
(* 0.0003968253968253968 (pow l 7.0))
(* 0.016666666666666666 (pow l 5.0))))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = exp(l) - exp(-l);
double tmp;
if (((J * t_1) * cos((K / 2.0))) <= -((double) INFINITY)) {
tmp = (J * (t_1 * t_0)) + U;
} else {
tmp = U + ((J * (t_0 * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)))) + (J * (t_0 * ((0.0003968253968253968 * pow(l, 7.0)) + (0.016666666666666666 * pow(l, 5.0))))));
}
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 = Math.exp(l) - Math.exp(-l);
double tmp;
if (((J * t_1) * Math.cos((K / 2.0))) <= -Double.POSITIVE_INFINITY) {
tmp = (J * (t_1 * t_0)) + U;
} else {
tmp = U + ((J * (t_0 * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)))) + (J * (t_0 * ((0.0003968253968253968 * Math.pow(l, 7.0)) + (0.016666666666666666 * Math.pow(l, 5.0))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if ((J * t_1) * math.cos((K / 2.0))) <= -math.inf: tmp = (J * (t_1 * t_0)) + U else: tmp = U + ((J * (t_0 * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) + (J * (t_0 * ((0.0003968253968253968 * math.pow(l, 7.0)) + (0.016666666666666666 * math.pow(l, 5.0)))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if (Float64(Float64(J * t_1) * cos(Float64(K / 2.0))) <= Float64(-Inf)) tmp = Float64(Float64(J * Float64(t_1 * t_0)) + U); else tmp = Float64(U + Float64(Float64(J * Float64(t_0 * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))) + Float64(J * Float64(t_0 * Float64(Float64(0.0003968253968253968 * (l ^ 7.0)) + Float64(0.016666666666666666 * (l ^ 5.0))))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); t_1 = exp(l) - exp(-l); tmp = 0.0; if (((J * t_1) * cos((K / 2.0))) <= -Inf) tmp = (J * (t_1 * t_0)) + U; else tmp = U + ((J * (t_0 * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))) + (J * (t_0 * ((0.0003968253968253968 * (l ^ 7.0)) + (0.016666666666666666 * (l ^ 5.0)))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(J * t$95$1), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(J * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(J * N[(t$95$0 * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * N[(t$95$0 * N[(N[(0.0003968253968253968 * N[Power[l, 7.0], $MachinePrecision]), $MachinePrecision] + N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;\left(J \cdot t_1\right) \cdot \cos \left(\frac{K}{2}\right) \leq -\infty:\\
\;\;\;\;J \cdot \left(t_1 \cdot t_0\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \left(t_0 \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right) + J \cdot \left(t_0 \cdot \left(0.0003968253968253968 \cdot {\ell}^{7} + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < -inf.0Initial program 100.0%
Taylor expanded in J around 0 100.0%
if -inf.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) Initial program 76.9%
Taylor expanded in l around 0 98.3%
Simplified98.3%
Taylor expanded in J around 0 98.3%
Taylor expanded in J around 0 98.3%
Final simplification98.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (cos (/ K 2.0))))
(if (<= (* (* J t_0) t_1) (- INFINITY))
(+ (* J (* t_0 (cos (* K 0.5)))) U)
(+
U
(*
t_1
(*
J
(+
(* 0.0003968253968253968 (pow l 7.0))
(+
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))
(* 0.016666666666666666 (pow l 5.0))))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double t_1 = cos((K / 2.0));
double tmp;
if (((J * t_0) * t_1) <= -((double) INFINITY)) {
tmp = (J * (t_0 * cos((K * 0.5)))) + U;
} else {
tmp = U + (t_1 * (J * ((0.0003968253968253968 * pow(l, 7.0)) + (((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)) + (0.016666666666666666 * pow(l, 5.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 t_1 = Math.cos((K / 2.0));
double tmp;
if (((J * t_0) * t_1) <= -Double.POSITIVE_INFINITY) {
tmp = (J * (t_0 * Math.cos((K * 0.5)))) + U;
} else {
tmp = U + (t_1 * (J * ((0.0003968253968253968 * Math.pow(l, 7.0)) + (((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)) + (0.016666666666666666 * Math.pow(l, 5.0))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if ((J * t_0) * t_1) <= -math.inf: tmp = (J * (t_0 * math.cos((K * 0.5)))) + U else: tmp = U + (t_1 * (J * ((0.0003968253968253968 * math.pow(l, 7.0)) + (((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)) + (0.016666666666666666 * math.pow(l, 5.0)))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (Float64(Float64(J * t_0) * t_1) <= Float64(-Inf)) tmp = Float64(Float64(J * Float64(t_0 * cos(Float64(K * 0.5)))) + U); else tmp = Float64(U + Float64(t_1 * Float64(J * Float64(Float64(0.0003968253968253968 * (l ^ 7.0)) + Float64(Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)) + Float64(0.016666666666666666 * (l ^ 5.0))))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = cos((K / 2.0)); tmp = 0.0; if (((J * t_0) * t_1) <= -Inf) tmp = (J * (t_0 * cos((K * 0.5)))) + U; else tmp = U + (t_1 * (J * ((0.0003968253968253968 * (l ^ 7.0)) + (((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)) + (0.016666666666666666 * (l ^ 5.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]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(J * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], (-Infinity)], N[(N[(J * N[(t$95$0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$1 * N[(J * N[(N[(0.0003968253968253968 * N[Power[l, 7.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;\left(J \cdot t_0\right) \cdot t_1 \leq -\infty:\\
\;\;\;\;J \cdot \left(t_0 \cdot \cos \left(K \cdot 0.5\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(\left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right) + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < -inf.0Initial program 100.0%
Taylor expanded in J around 0 100.0%
if -inf.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) Initial program 76.9%
Taylor expanded in l around 0 98.2%
Final simplification98.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -0.004) (not (<= t_0 5e-6)))
(+ (* J (* t_0 (cos (* K 0.5)))) U)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 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 <= -0.004) || !(t_0 <= 5e-6)) {
tmp = (J * (t_0 * cos((K * 0.5)))) + U;
} else {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-0.004d0)) .or. (.not. (t_0 <= 5d-6))) then
tmp = (j * (t_0 * cos((k * 0.5d0)))) + u
else
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -0.004) || !(t_0 <= 5e-6)) {
tmp = (J * (t_0 * Math.cos((K * 0.5)))) + U;
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -0.004) or not (t_0 <= 5e-6): tmp = (J * (t_0 * math.cos((K * 0.5)))) + U else: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (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 <= -0.004) || !(t_0 <= 5e-6)) tmp = Float64(Float64(J * Float64(t_0 * cos(Float64(K * 0.5)))) + U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + 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 <= -0.004) || ~((t_0 <= 5e-6))) tmp = (J * (t_0 * cos((K * 0.5)))) + U; else tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (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, -0.004], N[Not[LessEqual[t$95$0, 5e-6]], $MachinePrecision]], N[(N[(J * N[(t$95$0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -0.004 \lor \neg \left(t_0 \leq 5 \cdot 10^{-6}\right):\\
\;\;\;\;J \cdot \left(t_0 \cdot \cos \left(K \cdot 0.5\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.0040000000000000001 or 5.00000000000000041e-6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
Taylor expanded in J around 0 99.9%
if -0.0040000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000041e-6Initial program 66.7%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -2.5e+102)
(and (not (<= l -4500000.0)) (or (<= l 37000.0) (not (<= l 3e+97)))))
(+
U
(* (cos (/ K 2.0)) (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(+ (* J (- (exp l) (exp (- l)))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.5e+102) || (!(l <= -4500000.0) && ((l <= 37000.0) || !(l <= 3e+97)))) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = (J * (exp(l) - exp(-l))) + 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 <= (-2.5d+102)) .or. (.not. (l <= (-4500000.0d0))) .and. (l <= 37000.0d0) .or. (.not. (l <= 3d+97))) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else
tmp = (j * (exp(l) - exp(-l))) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.5e+102) || (!(l <= -4500000.0) && ((l <= 37000.0) || !(l <= 3e+97)))) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = (J * (Math.exp(l) - Math.exp(-l))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.5e+102) or (not (l <= -4500000.0) and ((l <= 37000.0) or not (l <= 3e+97))): tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) else: tmp = (J * (math.exp(l) - math.exp(-l))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.5e+102) || (!(l <= -4500000.0) && ((l <= 37000.0) || !(l <= 3e+97)))) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); else tmp = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.5e+102) || (~((l <= -4500000.0)) && ((l <= 37000.0) || ~((l <= 3e+97))))) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); else tmp = (J * (exp(l) - exp(-l))) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.5e+102], And[N[Not[LessEqual[l, -4500000.0]], $MachinePrecision], Or[LessEqual[l, 37000.0], N[Not[LessEqual[l, 3e+97]], $MachinePrecision]]]], 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], N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{+102} \lor \neg \left(\ell \leq -4500000\right) \land \left(\ell \leq 37000 \lor \neg \left(\ell \leq 3 \cdot 10^{+97}\right)\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\end{array}
\end{array}
if l < -2.5e102 or -4.5e6 < l < 37000 or 2.9999999999999998e97 < l Initial program 80.9%
Taylor expanded in l around 0 98.1%
if -2.5e102 < l < -4.5e6 or 37000 < l < 2.9999999999999998e97Initial program 100.0%
Taylor expanded in K around 0 82.1%
Final simplification95.6%
(FPCore (J l K U)
:precision binary64
(if (<= l -8e+200)
(+ U (* 0.3333333333333333 (* J (pow l 3.0))))
(if (<= l -1.5e+149)
(+ U (* J (+ (* l 2.0) (sqrt (* (pow l 6.0) 0.1111111111111111)))))
(if (or (<= l -4500000.0) (not (<= l 37000.0)))
(+ (* J (- (exp l) (exp (- l)))) U)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -8e+200) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else if (l <= -1.5e+149) {
tmp = U + (J * ((l * 2.0) + sqrt((pow(l, 6.0) * 0.1111111111111111))));
} else if ((l <= -4500000.0) || !(l <= 37000.0)) {
tmp = (J * (exp(l) - exp(-l))) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-8d+200)) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else if (l <= (-1.5d+149)) then
tmp = u + (j * ((l * 2.0d0) + sqrt(((l ** 6.0d0) * 0.1111111111111111d0))))
else if ((l <= (-4500000.0d0)) .or. (.not. (l <= 37000.0d0))) then
tmp = (j * (exp(l) - exp(-l))) + u
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -8e+200) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else if (l <= -1.5e+149) {
tmp = U + (J * ((l * 2.0) + Math.sqrt((Math.pow(l, 6.0) * 0.1111111111111111))));
} else if ((l <= -4500000.0) || !(l <= 37000.0)) {
tmp = (J * (Math.exp(l) - Math.exp(-l))) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -8e+200: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) elif l <= -1.5e+149: tmp = U + (J * ((l * 2.0) + math.sqrt((math.pow(l, 6.0) * 0.1111111111111111)))) elif (l <= -4500000.0) or not (l <= 37000.0): tmp = (J * (math.exp(l) - math.exp(-l))) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -8e+200) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); elseif (l <= -1.5e+149) tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) + sqrt(Float64((l ^ 6.0) * 0.1111111111111111))))); elseif ((l <= -4500000.0) || !(l <= 37000.0)) tmp = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -8e+200) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); elseif (l <= -1.5e+149) tmp = U + (J * ((l * 2.0) + sqrt(((l ^ 6.0) * 0.1111111111111111)))); elseif ((l <= -4500000.0) || ~((l <= 37000.0))) tmp = (J * (exp(l) - exp(-l))) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -8e+200], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1.5e+149], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[Sqrt[N[(N[Power[l, 6.0], $MachinePrecision] * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, -4500000.0], N[Not[LessEqual[l, 37000.0]], $MachinePrecision]], N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8 \cdot 10^{+200}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq -1.5 \cdot 10^{+149}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2 + \sqrt{{\ell}^{6} \cdot 0.1111111111111111}\right)\\
\mathbf{elif}\;\ell \leq -4500000 \lor \neg \left(\ell \leq 37000\right):\\
\;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\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 < -7.9999999999999998e200Initial program 100.0%
Taylor expanded in K around 0 85.7%
Taylor expanded in l around 0 85.7%
Taylor expanded in l around inf 85.7%
if -7.9999999999999998e200 < l < -1.50000000000000002e149Initial program 100.0%
Taylor expanded in K around 0 8.3%
Taylor expanded in l around 0 8.3%
add-sqr-sqrt0.0%
sqrt-unprod91.7%
*-commutative91.7%
*-commutative91.7%
swap-sqr91.7%
pow-prod-up91.7%
metadata-eval91.7%
metadata-eval91.7%
Applied egg-rr91.7%
if -1.50000000000000002e149 < l < -4.5e6 or 37000 < l Initial program 100.0%
Taylor expanded in K around 0 79.1%
if -4.5e6 < l < 37000Initial program 68.2%
Taylor expanded in l around 0 96.8%
Final simplification89.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.05) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.05) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= 0.05d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.05) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.05: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.05) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.05) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.05], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.05:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.050000000000000003Initial program 83.3%
Taylor expanded in l around 0 59.8%
if 0.050000000000000003 < (cos.f64 (/.f64 K 2)) Initial program 84.0%
Taylor expanded in K around 0 82.9%
Taylor expanded in l around 0 84.6%
Final simplification78.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -4500000.0) (not (<= l 37000.0))) (+ (* J (- (exp l) (exp (- l)))) U) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -4500000.0) || !(l <= 37000.0)) {
tmp = (J * (exp(l) - exp(-l))) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-4500000.0d0)) .or. (.not. (l <= 37000.0d0))) then
tmp = (j * (exp(l) - exp(-l))) + u
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -4500000.0) || !(l <= 37000.0)) {
tmp = (J * (Math.exp(l) - Math.exp(-l))) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -4500000.0) or not (l <= 37000.0): tmp = (J * (math.exp(l) - math.exp(-l))) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -4500000.0) || !(l <= 37000.0)) tmp = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -4500000.0) || ~((l <= 37000.0))) tmp = (J * (exp(l) - exp(-l))) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -4500000.0], N[Not[LessEqual[l, 37000.0]], $MachinePrecision]], N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4500000 \lor \neg \left(\ell \leq 37000\right):\\
\;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\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.5e6 or 37000 < l Initial program 100.0%
Taylor expanded in K around 0 73.8%
if -4.5e6 < l < 37000Initial program 68.2%
Taylor expanded in l around 0 96.8%
Final simplification85.5%
(FPCore (J l K U)
:precision binary64
(if (<= l -195000000.0)
(+ U (* 0.3333333333333333 (* J (pow l 3.0))))
(if (<= l 12000.0)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -195000000.0) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else if (l <= 12000.0) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = J * ((0.3333333333333333 * pow(l, 3.0)) + (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 (l <= (-195000000.0d0)) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else if (l <= 12000.0d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -195000000.0) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else if (l <= 12000.0) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -195000000.0: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) elif l <= 12000.0: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -195000000.0) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); elseif (l <= 12000.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -195000000.0) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); elseif (l <= 12000.0) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -195000000.0], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 12000.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -195000000:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 12000:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -1.95e8Initial program 100.0%
Taylor expanded in K around 0 67.6%
Taylor expanded in l around 0 52.9%
Taylor expanded in l around inf 52.9%
if -1.95e8 < l < 12000Initial program 67.9%
Taylor expanded in l around 0 97.5%
if 12000 < l Initial program 100.0%
Taylor expanded in K around 0 80.4%
Taylor expanded in l around 0 62.0%
Taylor expanded in J around inf 62.0%
Final simplification77.4%
(FPCore (J l K U)
:precision binary64
(if (<= l -4500000.0)
(+ U (* 0.3333333333333333 (* J (pow l 3.0))))
(if (<= l 1750.0)
(+ U (* J (* l 2.0)))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4500000.0) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else if (l <= 1750.0) {
tmp = U + (J * (l * 2.0));
} else {
tmp = J * ((0.3333333333333333 * pow(l, 3.0)) + (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 (l <= (-4500000.0d0)) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else if (l <= 1750.0d0) then
tmp = u + (j * (l * 2.0d0))
else
tmp = j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4500000.0) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else if (l <= 1750.0) {
tmp = U + (J * (l * 2.0));
} else {
tmp = J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -4500000.0: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) elif l <= 1750.0: tmp = U + (J * (l * 2.0)) else: tmp = J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -4500000.0) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); elseif (l <= 1750.0) tmp = Float64(U + Float64(J * Float64(l * 2.0))); else tmp = Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -4500000.0) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); elseif (l <= 1750.0) tmp = U + (J * (l * 2.0)); else tmp = J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -4500000.0], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1750.0], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4500000:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 1750:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -4.5e6Initial program 100.0%
Taylor expanded in K around 0 67.6%
Taylor expanded in l around 0 52.9%
Taylor expanded in l around inf 52.9%
if -4.5e6 < l < 1750Initial program 67.9%
Taylor expanded in K around 0 64.4%
Taylor expanded in l around 0 82.6%
if 1750 < l Initial program 100.0%
Taylor expanded in K around 0 80.4%
Taylor expanded in l around 0 62.0%
Taylor expanded in J around inf 62.0%
Final simplification69.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -4500000.0) (not (<= l 2.45))) (+ U (* 0.3333333333333333 (* J (pow l 3.0)))) (+ U (* J (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -4500000.0) || !(l <= 2.45)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + (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 ((l <= (-4500000.0d0)) .or. (.not. (l <= 2.45d0))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + (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 ((l <= -4500000.0) || !(l <= 2.45)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -4500000.0) or not (l <= 2.45): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -4500000.0) || !(l <= 2.45)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(J * Float64(l * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -4500000.0) || ~((l <= 2.45))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + (J * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -4500000.0], 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[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4500000 \lor \neg \left(\ell \leq 2.45\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -4.5e6 or 2.4500000000000002 < l Initial program 100.0%
Taylor expanded in K around 0 73.2%
Taylor expanded in l around 0 56.9%
Taylor expanded in l around inf 56.9%
if -4.5e6 < l < 2.4500000000000002Initial program 67.9%
Taylor expanded in K around 0 64.4%
Taylor expanded in l around 0 82.6%
Final simplification69.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -5.8e+205) (not (<= l -4500000.0))) (+ U (* J (* l 2.0))) (pow U -3.0)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -5.8e+205) || !(l <= -4500000.0)) {
tmp = U + (J * (l * 2.0));
} else {
tmp = pow(U, -3.0);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-5.8d+205)) .or. (.not. (l <= (-4500000.0d0)))) then
tmp = u + (j * (l * 2.0d0))
else
tmp = u ** (-3.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -5.8e+205) || !(l <= -4500000.0)) {
tmp = U + (J * (l * 2.0));
} else {
tmp = Math.pow(U, -3.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -5.8e+205) or not (l <= -4500000.0): tmp = U + (J * (l * 2.0)) else: tmp = math.pow(U, -3.0) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -5.8e+205) || !(l <= -4500000.0)) tmp = Float64(U + Float64(J * Float64(l * 2.0))); else tmp = U ^ -3.0; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -5.8e+205) || ~((l <= -4500000.0))) tmp = U + (J * (l * 2.0)); else tmp = U ^ -3.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -5.8e+205], N[Not[LessEqual[l, -4500000.0]], $MachinePrecision]], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -3.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.8 \cdot 10^{+205} \lor \neg \left(\ell \leq -4500000\right):\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;{U}^{-3}\\
\end{array}
\end{array}
if l < -5.8000000000000003e205 or -4.5e6 < l Initial program 80.3%
Taylor expanded in K around 0 71.4%
Taylor expanded in l around 0 61.2%
if -5.8000000000000003e205 < l < -4.5e6Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr36.1%
Final simplification56.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7e+15) (not (<= l 1.95e-17))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7e+15) || !(l <= 1.95e-17)) {
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 <= (-7d+15)) .or. (.not. (l <= 1.95d-17))) 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 <= -7e+15) || !(l <= 1.95e-17)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7e+15) or not (l <= 1.95e-17): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7e+15) || !(l <= 1.95e-17)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -7e+15) || ~((l <= 1.95e-17))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7e+15], N[Not[LessEqual[l, 1.95e-17]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7 \cdot 10^{+15} \lor \neg \left(\ell \leq 1.95 \cdot 10^{-17}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -7e15 or 1.94999999999999995e-17 < l Initial program 97.9%
associate-*l*97.9%
fma-def97.9%
Simplified97.9%
Applied egg-rr13.2%
if -7e15 < l < 1.94999999999999995e-17Initial program 69.4%
associate-*l*69.4%
fma-def69.4%
Simplified69.4%
Taylor expanded in J around 0 64.2%
Final simplification38.3%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l 2.0))))
double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (j * (l * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
def code(J, l, K, U): return U + (J * (l * 2.0))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot 2\right)
\end{array}
Initial program 83.8%
Taylor expanded in K around 0 68.8%
Taylor expanded in l around 0 51.6%
Final simplification51.6%
(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 83.8%
associate-*l*83.8%
fma-def83.8%
Simplified83.8%
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 83.8%
associate-*l*83.8%
fma-def83.8%
Simplified83.8%
Taylor expanded in J around 0 32.8%
Final simplification32.8%
herbie shell --seed 2024026
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))