
(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 11 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 -5000000.0) (not (<= t_1 0.0)))
(+ (* (* t_1 J) t_0) 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 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -5000000.0) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + 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 = exp(l) - exp(-l)
if ((t_1 <= (-5000000.0d0)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = ((t_1 * j) * t_0) + 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 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -5000000.0) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + 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 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -5000000.0) or not (t_1 <= 0.0): tmp = ((t_1 * J) * t_0) + 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(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= -5000000.0) || !(t_1 <= 0.0)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + 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 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -5000000.0) || ~((t_1 <= 0.0))) tmp = ((t_1 * J) * t_0) + 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[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5000000.0], 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[(l * 2.0), $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 -5000000 \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(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -5e6 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -5e6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 78.1%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J)))
(if (or (<= t_0 -5e+165) (not (<= t_0 0.0)))
(+ t_0 U)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double tmp;
if ((t_0 <= -5e+165) || !(t_0 <= 0.0)) {
tmp = t_0 + U;
} 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)) * j
if ((t_0 <= (-5d+165)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0 + u
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)) * J;
double tmp;
if ((t_0 <= -5e+165) || !(t_0 <= 0.0)) {
tmp = t_0 + U;
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = (math.exp(l) - math.exp(-l)) * J tmp = 0 if (t_0 <= -5e+165) or not (t_0 <= 0.0): tmp = t_0 + U else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if ((t_0 <= -5e+165) || !(t_0 <= 0.0)) tmp = Float64(t_0 + U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (exp(l) - exp(-l)) * J; tmp = 0.0; if ((t_0 <= -5e+165) || ~((t_0 <= 0.0))) tmp = t_0 + U; else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e+165], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(t$95$0 + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+165} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -4.9999999999999997e165 or -0.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in K around 0 77.7%
if -4.9999999999999997e165 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -0.0Initial program 77.7%
Taylor expanded in l around 0 99.9%
Final simplification87.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* (* J -0.25) (* l (pow K 2.0))))))
(if (<= t_0 -0.75)
t_1
(if (<= t_0 -0.65)
U
(if (<= t_0 -0.02)
t_1
(+ U (* 0.3333333333333333 (* J (pow l 3.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + ((J * -0.25) * (l * pow(K, 2.0)));
double tmp;
if (t_0 <= -0.75) {
tmp = t_1;
} else if (t_0 <= -0.65) {
tmp = U;
} else if (t_0 <= -0.02) {
tmp = t_1;
} else {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u + ((j * (-0.25d0)) * (l * (k ** 2.0d0)))
if (t_0 <= (-0.75d0)) then
tmp = t_1
else if (t_0 <= (-0.65d0)) then
tmp = u
else if (t_0 <= (-0.02d0)) then
tmp = t_1
else
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
double tmp;
if (t_0 <= -0.75) {
tmp = t_1;
} else if (t_0 <= -0.65) {
tmp = U;
} else if (t_0 <= -0.02) {
tmp = t_1;
} else {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + ((J * -0.25) * (l * math.pow(K, 2.0))) tmp = 0 if t_0 <= -0.75: tmp = t_1 elif t_0 <= -0.65: tmp = U elif t_0 <= -0.02: tmp = t_1 else: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 2.0)))) tmp = 0.0 if (t_0 <= -0.75) tmp = t_1; elseif (t_0 <= -0.65) tmp = U; elseif (t_0 <= -0.02) tmp = t_1; else tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = U + ((J * -0.25) * (l * (K ^ 2.0))); tmp = 0.0; if (t_0 <= -0.75) tmp = t_1; elseif (t_0 <= -0.65) tmp = U; elseif (t_0 <= -0.02) tmp = t_1; else tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.75], t$95$1, If[LessEqual[t$95$0, -0.65], U, If[LessEqual[t$95$0, -0.02], t$95$1, N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.75:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -0.65:\\
\;\;\;\;U\\
\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.75 or -0.650000000000000022 < (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 89.8%
Taylor expanded in l around 0 61.1%
associate-*r*61.3%
*-commutative61.3%
associate-*l*61.2%
associate-*r*61.2%
Simplified61.2%
Taylor expanded in K around 0 62.8%
Taylor expanded in K around inf 67.8%
associate-*r*67.8%
Simplified67.8%
if -0.75 < (cos.f64 (/.f64 K 2)) < -0.650000000000000022Initial program 100.0%
Applied egg-rr56.9%
Taylor expanded in J around 0 100.0%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 90.4%
Taylor expanded in l around 0 83.6%
Taylor expanded in l around inf 74.2%
associate-*r*74.2%
Simplified74.2%
Taylor expanded in K around 0 74.2%
Final simplification73.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.4)
(+ U (* t_0 (* J (* l 2.0))))
(if (<= t_0 -0.02)
(+ U (* (* J -0.25) (* l (pow K 2.0))))
(+ U (* J (+ (* l 2.0) (* 0.3333333333333333 (pow l 3.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.4) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else if (t_0 <= -0.02) {
tmp = U + ((J * -0.25) * (l * pow(K, 2.0)));
} else {
tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * 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) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= (-0.4d0)) then
tmp = u + (t_0 * (j * (l * 2.0d0)))
else if (t_0 <= (-0.02d0)) then
tmp = u + ((j * (-0.25d0)) * (l * (k ** 2.0d0)))
else
tmp = u + (j * ((l * 2.0d0) + (0.3333333333333333d0 * (l ** 3.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 tmp;
if (t_0 <= -0.4) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else if (t_0 <= -0.02) {
tmp = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
} else {
tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * Math.pow(l, 3.0))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.4: tmp = U + (t_0 * (J * (l * 2.0))) elif t_0 <= -0.02: tmp = U + ((J * -0.25) * (l * math.pow(K, 2.0))) else: tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * math.pow(l, 3.0)))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.4) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0)))); elseif (t_0 <= -0.02) tmp = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 2.0)))); else tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * (l ^ 3.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.4) tmp = U + (t_0 * (J * (l * 2.0))); elseif (t_0 <= -0.02) tmp = U + ((J * -0.25) * (l * (K ^ 2.0))); else tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * (l ^ 3.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.4], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.4:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.40000000000000002Initial program 89.5%
Taylor expanded in l around 0 68.8%
if -0.40000000000000002 < (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 94.6%
Taylor expanded in l around 0 57.0%
associate-*r*57.1%
*-commutative57.1%
associate-*l*57.1%
associate-*r*57.1%
Simplified57.1%
Taylor expanded in K around 0 78.5%
Taylor expanded in K around inf 83.6%
associate-*r*83.6%
Simplified83.6%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 90.4%
Taylor expanded in l around 0 83.6%
Taylor expanded in K around 0 80.3%
Final simplification78.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (* J 0.3333333333333333) (* (pow l 3.0) (cos (* K 0.5))))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -3.95e+102)
t_0
(if (<= l -0.00295)
t_1
(if (<= l 0.0058)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 2.2e+89) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((J * 0.3333333333333333) * (pow(l, 3.0) * cos((K * 0.5))));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -3.95e+102) {
tmp = t_0;
} else if (l <= -0.00295) {
tmp = t_1;
} else if (l <= 0.0058) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 2.2e+89) {
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 + ((j * 0.3333333333333333d0) * ((l ** 3.0d0) * cos((k * 0.5d0))))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-3.95d+102)) then
tmp = t_0
else if (l <= (-0.00295d0)) then
tmp = t_1
else if (l <= 0.0058d0) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
else if (l <= 2.2d+89) 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 + ((J * 0.3333333333333333) * (Math.pow(l, 3.0) * Math.cos((K * 0.5))));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -3.95e+102) {
tmp = t_0;
} else if (l <= -0.00295) {
tmp = t_1;
} else if (l <= 0.0058) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 2.2e+89) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((J * 0.3333333333333333) * (math.pow(l, 3.0) * math.cos((K * 0.5)))) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -3.95e+102: tmp = t_0 elif l <= -0.00295: tmp = t_1 elif l <= 0.0058: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) elif l <= 2.2e+89: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64(J * 0.3333333333333333) * Float64((l ^ 3.0) * cos(Float64(K * 0.5))))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -3.95e+102) tmp = t_0; elseif (l <= -0.00295) tmp = t_1; elseif (l <= 0.0058) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 2.2e+89) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((J * 0.3333333333333333) * ((l ^ 3.0) * cos((K * 0.5)))); t_1 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -3.95e+102) tmp = t_0; elseif (l <= -0.00295) tmp = t_1; elseif (l <= 0.0058) tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); elseif (l <= 2.2e+89) 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[(J * 0.3333333333333333), $MachinePrecision] * N[(N[Power[l, 3.0], $MachinePrecision] * N[Cos[N[(K * 0.5), $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, -3.95e+102], t$95$0, If[LessEqual[l, -0.00295], t$95$1, If[LessEqual[l, 0.0058], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.2e+89], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left(J \cdot 0.3333333333333333\right) \cdot \left({\ell}^{3} \cdot \cos \left(K \cdot 0.5\right)\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -3.95 \cdot 10^{+102}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -0.00295:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq 0.0058:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{+89}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -3.9500000000000001e102 or 2.2e89 < l Initial program 100.0%
Taylor expanded in l around 0 99.0%
Taylor expanded in l around inf 99.0%
associate-*r*99.0%
Simplified99.0%
if -3.9500000000000001e102 < l < -0.00294999999999999993 or 0.0058 < l < 2.2e89Initial program 100.0%
Taylor expanded in K around 0 74.0%
if -0.00294999999999999993 < l < 0.0058Initial program 78.1%
Taylor expanded in l around 0 99.9%
Final simplification94.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.6e+68) (not (<= l 1.35e+23))) (+ U (* 0.3333333333333333 (* J (pow l 3.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.6e+68) || !(l <= 1.35e+23)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.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.6d+68)) .or. (.not. (l <= 1.35d+23))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.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.6e+68) || !(l <= 1.35e+23)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.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.6e+68) or not (l <= 1.35e+23): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.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.6e+68) || !(l <= 1.35e+23)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.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.6e+68) || ~((l <= 1.35e+23))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.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.6e+68], N[Not[LessEqual[l, 1.35e+23]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.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.6 \cdot 10^{+68} \lor \neg \left(\ell \leq 1.35 \cdot 10^{+23}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\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.59999999999999997e68 or 1.3499999999999999e23 < l Initial program 100.0%
Taylor expanded in l around 0 87.3%
Taylor expanded in l around inf 87.3%
associate-*r*87.3%
Simplified87.3%
Taylor expanded in K around 0 70.0%
if -1.59999999999999997e68 < l < 1.3499999999999999e23Initial program 83.2%
Taylor expanded in l around 0 79.4%
Final simplification75.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.6e+68) (not (<= l 2.2e+23))) (+ U (* 0.3333333333333333 (* J (pow l 3.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.6e+68) || !(l <= 2.2e+23)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.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.6d+68)) .or. (.not. (l <= 2.2d+23))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.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.6e+68) || !(l <= 2.2e+23)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.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.6e+68) or not (l <= 2.2e+23): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.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.6e+68) || !(l <= 2.2e+23)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.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.6e+68) || ~((l <= 2.2e+23))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.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.6e+68], N[Not[LessEqual[l, 2.2e+23]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.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.6 \cdot 10^{+68} \lor \neg \left(\ell \leq 2.2 \cdot 10^{+23}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\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.59999999999999997e68 or 2.20000000000000008e23 < l Initial program 100.0%
Taylor expanded in l around 0 87.3%
Taylor expanded in l around inf 87.3%
associate-*r*87.3%
Simplified87.3%
Taylor expanded in K around 0 70.0%
if -1.59999999999999997e68 < l < 2.20000000000000008e23Initial program 83.2%
Taylor expanded in l around 0 79.4%
associate-*r*79.5%
*-commutative79.5%
associate-*l*79.5%
associate-*r*79.5%
Simplified79.5%
Final simplification75.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.7e+68) (not (<= l 4.5e+23))) (+ U (* 0.3333333333333333 (* J (pow l 3.0)))) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.7e+68) || !(l <= 4.5e+23)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-1.7d+68)) .or. (.not. (l <= 4.5d+23))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.7e+68) || !(l <= 4.5e+23)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.7e+68) or not (l <= 4.5e+23): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.7e+68) || !(l <= 4.5e+23)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.7e+68) || ~((l <= 4.5e+23))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.7e+68], N[Not[LessEqual[l, 4.5e+23]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{+68} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+23}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -1.70000000000000008e68 or 4.49999999999999979e23 < l Initial program 100.0%
Taylor expanded in l around 0 87.3%
Taylor expanded in l around inf 87.3%
associate-*r*87.3%
Simplified87.3%
Taylor expanded in K around 0 70.0%
if -1.70000000000000008e68 < l < 4.49999999999999979e23Initial program 83.2%
Taylor expanded in l around 0 79.5%
Final simplification75.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.1) (not (<= l 2.5))) (+ 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 <= -2.1) || !(l <= 2.5)) {
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 <= (-2.1d0)) .or. (.not. (l <= 2.5d0))) 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 <= -2.1) || !(l <= 2.5)) {
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 <= -2.1) or not (l <= 2.5): 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 <= -2.1) || !(l <= 2.5)) 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 <= -2.1) || ~((l <= 2.5))) 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, -2.1], N[Not[LessEqual[l, 2.5]], $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 -2.1 \lor \neg \left(\ell \leq 2.5\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 < -2.10000000000000009 or 2.5 < l Initial program 100.0%
Taylor expanded in l around 0 71.1%
Taylor expanded in l around inf 71.1%
associate-*r*71.1%
Simplified71.1%
Taylor expanded in K around 0 56.4%
if -2.10000000000000009 < l < 2.5Initial program 78.1%
Taylor expanded in l around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in K around 0 88.9%
Final simplification70.5%
(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 90.5%
Taylor expanded in l around 0 62.2%
associate-*r*62.2%
*-commutative62.2%
associate-*l*62.2%
associate-*r*62.2%
Simplified62.2%
Taylor expanded in K around 0 53.7%
Final simplification53.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 90.5%
Applied egg-rr25.3%
Taylor expanded in J around 0 35.2%
Final simplification35.2%
herbie shell --seed 2024052
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))