
(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 (cos (/ K 2.0))) (t_1 (* (* J (- (exp l) (exp (- l)))) t_0)))
(if (or (<= t_1 -5e-235) (not (<= t_1 0.0)))
(+ t_1 U)
(+ U (* t_0 (* J (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = (J * (exp(l) - exp(-l))) * t_0;
double tmp;
if ((t_1 <= -5e-235) || !(t_1 <= 0.0)) {
tmp = t_1 + U;
} else {
tmp = U + (t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = (j * (exp(l) - exp(-l))) * t_0
if ((t_1 <= (-5d-235)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = t_1 + u
else
tmp = u + (t_0 * (j * (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 = (J * (Math.exp(l) - Math.exp(-l))) * t_0;
double tmp;
if ((t_1 <= -5e-235) || !(t_1 <= 0.0)) {
tmp = t_1 + U;
} else {
tmp = U + (t_0 * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = (J * (math.exp(l) - math.exp(-l))) * t_0 tmp = 0 if (t_1 <= -5e-235) or not (t_1 <= 0.0): tmp = t_1 + U else: tmp = U + (t_0 * (J * (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * t_0) tmp = 0.0 if ((t_1 <= -5e-235) || !(t_1 <= 0.0)) tmp = Float64(t_1 + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = (J * (exp(l) - exp(-l))) * t_0; tmp = 0.0; if ((t_1 <= -5e-235) || ~((t_1 <= 0.0))) tmp = t_1 + U; else tmp = U + (t_0 * (J * (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[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e-235], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(t$95$1 + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-235} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;t\_1 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < -4.9999999999999998e-235 or -0.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) Initial program 99.9%
if -4.9999999999999998e-235 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < -0.0Initial program 70.4%
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 (* (* J (- (exp l) (exp (- l)))) t_0)))
(if (<= t_1 0.0)
(+
(*
t_0
(*
J
(+
(* 0.016666666666666666 (pow l 5.0))
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
U)
(+ t_1 U))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = (J * (exp(l) - exp(-l))) * t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (t_0 * (J * ((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))))) + U;
} else {
tmp = t_1 + 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = (j * (exp(l) - exp(-l))) * t_0
if (t_1 <= 0.0d0) then
tmp = (t_0 * (j * ((0.016666666666666666d0 * (l ** 5.0d0)) + ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))) + u
else
tmp = t_1 + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = (J * (Math.exp(l) - Math.exp(-l))) * t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (t_0 * (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))))) + U;
} else {
tmp = t_1 + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = (J * (math.exp(l) - math.exp(-l))) * t_0 tmp = 0 if t_1 <= 0.0: tmp = (t_0 * (J * ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))) + U else: tmp = t_1 + U return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * t_0) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(t_0 * Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))) + U); else tmp = Float64(t_1 + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = (J * (exp(l) - exp(-l))) * t_0; tmp = 0.0; if (t_1 <= 0.0) tmp = (t_0 * (J * ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))))) + U; else tmp = t_1 + U; 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[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(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] + U), $MachinePrecision], N[(t$95$1 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;t\_1 + U\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < -0.0Initial program 79.9%
Taylor expanded in l around 0 97.9%
if -0.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) Initial program 100.0%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -0.01) (not (<= t_0 2000000000.0)))
(* J t_0)
(+ 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 <= -0.01) || !(t_0 <= 2000000000.0)) {
tmp = J * t_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) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-0.01d0)) .or. (.not. (t_0 <= 2000000000.0d0))) then
tmp = j * t_0
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 t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -0.01) || !(t_0 <= 2000000000.0)) {
tmp = J * t_0;
} 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 <= -0.01) or not (t_0 <= 2000000000.0): tmp = J * t_0 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 <= -0.01) || !(t_0 <= 2000000000.0)) tmp = Float64(J * t_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) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -0.01) || ~((t_0 <= 2000000000.0))) tmp = J * t_0; 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, -0.01], N[Not[LessEqual[t$95$0, 2000000000.0]], $MachinePrecision]], N[(J * t$95$0), $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 -0.01 \lor \neg \left(t\_0 \leq 2000000000\right):\\
\;\;\;\;J \cdot t\_0\\
\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))) < -0.0100000000000000002 or 2e9 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
Taylor expanded in K around 0 78.8%
Taylor expanded in J around inf 78.8%
if -0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2e9Initial program 70.6%
Taylor expanded in l around 0 99.3%
Final simplification89.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* (* l 2.0) (* J (cos (* K 0.5)))))))
(if (<= t_0 -0.33)
t_1
(if (<= t_0 -0.1)
(+ U (+ (* -0.25 (* J (* l (pow K 2.0)))) (* 2.0 (* J l))))
(if (<= t_0 0.34)
t_1
(+ U (* J (+ (* 0.016666666666666666 (pow l 5.0)) (* l 2.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + ((l * 2.0) * (J * cos((K * 0.5))));
double tmp;
if (t_0 <= -0.33) {
tmp = t_1;
} else if (t_0 <= -0.1) {
tmp = U + ((-0.25 * (J * (l * pow(K, 2.0)))) + (2.0 * (J * l)));
} else if (t_0 <= 0.34) {
tmp = t_1;
} else {
tmp = U + (J * ((0.016666666666666666 * pow(l, 5.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 = u + ((l * 2.0d0) * (j * cos((k * 0.5d0))))
if (t_0 <= (-0.33d0)) then
tmp = t_1
else if (t_0 <= (-0.1d0)) then
tmp = u + (((-0.25d0) * (j * (l * (k ** 2.0d0)))) + (2.0d0 * (j * l)))
else if (t_0 <= 0.34d0) then
tmp = t_1
else
tmp = u + (j * ((0.016666666666666666d0 * (l ** 5.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 = U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
double tmp;
if (t_0 <= -0.33) {
tmp = t_1;
} else if (t_0 <= -0.1) {
tmp = U + ((-0.25 * (J * (l * Math.pow(K, 2.0)))) + (2.0 * (J * l)));
} else if (t_0 <= 0.34) {
tmp = t_1;
} else {
tmp = U + (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + ((l * 2.0) * (J * math.cos((K * 0.5)))) tmp = 0 if t_0 <= -0.33: tmp = t_1 elif t_0 <= -0.1: tmp = U + ((-0.25 * (J * (l * math.pow(K, 2.0)))) + (2.0 * (J * l))) elif t_0 <= 0.34: tmp = t_1 else: tmp = U + (J * ((0.016666666666666666 * math.pow(l, 5.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))) tmp = 0.0 if (t_0 <= -0.33) tmp = t_1; elseif (t_0 <= -0.1) tmp = Float64(U + Float64(Float64(-0.25 * Float64(J * Float64(l * (K ^ 2.0)))) + Float64(2.0 * Float64(J * l)))); elseif (t_0 <= 0.34) tmp = t_1; else tmp = Float64(U + Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.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 = U + ((l * 2.0) * (J * cos((K * 0.5)))); tmp = 0.0; if (t_0 <= -0.33) tmp = t_1; elseif (t_0 <= -0.1) tmp = U + ((-0.25 * (J * (l * (K ^ 2.0)))) + (2.0 * (J * l))); elseif (t_0 <= 0.34) tmp = t_1; else tmp = U + (J * ((0.016666666666666666 * (l ^ 5.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[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.33], t$95$1, If[LessEqual[t$95$0, -0.1], N[(U + N[(N[(-0.25 * N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.34], t$95$1, N[(U + N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;t\_0 \leq -0.33:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -0.1:\\
\;\;\;\;U + \left(-0.25 \cdot \left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.34:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.330000000000000016 or -0.10000000000000001 < (cos.f64 (/.f64 K 2)) < 0.340000000000000024Initial program 79.8%
Taylor expanded in l around 0 73.5%
*-commutative73.5%
associate-*l*73.5%
*-commutative73.5%
associate-*r*73.5%
Simplified73.5%
if -0.330000000000000016 < (cos.f64 (/.f64 K 2)) < -0.10000000000000001Initial program 95.4%
Taylor expanded in l around 0 24.9%
*-commutative24.9%
associate-*l*24.9%
*-commutative24.9%
associate-*r*24.9%
Simplified24.9%
Taylor expanded in K around 0 78.5%
if 0.340000000000000024 < (cos.f64 (/.f64 K 2)) Initial program 86.9%
Taylor expanded in l around 0 95.7%
Taylor expanded in K around 0 93.9%
Taylor expanded in l around 0 93.6%
Final simplification87.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= (* J (- (exp l) (exp (- l)))) 1e-288)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(+ U (* t_0 (* (pow l 5.0) (* J 0.016666666666666666)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if ((J * (exp(l) - exp(-l))) <= 1e-288) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = U + (t_0 * (pow(l, 5.0) * (J * 0.016666666666666666)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if ((j * (exp(l) - exp(-l))) <= 1d-288) then
tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else
tmp = u + (t_0 * ((l ** 5.0d0) * (j * 0.016666666666666666d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if ((J * (Math.exp(l) - Math.exp(-l))) <= 1e-288) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = U + (t_0 * (Math.pow(l, 5.0) * (J * 0.016666666666666666)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if (J * (math.exp(l) - math.exp(-l))) <= 1e-288: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) else: tmp = U + (t_0 * (math.pow(l, 5.0) * (J * 0.016666666666666666))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (Float64(J * Float64(exp(l) - exp(Float64(-l)))) <= 1e-288) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); else tmp = Float64(U + Float64(t_0 * Float64((l ^ 5.0) * Float64(J * 0.016666666666666666)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if ((J * (exp(l) - exp(-l))) <= 1e-288) tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); else tmp = U + (t_0 * ((l ^ 5.0) * (J * 0.016666666666666666))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-288], 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], N[(U + N[(t$95$0 * N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \cdot \left(e^{\ell} - e^{-\ell}\right) \leq 10^{-288}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 1.00000000000000006e-288Initial program 79.4%
Taylor expanded in l around 0 95.6%
if 1.00000000000000006e-288 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in l around 0 85.7%
Taylor expanded in l around inf 85.7%
*-commutative85.7%
*-commutative85.7%
associate-*l*85.7%
Simplified85.7%
Final simplification92.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 5.0) (* J 0.016666666666666666))))))
(if (<= l -1.35e+45)
t_1
(if (<= l -0.0062)
(* J (- (exp l) (exp (- l))))
(if (<= l 3.3) (+ U (* t_0 (* J (* l 2.0)))) t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + (t_0 * (pow(l, 5.0) * (J * 0.016666666666666666)));
double tmp;
if (l <= -1.35e+45) {
tmp = t_1;
} else if (l <= -0.0062) {
tmp = J * (exp(l) - exp(-l));
} else if (l <= 3.3) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u + (t_0 * ((l ** 5.0d0) * (j * 0.016666666666666666d0)))
if (l <= (-1.35d+45)) then
tmp = t_1
else if (l <= (-0.0062d0)) then
tmp = j * (exp(l) - exp(-l))
else if (l <= 3.3d0) then
tmp = u + (t_0 * (j * (l * 2.0d0)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = U + (t_0 * (Math.pow(l, 5.0) * (J * 0.016666666666666666)));
double tmp;
if (l <= -1.35e+45) {
tmp = t_1;
} else if (l <= -0.0062) {
tmp = J * (Math.exp(l) - Math.exp(-l));
} else if (l <= 3.3) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + (t_0 * (math.pow(l, 5.0) * (J * 0.016666666666666666))) tmp = 0 if l <= -1.35e+45: tmp = t_1 elif l <= -0.0062: tmp = J * (math.exp(l) - math.exp(-l)) elif l <= 3.3: tmp = U + (t_0 * (J * (l * 2.0))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(t_0 * Float64((l ^ 5.0) * Float64(J * 0.016666666666666666)))) tmp = 0.0 if (l <= -1.35e+45) tmp = t_1; elseif (l <= -0.0062) tmp = Float64(J * Float64(exp(l) - exp(Float64(-l)))); elseif (l <= 3.3) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = U + (t_0 * ((l ^ 5.0) * (J * 0.016666666666666666))); tmp = 0.0; if (l <= -1.35e+45) tmp = t_1; elseif (l <= -0.0062) tmp = J * (exp(l) - exp(-l)); elseif (l <= 3.3) tmp = U + (t_0 * (J * (l * 2.0))); else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(t$95$0 * N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.35e+45], t$95$1, If[LessEqual[l, -0.0062], N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.3], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + t\_0 \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -1.35 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -0.0062:\\
\;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 3.3:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -1.34999999999999992e45 or 3.2999999999999998 < l Initial program 100.0%
Taylor expanded in l around 0 92.2%
Taylor expanded in l around inf 92.2%
*-commutative92.2%
*-commutative92.2%
associate-*l*92.2%
Simplified92.2%
if -1.34999999999999992e45 < l < -0.00619999999999999978Initial program 98.7%
Taylor expanded in K around 0 70.1%
Taylor expanded in J around inf 70.1%
if -0.00619999999999999978 < l < 3.2999999999999998Initial program 70.4%
Taylor expanded in l around 0 99.9%
Final simplification95.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.34) (+ U (* (* l 2.0) (* J (cos (* K 0.5))))) (+ U (* J (+ (* 0.016666666666666666 (pow l 5.0)) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.34) {
tmp = U + ((l * 2.0) * (J * cos((K * 0.5))));
} else {
tmp = U + (J * ((0.016666666666666666 * pow(l, 5.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.34d0) then
tmp = u + ((l * 2.0d0) * (j * cos((k * 0.5d0))))
else
tmp = u + (j * ((0.016666666666666666d0 * (l ** 5.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.34) {
tmp = U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
} else {
tmp = U + (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.34: tmp = U + ((l * 2.0) * (J * math.cos((K * 0.5)))) else: tmp = U + (J * ((0.016666666666666666 * math.pow(l, 5.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.34) tmp = Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))); else tmp = Float64(U + Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.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.34) tmp = U + ((l * 2.0) * (J * cos((K * 0.5)))); else tmp = U + (J * ((0.016666666666666666 * (l ^ 5.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.34], N[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.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.34:\\
\;\;\;\;U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.340000000000000024Initial program 81.6%
Taylor expanded in l around 0 67.9%
*-commutative67.9%
associate-*l*67.9%
*-commutative67.9%
associate-*r*67.9%
Simplified67.9%
if 0.340000000000000024 < (cos.f64 (/.f64 K 2)) Initial program 86.9%
Taylor expanded in l around 0 95.7%
Taylor expanded in K around 0 93.9%
Taylor expanded in l around 0 93.6%
Final simplification85.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (- (exp l) (exp (- l))))))
(if (<= l -0.0062)
t_0
(if (<= l 23.5) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0)))) (+ t_0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = J * (exp(l) - exp(-l));
double tmp;
if (l <= -0.0062) {
tmp = t_0;
} else if (l <= 23.5) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else {
tmp = t_0 + U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = j * (exp(l) - exp(-l))
if (l <= (-0.0062d0)) then
tmp = t_0
else if (l <= 23.5d0) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
else
tmp = t_0 + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (Math.exp(l) - Math.exp(-l));
double tmp;
if (l <= -0.0062) {
tmp = t_0;
} else if (l <= 23.5) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else {
tmp = t_0 + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (math.exp(l) - math.exp(-l)) tmp = 0 if l <= -0.0062: tmp = t_0 elif l <= 23.5: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) else: tmp = t_0 + U return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if (l <= -0.0062) tmp = t_0; elseif (l <= 23.5) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); else tmp = Float64(t_0 + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (exp(l) - exp(-l)); tmp = 0.0; if (l <= -0.0062) tmp = t_0; elseif (l <= 23.5) tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); else tmp = t_0 + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -0.0062], t$95$0, If[LessEqual[l, 23.5], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -0.0062:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 23.5:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + U\\
\end{array}
\end{array}
if l < -0.00619999999999999978Initial program 99.8%
Taylor expanded in K around 0 78.0%
Taylor expanded in J around inf 78.0%
if -0.00619999999999999978 < l < 23.5Initial program 70.6%
Taylor expanded in l around 0 99.3%
if 23.5 < l Initial program 100.0%
Taylor expanded in K around 0 79.5%
Final simplification89.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.4e+45) (not (<= l 780.0))) (+ U (* 0.016666666666666666 (* J (pow l 5.0)))) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.4e+45) || !(l <= 780.0)) {
tmp = U + (0.016666666666666666 * (J * pow(l, 5.0)));
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-1.4d+45)) .or. (.not. (l <= 780.0d0))) then
tmp = u + (0.016666666666666666d0 * (j * (l ** 5.0d0)))
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 <= -1.4e+45) || !(l <= 780.0)) {
tmp = U + (0.016666666666666666 * (J * Math.pow(l, 5.0)));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.4e+45) or not (l <= 780.0): tmp = U + (0.016666666666666666 * (J * math.pow(l, 5.0))) 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 <= -1.4e+45) || !(l <= 780.0)) tmp = Float64(U + Float64(0.016666666666666666 * Float64(J * (l ^ 5.0)))); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.4e+45) || ~((l <= 780.0))) tmp = U + (0.016666666666666666 * (J * (l ^ 5.0))); 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, -1.4e+45], N[Not[LessEqual[l, 780.0]], $MachinePrecision]], N[(U + N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.4 \cdot 10^{+45} \lor \neg \left(\ell \leq 780\right):\\
\;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -1.4e45 or 780 < l Initial program 100.0%
Taylor expanded in l around 0 92.8%
Taylor expanded in l around inf 92.8%
*-commutative92.8%
*-commutative92.8%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in K around 0 76.1%
+-commutative76.1%
Simplified76.1%
if -1.4e45 < l < 780Initial program 72.3%
Taylor expanded in l around 0 94.6%
Final simplification85.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.4e+45) (not (<= l 56.0))) (+ U (* 0.016666666666666666 (* J (pow l 5.0)))) (+ U (* (* l 2.0) (* J (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.4e+45) || !(l <= 56.0)) {
tmp = U + (0.016666666666666666 * (J * pow(l, 5.0)));
} else {
tmp = U + ((l * 2.0) * (J * 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 <= (-1.4d+45)) .or. (.not. (l <= 56.0d0))) then
tmp = u + (0.016666666666666666d0 * (j * (l ** 5.0d0)))
else
tmp = u + ((l * 2.0d0) * (j * 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 <= -1.4e+45) || !(l <= 56.0)) {
tmp = U + (0.016666666666666666 * (J * Math.pow(l, 5.0)));
} else {
tmp = U + ((l * 2.0) * (J * Math.cos((K * 0.5))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.4e+45) or not (l <= 56.0): tmp = U + (0.016666666666666666 * (J * math.pow(l, 5.0))) else: tmp = U + ((l * 2.0) * (J * math.cos((K * 0.5)))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.4e+45) || !(l <= 56.0)) tmp = Float64(U + Float64(0.016666666666666666 * Float64(J * (l ^ 5.0)))); else tmp = Float64(U + Float64(Float64(l * 2.0) * Float64(J * cos(Float64(K * 0.5))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.4e+45) || ~((l <= 56.0))) tmp = U + (0.016666666666666666 * (J * (l ^ 5.0))); else tmp = U + ((l * 2.0) * (J * cos((K * 0.5)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.4e+45], N[Not[LessEqual[l, 56.0]], $MachinePrecision]], N[(U + N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.4 \cdot 10^{+45} \lor \neg \left(\ell \leq 56\right):\\
\;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if l < -1.4e45 or 56 < l Initial program 100.0%
Taylor expanded in l around 0 92.8%
Taylor expanded in l around inf 92.8%
*-commutative92.8%
*-commutative92.8%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in K around 0 76.1%
+-commutative76.1%
Simplified76.1%
if -1.4e45 < l < 56Initial program 72.3%
Taylor expanded in l around 0 94.6%
*-commutative94.6%
associate-*l*94.7%
*-commutative94.7%
associate-*r*94.7%
Simplified94.7%
Final simplification86.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.4e+45) (not (<= l 410000.0))) (+ U (* 0.016666666666666666 (* J (pow l 5.0)))) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.4e+45) || !(l <= 410000.0)) {
tmp = U + (0.016666666666666666 * (J * pow(l, 5.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 ((l <= (-1.4d+45)) .or. (.not. (l <= 410000.0d0))) then
tmp = u + (0.016666666666666666d0 * (j * (l ** 5.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 ((l <= -1.4e+45) || !(l <= 410000.0)) {
tmp = U + (0.016666666666666666 * (J * Math.pow(l, 5.0)));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.4e+45) or not (l <= 410000.0): tmp = U + (0.016666666666666666 * (J * math.pow(l, 5.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 ((l <= -1.4e+45) || !(l <= 410000.0)) tmp = Float64(U + Float64(0.016666666666666666 * Float64(J * (l ^ 5.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 ((l <= -1.4e+45) || ~((l <= 410000.0))) tmp = U + (0.016666666666666666 * (J * (l ^ 5.0))); else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.4e+45], N[Not[LessEqual[l, 410000.0]], $MachinePrecision]], N[(U + N[(0.016666666666666666 * N[(J * N[Power[l, 5.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}\;\ell \leq -1.4 \cdot 10^{+45} \lor \neg \left(\ell \leq 410000\right):\\
\;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\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 l < -1.4e45 or 4.1e5 < l Initial program 100.0%
Taylor expanded in l around 0 92.8%
Taylor expanded in l around inf 92.8%
*-commutative92.8%
*-commutative92.8%
associate-*l*92.8%
Simplified92.8%
Taylor expanded in K around 0 76.1%
+-commutative76.1%
Simplified76.1%
if -1.4e45 < l < 4.1e5Initial program 72.3%
Taylor expanded in l around 0 94.7%
Final simplification86.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -900000000000.0) (not (<= l 2.1e-18))) (+ U (* 0.016666666666666666 (* J (pow l 5.0)))) (+ U (* J (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -900000000000.0) || !(l <= 2.1e-18)) {
tmp = U + (0.016666666666666666 * (J * pow(l, 5.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 <= (-900000000000.0d0)) .or. (.not. (l <= 2.1d-18))) then
tmp = u + (0.016666666666666666d0 * (j * (l ** 5.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 <= -900000000000.0) || !(l <= 2.1e-18)) {
tmp = U + (0.016666666666666666 * (J * Math.pow(l, 5.0)));
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -900000000000.0) or not (l <= 2.1e-18): tmp = U + (0.016666666666666666 * (J * math.pow(l, 5.0))) else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -900000000000.0) || !(l <= 2.1e-18)) tmp = Float64(U + Float64(0.016666666666666666 * Float64(J * (l ^ 5.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 <= -900000000000.0) || ~((l <= 2.1e-18))) tmp = U + (0.016666666666666666 * (J * (l ^ 5.0))); else tmp = U + (J * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -900000000000.0], N[Not[LessEqual[l, 2.1e-18]], $MachinePrecision]], N[(U + N[(0.016666666666666666 * N[(J * N[Power[l, 5.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 -900000000000 \lor \neg \left(\ell \leq 2.1 \cdot 10^{-18}\right):\\
\;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -9e11 or 2.1e-18 < l Initial program 99.7%
Taylor expanded in l around 0 90.3%
Taylor expanded in l around inf 89.6%
*-commutative89.6%
*-commutative89.6%
associate-*l*89.6%
Simplified89.6%
Taylor expanded in K around 0 72.9%
+-commutative72.9%
Simplified72.9%
if -9e11 < l < 2.1e-18Initial program 71.1%
Taylor expanded in l around 0 97.3%
*-commutative97.3%
associate-*l*97.3%
*-commutative97.3%
associate-*r*97.3%
Simplified97.3%
Taylor expanded in K around 0 84.0%
Final simplification78.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -800.0) (not (<= l 1100.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -800.0) || !(l <= 1100.0)) {
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 <= (-800.0d0)) .or. (.not. (l <= 1100.0d0))) 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 <= -800.0) || !(l <= 1100.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -800.0) or not (l <= 1100.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -800.0) || !(l <= 1100.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -800.0) || ~((l <= 1100.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -800.0], N[Not[LessEqual[l, 1100.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -800 \lor \neg \left(\ell \leq 1100\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -800 or 1100 < l Initial program 100.0%
Taylor expanded in l around 0 88.7%
Taylor expanded in l around inf 88.7%
*-commutative88.7%
*-commutative88.7%
associate-*l*88.7%
Simplified88.7%
Applied egg-rr14.1%
if -800 < l < 1100Initial program 70.8%
Applied egg-rr53.1%
Taylor expanded in J around 0 69.0%
Final simplification41.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 85.3%
Taylor expanded in l around 0 63.8%
*-commutative63.8%
associate-*l*63.8%
*-commutative63.8%
associate-*r*64.2%
Simplified64.2%
Taylor expanded in K around 0 55.0%
Final simplification55.0%
(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 85.3%
Taylor expanded in l around 0 94.0%
Taylor expanded in l around inf 78.9%
*-commutative78.9%
*-commutative78.9%
associate-*l*78.9%
Simplified78.9%
Applied egg-rr2.8%
*-inverses2.8%
Simplified2.8%
Final simplification2.8%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 85.3%
Applied egg-rr27.9%
Taylor expanded in J around 0 35.8%
Final simplification35.8%
herbie shell --seed 2024044
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))