Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\]
↓
\[\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -0.02 \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;U + \left(t_1 \cdot J\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(2 \cdot \left(\ell \cdot J\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
\]
(FPCore (J l K U)
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U)) ↓
(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.02) (not (<= t_1 0.0)))
(+ U (* (* t_1 J) t_0))
(+
U
(* t_0 (+ (* 2.0 (* l J)) (* 0.3333333333333333 (* J (pow l 3.0))))))))) double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
↓
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.02) || !(t_1 <= 0.0)) {
tmp = U + ((t_1 * J) * t_0);
} else {
tmp = U + (t_0 * ((2.0 * (l * J)) + (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
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
↓
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.02d0)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = u + ((t_1 * j) * t_0)
else
tmp = u + (t_0 * ((2.0d0 * (l * j)) + (0.3333333333333333d0 * (j * (l ** 3.0d0)))))
end if
code = tmp
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;
}
↓
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.02) || !(t_1 <= 0.0)) {
tmp = U + ((t_1 * J) * t_0);
} else {
tmp = U + (t_0 * ((2.0 * (l * J)) + (0.3333333333333333 * (J * Math.pow(l, 3.0)))));
}
return tmp;
}
def code(J, l, K, U):
return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
↓
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.02) or not (t_1 <= 0.0):
tmp = U + ((t_1 * J) * t_0)
else:
tmp = U + (t_0 * ((2.0 * (l * J)) + (0.3333333333333333 * (J * math.pow(l, 3.0)))))
return tmp
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 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.02) || !(t_1 <= 0.0))
tmp = Float64(U + Float64(Float64(t_1 * J) * t_0));
else
tmp = Float64(U + Float64(t_0 * Float64(Float64(2.0 * Float64(l * J)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))))));
end
return tmp
end
function tmp = code(J, l, K, U)
tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
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.02) || ~((t_1 <= 0.0)))
tmp = U + ((t_1 * J) * t_0);
else
tmp = U + (t_0 * ((2.0 * (l * J)) + (0.3333333333333333 * (J * (l ^ 3.0)))));
end
tmp_2 = tmp;
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]
↓
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.02], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(U + N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
↓
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -0.02 \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;U + \left(t_1 \cdot J\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(2 \cdot \left(\ell \cdot J\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
Alternatives Alternative 1 Accuracy 99.6% Cost 46217
\[\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -0.02 \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;U + \left(t_1 \cdot J\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(2 \cdot \left(\ell \cdot J\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
\]
Alternative 2 Accuracy 97.5% Cost 60740
\[\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq 0.01:\\
\;\;\;\;\left(2 \cdot \left(t_0 \cdot \left(\ell \cdot J\right)\right) + \left(0.016666666666666666 \cdot \left(t_0 \cdot \left(J \cdot {\ell}^{5}\right)\right) + \left(0.0003968253968253968 \cdot \left(t_0 \cdot \left(J \cdot {\ell}^{7}\right)\right) + 0.3333333333333333 \cdot \left(t_0 \cdot \left(J \cdot {\ell}^{3}\right)\right)\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_1 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\\
\end{array}
\]
Alternative 3 Accuracy 97.5% Cost 40388
\[\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.01:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \ell \cdot 2\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_0 \cdot J\right) \cdot t_1\\
\end{array}
\]
Alternative 4 Accuracy 96.5% Cost 33924
\[\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.01:\\
\;\;\;\;U + t_1 \cdot \left(2 \cdot \left(\ell \cdot J\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_0 \cdot J\right) \cdot t_1\\
\end{array}
\]
Alternative 5 Accuracy 96.5% Cost 33668
\[\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.01:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.016666666666666666 \cdot {\ell}^{5} + \ell \cdot 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_0 \cdot J\right) \cdot t_1\\
\end{array}
\]
Alternative 6 Accuracy 93.8% Cost 20612
\[\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.999995:\\
\;\;\;\;U + t_0 \cdot \left(2 \cdot \left(\ell \cdot J\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\end{array}
\]
Alternative 7 Accuracy 93.8% Cost 14148
\[\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.999995:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\end{array}
\]
Alternative 8 Accuracy 85.2% Cost 13508
\[\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.22:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(K \cdot \left(K \cdot -0.25\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\end{array}
\]
Alternative 9 Accuracy 58.6% Cost 7189
\[\begin{array}{l}
t_0 := U + \left(\ell \cdot J\right) \cdot \left(2 + -0.25 \cdot \left(K \cdot K\right)\right)\\
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{+83}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -840:\\
\;\;\;\;{U}^{-8}\\
\mathbf{elif}\;\ell \leq 0.00335:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\
\mathbf{elif}\;\ell \leq 10^{+97} \lor \neg \left(\ell \leq 9.5 \cdot 10^{+193}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{U}^{-8}\\
\end{array}
\]
Alternative 10 Accuracy 58.6% Cost 1097
\[\begin{array}{l}
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{+76} \lor \neg \left(\ell \leq 0.00335\right):\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + -0.25 \cdot \left(K \cdot K\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\
\end{array}
\]
Alternative 11 Accuracy 44.1% Cost 585
\[\begin{array}{l}
\mathbf{if}\;\ell \leq -1.85 \cdot 10^{-28} \lor \neg \left(\ell \leq 1.15 \cdot 10^{-62}\right):\\
\;\;\;\;2 \cdot \left(\ell \cdot J\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\]
Alternative 12 Accuracy 41.5% Cost 456
\[\begin{array}{l}
\mathbf{if}\;\ell \leq -0.0115:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1020:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\]
Alternative 13 Accuracy 53.7% Cost 448
\[U + 2 \cdot \left(\ell \cdot J\right)
\]
Alternative 14 Accuracy 2.7% Cost 64
\[1
\]
Alternative 15 Accuracy 36.3% Cost 64
\[U
\]