
(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 12 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.002)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(+
(* 0.016666666666666666 (pow l 5.0))
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.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.002)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.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.002)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.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.002): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.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.002)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + 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 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 0.002))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, 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.002]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.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.002\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 2e-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))) < 2e-3Initial program 73.7%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -0.01) (not (<= t_1 0.0)))
(+ (* (* t_1 J) t_0) U)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.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 <= -0.01) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_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) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-0.01d0)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (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.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -0.01) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.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 <= -0.01) or not (t_1 <= 0.0): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.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 <= -0.01) || !(t_1 <= 0.0)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_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 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -0.01) || ~((t_1 <= 0.0))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_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[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, -0.01], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * 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 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -0.01 \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \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.0100000000000000002 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
if -0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 73.0%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -7e+158)
(not (or (<= l -0.038) (and (not (<= l 2.05e-26)) (<= l 2.8e+102)))))
(+
U
(* (cos (/ K 2.0)) (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(+ (* (- (exp l) (exp (- l))) J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7e+158) || !((l <= -0.038) || (!(l <= 2.05e-26) && (l <= 2.8e+102)))) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = ((exp(l) - exp(-l)) * J) + 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+158)) .or. (.not. (l <= (-0.038d0)) .or. (.not. (l <= 2.05d-26)) .and. (l <= 2.8d+102))) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else
tmp = ((exp(l) - exp(-l)) * j) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7e+158) || !((l <= -0.038) || (!(l <= 2.05e-26) && (l <= 2.8e+102)))) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7e+158) or not ((l <= -0.038) or (not (l <= 2.05e-26) and (l <= 2.8e+102))): tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) else: tmp = ((math.exp(l) - math.exp(-l)) * J) + U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7e+158) || !((l <= -0.038) || (!(l <= 2.05e-26) && (l <= 2.8e+102)))) 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(Float64(exp(l) - exp(Float64(-l))) * J) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -7e+158) || ~(((l <= -0.038) || (~((l <= 2.05e-26)) && (l <= 2.8e+102))))) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); else tmp = ((exp(l) - exp(-l)) * J) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7e+158], N[Not[Or[LessEqual[l, -0.038], And[N[Not[LessEqual[l, 2.05e-26]], $MachinePrecision], LessEqual[l, 2.8e+102]]]], $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[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7 \cdot 10^{+158} \lor \neg \left(\ell \leq -0.038 \lor \neg \left(\ell \leq 2.05 \cdot 10^{-26}\right) \land \ell \leq 2.8 \cdot 10^{+102}\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}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\end{array}
\end{array}
if l < -7.0000000000000003e158 or -0.0379999999999999991 < l < 2.0499999999999999e-26 or 2.80000000000000018e102 < l Initial program 82.0%
Taylor expanded in l around 0 99.8%
if -7.0000000000000003e158 < l < -0.0379999999999999991 or 2.0499999999999999e-26 < l < 2.80000000000000018e102Initial program 99.9%
Taylor expanded in K around 0 85.5%
Final simplification96.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -7e+158)
t_0
(if (<= l -0.07)
t_1
(if (<= l 2.05e-26)
(+
U
(*
(cos (* K 0.5))
(+ (* l (* J 2.0)) (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l 5.5e+102) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -7e+158) {
tmp = t_0;
} else if (l <= -0.07) {
tmp = t_1;
} else if (l <= 2.05e-26) {
tmp = U + (cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * pow(l, 3.0)))));
} else if (l <= 5.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 + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-7d+158)) then
tmp = t_0
else if (l <= (-0.07d0)) then
tmp = t_1
else if (l <= 2.05d-26) then
tmp = u + (cos((k * 0.5d0)) * ((l * (j * 2.0d0)) + (0.3333333333333333d0 * (j * (l ** 3.0d0)))))
else if (l <= 5.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.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -7e+158) {
tmp = t_0;
} else if (l <= -0.07) {
tmp = t_1;
} else if (l <= 2.05e-26) {
tmp = U + (Math.cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * Math.pow(l, 3.0)))));
} else if (l <= 5.5e+102) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -7e+158: tmp = t_0 elif l <= -0.07: tmp = t_1 elif l <= 2.05e-26: tmp = U + (math.cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * math.pow(l, 3.0))))) elif l <= 5.5e+102: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -7e+158) tmp = t_0; elseif (l <= -0.07) tmp = t_1; elseif (l <= 2.05e-26) tmp = Float64(U + Float64(cos(Float64(K * 0.5)) * Float64(Float64(l * Float64(J * 2.0)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))))); elseif (l <= 5.5e+102) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); t_1 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -7e+158) tmp = t_0; elseif (l <= -0.07) tmp = t_1; elseif (l <= 2.05e-26) tmp = U + (cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * (l ^ 3.0))))); elseif (l <= 5.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[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]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -7e+158], t$95$0, If[LessEqual[l, -0.07], t$95$1, If[LessEqual[l, 2.05e-26], N[(U + N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[(l * N[(J * 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], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -7 \cdot 10^{+158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.07:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 2.05 \cdot 10^{-26}:\\
\;\;\;\;U + \cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \left(J \cdot 2\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\mathbf{elif}\;\ell \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -7.0000000000000003e158 or 5.49999999999999981e102 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
if -7.0000000000000003e158 < l < -0.070000000000000007 or 2.0499999999999999e-26 < l < 5.49999999999999981e102Initial program 99.9%
Taylor expanded in K around 0 85.5%
if -0.070000000000000007 < l < 2.0499999999999999e-26Initial program 72.9%
Taylor expanded in l around 0 99.6%
+-commutative99.6%
associate-*r*99.6%
associate-*r*99.6%
associate-*r*99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
associate-*r*99.6%
*-commutative99.6%
*-commutative99.6%
Simplified99.6%
Final simplification96.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.005) (+ U (* (* l J) (* 2.0 (cos (* K 0.5))))) (+ U (+ (* l (* J 2.0)) (* 0.3333333333333333 (* J (pow l 3.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.005) {
tmp = U + ((l * J) * (2.0 * cos((K * 0.5))));
} else {
tmp = U + ((l * (J * 2.0)) + (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 (cos((k / 2.0d0)) <= (-0.005d0)) then
tmp = u + ((l * j) * (2.0d0 * cos((k * 0.5d0))))
else
tmp = u + ((l * (j * 2.0d0)) + (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 (Math.cos((K / 2.0)) <= -0.005) {
tmp = U + ((l * J) * (2.0 * Math.cos((K * 0.5))));
} else {
tmp = U + ((l * (J * 2.0)) + (0.3333333333333333 * (J * Math.pow(l, 3.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.005: tmp = U + ((l * J) * (2.0 * math.cos((K * 0.5)))) else: tmp = U + ((l * (J * 2.0)) + (0.3333333333333333 * (J * math.pow(l, 3.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.005) tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 * cos(Float64(K * 0.5))))); else tmp = Float64(U + Float64(Float64(l * Float64(J * 2.0)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.005) tmp = U + ((l * J) * (2.0 * cos((K * 0.5)))); else tmp = U + ((l * (J * 2.0)) + (0.3333333333333333 * (J * (l ^ 3.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.005], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot \left(J \cdot 2\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0050000000000000001Initial program 83.3%
Taylor expanded in l around 0 71.2%
*-commutative71.2%
associate-*r*71.2%
associate-*l*71.2%
*-commutative71.2%
Simplified71.2%
if -0.0050000000000000001 < (cos.f64 (/.f64 K 2)) Initial program 87.6%
Taylor expanded in l around 0 84.9%
+-commutative84.9%
associate-*r*84.9%
associate-*r*84.9%
associate-*r*84.9%
associate-*r*84.9%
distribute-rgt-out84.9%
associate-*r*84.9%
*-commutative84.9%
*-commutative84.9%
Simplified84.9%
Taylor expanded in K around 0 80.4%
Final simplification77.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.0125) (not (<= l 2.05e-26))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* (* l J) (* 2.0 (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.0125) || !(l <= 2.05e-26)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + ((l * J) * (2.0 * 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 <= (-0.0125d0)) .or. (.not. (l <= 2.05d-26))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + ((l * j) * (2.0d0 * 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 <= -0.0125) || !(l <= 2.05e-26)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + ((l * J) * (2.0 * Math.cos((K * 0.5))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.0125) or not (l <= 2.05e-26): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + ((l * J) * (2.0 * math.cos((K * 0.5)))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.0125) || !(l <= 2.05e-26)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 * cos(Float64(K * 0.5))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.0125) || ~((l <= 2.05e-26))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + ((l * J) * (2.0 * cos((K * 0.5)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.0125], N[Not[LessEqual[l, 2.05e-26]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.0125 \lor \neg \left(\ell \leq 2.05 \cdot 10^{-26}\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if l < -0.012500000000000001 or 2.0499999999999999e-26 < l Initial program 99.9%
Taylor expanded in K around 0 78.0%
if -0.012500000000000001 < l < 2.0499999999999999e-26Initial program 72.9%
Taylor expanded in l around 0 99.4%
*-commutative99.4%
associate-*r*99.4%
associate-*l*99.4%
*-commutative99.4%
Simplified99.4%
Final simplification88.7%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l (* 2.0 (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (J * (l * (2.0 * cos((K * 0.5)))));
}
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 * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * (2.0 * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (J * (l * (2.0 * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * Float64(2.0 * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * (2.0 * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 86.4%
Taylor expanded in l around 0 66.4%
*-commutative66.4%
associate-*l*66.4%
associate-*l*66.4%
*-commutative66.4%
Simplified66.4%
Final simplification66.4%
(FPCore (J l K U) :precision binary64 (+ U (* (* l J) (* 2.0 (cos (* K 0.5))))))
double code(double J, double l, double K, double U) {
return U + ((l * J) * (2.0 * cos((K * 0.5))));
}
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 * cos((k * 0.5d0))))
end function
public static double code(double J, double l, double K, double U) {
return U + ((l * J) * (2.0 * Math.cos((K * 0.5))));
}
def code(J, l, K, U): return U + ((l * J) * (2.0 * math.cos((K * 0.5))))
function code(J, l, K, U) return Float64(U + Float64(Float64(l * J) * Float64(2.0 * cos(Float64(K * 0.5))))) end
function tmp = code(J, l, K, U) tmp = U + ((l * J) * (2.0 * cos((K * 0.5)))); end
code[J_, l_, K_, U_] := N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \left(\ell \cdot J\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)
\end{array}
Initial program 86.4%
Taylor expanded in l around 0 66.4%
*-commutative66.4%
associate-*r*66.4%
associate-*l*66.4%
*-commutative66.4%
Simplified66.4%
Final simplification66.4%
(FPCore (J l K U) :precision binary64 (if (or (<= l -9e+86) (not (<= l 0.0009))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -9e+86) || !(l <= 0.0009)) {
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 <= (-9d+86)) .or. (.not. (l <= 0.0009d0))) 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 <= -9e+86) || !(l <= 0.0009)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -9e+86) or not (l <= 0.0009): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -9e+86) || !(l <= 0.0009)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -9e+86) || ~((l <= 0.0009))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -9e+86], N[Not[LessEqual[l, 0.0009]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9 \cdot 10^{+86} \lor \neg \left(\ell \leq 0.0009\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -8.99999999999999986e86 or 8.9999999999999998e-4 < l Initial program 99.9%
Applied egg-rr16.0%
if -8.99999999999999986e86 < l < 8.9999999999999998e-4Initial program 76.9%
Taylor expanded in J around 0 63.5%
Final simplification43.8%
(FPCore (J l K U) :precision binary64 (if (<= l -9.5e+84) (* U (- U -4.0)) (if (<= l 0.0009) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -9.5e+84) {
tmp = U * (U - -4.0);
} else if (l <= 0.0009) {
tmp = U;
} else {
tmp = U * 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 <= (-9.5d+84)) then
tmp = u * (u - (-4.0d0))
else if (l <= 0.0009d0) then
tmp = u
else
tmp = u * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -9.5e+84) {
tmp = U * (U - -4.0);
} else if (l <= 0.0009) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -9.5e+84: tmp = U * (U - -4.0) elif l <= 0.0009: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -9.5e+84) tmp = Float64(U * Float64(U - -4.0)); elseif (l <= 0.0009) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -9.5e+84) tmp = U * (U - -4.0); elseif (l <= 0.0009) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -9.5e+84], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.0009], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9.5 \cdot 10^{+84}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\mathbf{elif}\;\ell \leq 0.0009:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -9.49999999999999979e84Initial program 100.0%
Applied egg-rr17.3%
if -9.49999999999999979e84 < l < 8.9999999999999998e-4Initial program 76.9%
Taylor expanded in J around 0 63.5%
if 8.9999999999999998e-4 < l Initial program 99.9%
Applied egg-rr15.1%
Final simplification43.8%
(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 86.4%
Taylor expanded in l around 0 66.4%
*-commutative66.4%
associate-*l*66.4%
associate-*l*66.4%
*-commutative66.4%
Simplified66.4%
Taylor expanded in K around 0 55.6%
*-commutative55.6%
Simplified55.6%
Final simplification55.6%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 86.4%
Taylor expanded in J around 0 38.1%
Final simplification38.1%
herbie shell --seed 2023308
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))