
(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 15 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 -1e+20) (not (<= t_1 0.001)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(+
(* 0.016666666666666666 (* J (pow l 5.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 <= -1e+20) || !(t_1 <= 0.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((0.016666666666666666 * (J * pow(l, 5.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 <= (-1d+20)) .or. (.not. (t_1 <= 0.001d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * ((0.016666666666666666d0 * (j * (l ** 5.0d0))) + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -1e+20) || !(t_1 <= 0.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((0.016666666666666666 * (J * Math.pow(l, 5.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 <= -1e+20) or not (t_1 <= 0.001): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * ((0.016666666666666666 * (J * math.pow(l, 5.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 <= -1e+20) || !(t_1 <= 0.001)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(Float64(0.016666666666666666 * Float64(J * (l ^ 5.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 <= -1e+20) || ~((t_1 <= 0.001))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * ((0.016666666666666666 * (J * (l ^ 5.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, -1e+20], N[Not[LessEqual[t$95$1, 0.001]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 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 -1 \cdot 10^{+20} \lor \neg \left(t_1 \leq 0.001\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + 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))) < -1e20 or 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -1e20 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3Initial program 79.0%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
distribute-lft-in99.9%
fma-def99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Applied egg-rr99.9%
fma-udef99.9%
*-commutative99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -1e+20) (not (<= t_1 0.001)))
(+ (* (* 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 <= -1e+20) || !(t_1 <= 0.001)) {
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;
}
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 <= (-1d+20)) .or. (.not. (t_1 <= 0.001d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (j * ((0.016666666666666666d0 * (l ** 5.0d0)) + ((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 <= -1e+20) || !(t_1 <= 0.001)) {
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 <= -1e+20) or not (t_1 <= 0.001): 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 <= -1e+20) || !(t_1 <= 0.001)) 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 <= -1e+20) || ~((t_1 <= 0.001))) 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, -1e+20], N[Not[LessEqual[t$95$1, 0.001]], $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 -1 \cdot 10^{+20} \lor \neg \left(t_1 \leq 0.001\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))) < -1e20 or 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -1e20 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3Initial program 79.0%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(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.001)))
(+ (* (* 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.001)) {
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.001d0))) 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.001)) {
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.001): 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.001)) 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.001))) 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.001]], $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.001\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 1e-3 < (-.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))) < 1e-3Initial program 78.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 (+ U (* t_0 (* (pow l 7.0) (* J 0.0003968253968253968))))))
(if (<= l -5.6)
t_1
(if (<= l 0.00195)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 5.6e+43) (+ (* (- (exp l) (exp (- l))) J) U) 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, 7.0) * (J * 0.0003968253968253968)));
double tmp;
if (l <= -5.6) {
tmp = t_1;
} else if (l <= 0.00195) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5.6e+43) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} 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 ** 7.0d0) * (j * 0.0003968253968253968d0)))
if (l <= (-5.6d0)) then
tmp = t_1
else if (l <= 0.00195d0) then
tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 5.6d+43) then
tmp = ((exp(l) - exp(-l)) * j) + u
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, 7.0) * (J * 0.0003968253968253968)));
double tmp;
if (l <= -5.6) {
tmp = t_1;
} else if (l <= 0.00195) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5.6e+43) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} 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, 7.0) * (J * 0.0003968253968253968))) tmp = 0 if l <= -5.6: tmp = t_1 elif l <= 0.00195: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 5.6e+43: tmp = ((math.exp(l) - math.exp(-l)) * J) + U 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 ^ 7.0) * Float64(J * 0.0003968253968253968)))) tmp = 0.0 if (l <= -5.6) tmp = t_1; elseif (l <= 0.00195) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 5.6e+43) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); 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 ^ 7.0) * (J * 0.0003968253968253968))); tmp = 0.0; if (l <= -5.6) tmp = t_1; elseif (l <= 0.00195) tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 5.6e+43) tmp = ((exp(l) - exp(-l)) * J) + U; 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, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.6], t$95$1, If[LessEqual[l, 0.00195], 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], If[LessEqual[l, 5.6e+43], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $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}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
\mathbf{if}\;\ell \leq -5.6:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.00195:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+43}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -5.5999999999999996 or 5.60000000000000038e43 < l Initial program 100.0%
Taylor expanded in l around 0 95.3%
Taylor expanded in l around inf 95.3%
associate-*r*95.3%
*-commutative95.3%
*-commutative95.3%
Simplified95.3%
if -5.5999999999999996 < l < 0.0019499999999999999Initial program 79.0%
Taylor expanded in l around 0 99.7%
if 0.0019499999999999999 < l < 5.60000000000000038e43Initial program 100.0%
Taylor expanded in K around 0 92.3%
Final simplification97.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 7.0) (* J 0.0003968253968253968))))))
(if (<= l -4.2)
t_1
(if (<= l 2.2e-9)
(+ U (* t_0 (* l (* J 2.0))))
(if (<= l 5.6e+43) (+ (* (- (exp l) (exp (- l))) J) U) 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, 7.0) * (J * 0.0003968253968253968)));
double tmp;
if (l <= -4.2) {
tmp = t_1;
} else if (l <= 2.2e-9) {
tmp = U + (t_0 * (l * (J * 2.0)));
} else if (l <= 5.6e+43) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} 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 ** 7.0d0) * (j * 0.0003968253968253968d0)))
if (l <= (-4.2d0)) then
tmp = t_1
else if (l <= 2.2d-9) then
tmp = u + (t_0 * (l * (j * 2.0d0)))
else if (l <= 5.6d+43) then
tmp = ((exp(l) - exp(-l)) * j) + u
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, 7.0) * (J * 0.0003968253968253968)));
double tmp;
if (l <= -4.2) {
tmp = t_1;
} else if (l <= 2.2e-9) {
tmp = U + (t_0 * (l * (J * 2.0)));
} else if (l <= 5.6e+43) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} 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, 7.0) * (J * 0.0003968253968253968))) tmp = 0 if l <= -4.2: tmp = t_1 elif l <= 2.2e-9: tmp = U + (t_0 * (l * (J * 2.0))) elif l <= 5.6e+43: tmp = ((math.exp(l) - math.exp(-l)) * J) + U 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 ^ 7.0) * Float64(J * 0.0003968253968253968)))) tmp = 0.0 if (l <= -4.2) tmp = t_1; elseif (l <= 2.2e-9) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(J * 2.0)))); elseif (l <= 5.6e+43) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); 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 ^ 7.0) * (J * 0.0003968253968253968))); tmp = 0.0; if (l <= -4.2) tmp = t_1; elseif (l <= 2.2e-9) tmp = U + (t_0 * (l * (J * 2.0))); elseif (l <= 5.6e+43) tmp = ((exp(l) - exp(-l)) * J) + U; 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, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.2], t$95$1, If[LessEqual[l, 2.2e-9], N[(U + N[(t$95$0 * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.6e+43], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $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}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
\mathbf{if}\;\ell \leq -4.2:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-9}:\\
\;\;\;\;U + t_0 \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+43}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -4.20000000000000018 or 5.60000000000000038e43 < l Initial program 100.0%
Taylor expanded in l around 0 95.3%
Taylor expanded in l around inf 95.3%
associate-*r*95.3%
*-commutative95.3%
*-commutative95.3%
Simplified95.3%
if -4.20000000000000018 < l < 2.1999999999999998e-9Initial program 78.7%
Taylor expanded in l around 0 99.2%
associate-*r*99.2%
*-commutative99.2%
Simplified99.2%
if 2.1999999999999998e-9 < l < 5.60000000000000038e43Initial program 99.4%
Taylor expanded in K around 0 92.7%
Final simplification97.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -47.0) (not (<= l 2.2e-9))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -47.0) || !(l <= 2.2e-9)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (cos((K / 2.0)) * (l * (J * 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 <= (-47.0d0)) .or. (.not. (l <= 2.2d-9))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + (cos((k / 2.0d0)) * (l * (j * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -47.0) || !(l <= 2.2e-9)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -47.0) or not (l <= 2.2e-9): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -47.0) || !(l <= 2.2e-9)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -47.0) || ~((l <= 2.2e-9))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (cos((K / 2.0)) * (l * (J * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -47.0], N[Not[LessEqual[l, 2.2e-9]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -47 \lor \neg \left(\ell \leq 2.2 \cdot 10^{-9}\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -47 or 2.1999999999999998e-9 < l Initial program 99.9%
Taylor expanded in K around 0 72.5%
if -47 < l < 2.1999999999999998e-9Initial program 78.9%
Taylor expanded in l around 0 98.4%
associate-*r*98.4%
*-commutative98.4%
Simplified98.4%
Final simplification84.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* l (+ (* J 2.0) (* -0.25 (* J (pow K 2.0)))))))
(t_1 (log1p (expm1 U))))
(if (<= l -9.5e+31)
t_0
(if (<= l 1300000.0)
(+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))
(if (<= l 6.5e+191)
t_1
(if (<= l 1.75e+229) (pow U -4.0) (if (<= l 3.3e+245) t_1 t_0)))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (l * ((J * 2.0) + (-0.25 * (J * pow(K, 2.0)))));
double t_1 = log1p(expm1(U));
double tmp;
if (l <= -9.5e+31) {
tmp = t_0;
} else if (l <= 1300000.0) {
tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
} else if (l <= 6.5e+191) {
tmp = t_1;
} else if (l <= 1.75e+229) {
tmp = pow(U, -4.0);
} else if (l <= 3.3e+245) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + (l * ((J * 2.0) + (-0.25 * (J * Math.pow(K, 2.0)))));
double t_1 = Math.log1p(Math.expm1(U));
double tmp;
if (l <= -9.5e+31) {
tmp = t_0;
} else if (l <= 1300000.0) {
tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
} else if (l <= 6.5e+191) {
tmp = t_1;
} else if (l <= 1.75e+229) {
tmp = Math.pow(U, -4.0);
} else if (l <= 3.3e+245) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (l * ((J * 2.0) + (-0.25 * (J * math.pow(K, 2.0))))) t_1 = math.log1p(math.expm1(U)) tmp = 0 if l <= -9.5e+31: tmp = t_0 elif l <= 1300000.0: tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0))) elif l <= 6.5e+191: tmp = t_1 elif l <= 1.75e+229: tmp = math.pow(U, -4.0) elif l <= 3.3e+245: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(l * Float64(Float64(J * 2.0) + Float64(-0.25 * Float64(J * (K ^ 2.0)))))) t_1 = log1p(expm1(U)) tmp = 0.0 if (l <= -9.5e+31) tmp = t_0; elseif (l <= 1300000.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0)))); elseif (l <= 6.5e+191) tmp = t_1; elseif (l <= 1.75e+229) tmp = U ^ -4.0; elseif (l <= 3.3e+245) tmp = t_1; else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(l * N[(N[(J * 2.0), $MachinePrecision] + N[(-0.25 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[1 + N[(Exp[U] - 1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -9.5e+31], t$95$0, If[LessEqual[l, 1300000.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.5e+191], t$95$1, If[LessEqual[l, 1.75e+229], N[Power[U, -4.0], $MachinePrecision], If[LessEqual[l, 3.3e+245], t$95$1, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \ell \cdot \left(J \cdot 2 + -0.25 \cdot \left(J \cdot {K}^{2}\right)\right)\\
t_1 := \mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\
\mathbf{if}\;\ell \leq -9.5 \cdot 10^{+31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 1300000:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 6.5 \cdot 10^{+191}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 1.75 \cdot 10^{+229}:\\
\;\;\;\;{U}^{-4}\\
\mathbf{elif}\;\ell \leq 3.3 \cdot 10^{+245}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -9.5000000000000008e31 or 3.30000000000000011e245 < l Initial program 100.0%
Taylor expanded in l around 0 29.5%
associate-*r*29.5%
*-commutative29.5%
associate-*l*29.5%
Simplified29.5%
Taylor expanded in K around 0 43.8%
if -9.5000000000000008e31 < l < 1.3e6Initial program 80.6%
Taylor expanded in l around 0 93.8%
associate-*r*93.8%
*-commutative93.8%
Simplified93.8%
if 1.3e6 < l < 6.50000000000000008e191 or 1.7500000000000001e229 < l < 3.30000000000000011e245Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr30.0%
if 6.50000000000000008e191 < l < 1.7500000000000001e229Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr58.3%
Final simplification67.8%
(FPCore (J l K U) :precision binary64 (if (<= l -1.35e+32) (+ U (* l (+ (* J 2.0) (* -0.25 (* J (pow K 2.0)))))) (+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.35e+32) {
tmp = U + (l * ((J * 2.0) + (-0.25 * (J * pow(K, 2.0)))));
} else {
tmp = U + (cos((K / 2.0)) * (l * (J * 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.35d+32)) then
tmp = u + (l * ((j * 2.0d0) + ((-0.25d0) * (j * (k ** 2.0d0)))))
else
tmp = u + (cos((k / 2.0d0)) * (l * (j * 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.35e+32) {
tmp = U + (l * ((J * 2.0) + (-0.25 * (J * Math.pow(K, 2.0)))));
} else {
tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.35e+32: tmp = U + (l * ((J * 2.0) + (-0.25 * (J * math.pow(K, 2.0))))) else: tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.35e+32) tmp = Float64(U + Float64(l * Float64(Float64(J * 2.0) + Float64(-0.25 * Float64(J * (K ^ 2.0)))))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.35e+32) tmp = U + (l * ((J * 2.0) + (-0.25 * (J * (K ^ 2.0))))); else tmp = U + (cos((K / 2.0)) * (l * (J * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.35e+32], N[(U + N[(l * N[(N[(J * 2.0), $MachinePrecision] + N[(-0.25 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.35 \cdot 10^{+32}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2 + -0.25 \cdot \left(J \cdot {K}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -1.35000000000000006e32Initial program 100.0%
Taylor expanded in l around 0 29.6%
associate-*r*29.6%
*-commutative29.6%
associate-*l*29.6%
Simplified29.6%
Taylor expanded in K around 0 46.1%
if -1.35000000000000006e32 < l Initial program 86.8%
Taylor expanded in l around 0 69.2%
associate-*r*69.2%
*-commutative69.2%
Simplified69.2%
Final simplification63.7%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * 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 + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 90.0%
Taylor expanded in l around 0 59.8%
Final simplification59.8%
(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(l * Float64(Float64(J * 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[(l * N[(N[(J * 2.0), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(\left(J \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)
\end{array}
Initial program 90.0%
Taylor expanded in l around 0 59.8%
associate-*r*59.8%
*-commutative59.8%
associate-*l*59.8%
Simplified59.8%
Final simplification59.8%
(FPCore (J l K U) :precision binary64 (+ U (* (cos (/ K 2.0)) (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (l * (J * 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 + (cos((k / 2.0d0)) * (l * (j * 2.0d0)))
end function
public static double code(double J, double l, double K, double U) {
return U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (l * (J * 2.0)))
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0)))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (l * (J * 2.0))); end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)
\end{array}
Initial program 90.0%
Taylor expanded in l around 0 59.8%
associate-*r*59.8%
*-commutative59.8%
Simplified59.8%
Final simplification59.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -360.0) (not (<= l 4200000000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -360.0) || !(l <= 4200000000.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 <= (-360.0d0)) .or. (.not. (l <= 4200000000.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 <= -360.0) || !(l <= 4200000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -360.0) or not (l <= 4200000000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -360.0) || !(l <= 4200000000.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 <= -360.0) || ~((l <= 4200000000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -360.0], N[Not[LessEqual[l, 4200000000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -360 \lor \neg \left(\ell \leq 4200000000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -360 or 4.2e9 < l Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr11.6%
if -360 < l < 4.2e9Initial program 80.0%
*-commutative80.0%
associate-*l*80.0%
fma-def80.0%
Simplified80.0%
Taylor expanded in l around 0 74.2%
Final simplification42.9%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 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 + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 90.0%
Taylor expanded in l around 0 59.8%
associate-*r*59.8%
*-commutative59.8%
Simplified59.8%
Taylor expanded in K around 0 50.2%
+-commutative50.2%
associate-*r*50.2%
Simplified50.2%
Final simplification50.2%
(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 90.0%
*-commutative90.0%
associate-*l*90.0%
fma-def90.0%
Simplified90.0%
Applied egg-rr2.6%
*-inverses2.6%
Simplified2.6%
Final simplification2.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 90.0%
*-commutative90.0%
associate-*l*90.0%
fma-def90.0%
Simplified90.0%
Taylor expanded in l around 0 38.2%
Final simplification38.2%
herbie shell --seed 2023310
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))