
(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 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -10000.0) (not (<= t_0 0.002)))
(+ (* J (* t_0 (cos (* 0.5 K)))) U)
(fma
J
(*
(+
(* 0.016666666666666666 (pow l 5.0))
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))
(cos (/ K 2.0)))
U))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 0.002)) {
tmp = (J * (t_0 * cos((0.5 * K)))) + U;
} else {
tmp = fma(J, (((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))) * cos((K / 2.0))), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 0.002)) tmp = Float64(Float64(J * Float64(t_0 * cos(Float64(0.5 * K)))) + U); else tmp = fma(J, Float64(Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))) * cos(Float64(K / 2.0))), U); end return 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, -10000.0], N[Not[LessEqual[t$95$0, 0.002]], $MachinePrecision]], N[(N[(J * N[(t$95$0 * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(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] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -10000 \lor \neg \left(t_0 \leq 0.002\right):\\
\;\;\;\;J \cdot \left(t_0 \cdot \cos \left(0.5 \cdot K\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right) \cdot \cos \left(\frac{K}{2}\right), U\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -1e4 or 2e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in J around 0 100.0%
if -1e4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2e-3Initial program 72.6%
associate-*l*72.6%
fma-def72.6%
Simplified72.6%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* 0.5 K))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -10000.0) (not (<= t_1 0.002)))
(+ (* J (* t_1 t_0)) U)
(+ U (* J (* t_0 (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((0.5 * K));
double t_1 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -10000.0) || !(t_1 <= 0.002)) {
tmp = (J * (t_1 * t_0)) + U;
} else {
tmp = U + (J * (t_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((0.5d0 * k))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-10000.0d0)) .or. (.not. (t_1 <= 0.002d0))) then
tmp = (j * (t_1 * t_0)) + u
else
tmp = u + (j * (t_0 * ((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((0.5 * K));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -10000.0) || !(t_1 <= 0.002)) {
tmp = (J * (t_1 * t_0)) + U;
} else {
tmp = U + (J * (t_0 * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((0.5 * K)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -10000.0) or not (t_1 <= 0.002): tmp = (J * (t_1 * t_0)) + U else: tmp = U + (J * (t_0 * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(0.5 * K)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= -10000.0) || !(t_1 <= 0.002)) tmp = Float64(Float64(J * Float64(t_1 * t_0)) + U); else tmp = Float64(U + Float64(J * Float64(t_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((0.5 * K)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -10000.0) || ~((t_1 <= 0.002))) tmp = (J * (t_1 * t_0)) + U; else tmp = U + (J * (t_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[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -10000.0], N[Not[LessEqual[t$95$1, 0.002]], $MachinePrecision]], N[(N[(J * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(t$95$0 * 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(0.5 \cdot K\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -10000 \lor \neg \left(t_1 \leq 0.002\right):\\
\;\;\;\;J \cdot \left(t_1 \cdot t_0\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(t_0 \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))) < -1e4 or 2e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in J around 0 100.0%
if -1e4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2e-3Initial program 72.6%
Taylor expanded in J around 0 72.6%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -10000.0) (not (<= t_0 0.002)))
(+ U (* t_0 J))
(+ U (* 2.0 (* J (* l (cos (* 0.5 K)))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 0.002)) {
tmp = U + (t_0 * J);
} else {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
}
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 <= (-10000.0d0)) .or. (.not. (t_0 <= 0.002d0))) then
tmp = u + (t_0 * j)
else
tmp = u + (2.0d0 * (j * (l * cos((0.5d0 * k)))))
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 <= -10000.0) || !(t_0 <= 0.002)) {
tmp = U + (t_0 * J);
} else {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -10000.0) or not (t_0 <= 0.002): tmp = U + (t_0 * J) else: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 0.002)) tmp = Float64(U + Float64(t_0 * J)); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -10000.0) || ~((t_0 <= 0.002))) tmp = U + (t_0 * J); else tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); 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, -10000.0], N[Not[LessEqual[t$95$0, 0.002]], $MachinePrecision]], N[(U + N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -10000 \lor \neg \left(t_0 \leq 0.002\right):\\
\;\;\;\;U + t_0 \cdot J\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -1e4 or 2e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 73.3%
if -1e4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2e-3Initial program 72.6%
Taylor expanded in l around 0 99.4%
Final simplification85.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* 0.5 K))) (t_1 (cos (/ K 2.0))))
(if (<= t_1 -0.9)
(+ U (* 2.0 (* J (* l t_0))))
(if (<= t_1 -0.58)
(+ U (* J (* l (+ 2.0 (* (pow K 2.0) -0.25)))))
(if (<= t_1 0.15)
(+ U (* 2.0 (* l (* J t_0))))
(+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((0.5 * K));
double t_1 = cos((K / 2.0));
double tmp;
if (t_1 <= -0.9) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (t_1 <= -0.58) {
tmp = U + (J * (l * (2.0 + (pow(K, 2.0) * -0.25))));
} else if (t_1 <= 0.15) {
tmp = U + (2.0 * (l * (J * t_0)));
} else {
tmp = U + (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((0.5d0 * k))
t_1 = cos((k / 2.0d0))
if (t_1 <= (-0.9d0)) then
tmp = u + (2.0d0 * (j * (l * t_0)))
else if (t_1 <= (-0.58d0)) then
tmp = u + (j * (l * (2.0d0 + ((k ** 2.0d0) * (-0.25d0)))))
else if (t_1 <= 0.15d0) then
tmp = u + (2.0d0 * (l * (j * t_0)))
else
tmp = u + (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((0.5 * K));
double t_1 = Math.cos((K / 2.0));
double tmp;
if (t_1 <= -0.9) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (t_1 <= -0.58) {
tmp = U + (J * (l * (2.0 + (Math.pow(K, 2.0) * -0.25))));
} else if (t_1 <= 0.15) {
tmp = U + (2.0 * (l * (J * t_0)));
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((0.5 * K)) t_1 = math.cos((K / 2.0)) tmp = 0 if t_1 <= -0.9: tmp = U + (2.0 * (J * (l * t_0))) elif t_1 <= -0.58: tmp = U + (J * (l * (2.0 + (math.pow(K, 2.0) * -0.25)))) elif t_1 <= 0.15: tmp = U + (2.0 * (l * (J * t_0))) else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(0.5 * K)) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_1 <= -0.9) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); elseif (t_1 <= -0.58) tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64((K ^ 2.0) * -0.25))))); elseif (t_1 <= 0.15) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * t_0)))); else tmp = Float64(U + 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((0.5 * K)); t_1 = cos((K / 2.0)); tmp = 0.0; if (t_1 <= -0.9) tmp = U + (2.0 * (J * (l * t_0))); elseif (t_1 <= -0.58) tmp = U + (J * (l * (2.0 + ((K ^ 2.0) * -0.25)))); elseif (t_1 <= 0.15) tmp = U + (2.0 * (l * (J * t_0))); else tmp = U + (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[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.9], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.58], N[(U + N[(J * N[(l * N[(2.0 + N[(N[Power[K, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.15], N[(U + N[(2.0 * N[(l * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_1 \leq -0.9:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_0\right)\right)\\
\mathbf{elif}\;t_1 \leq -0.58:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + {K}^{2} \cdot -0.25\right)\right)\\
\mathbf{elif}\;t_1 \leq 0.15:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.900000000000000022Initial program 76.4%
Taylor expanded in l around 0 71.5%
if -0.900000000000000022 < (cos.f64 (/.f64 K 2)) < -0.57999999999999996Initial program 95.2%
Taylor expanded in l around 0 42.7%
associate-*r*42.8%
*-commutative42.8%
associate-*l*42.7%
Simplified42.7%
Taylor expanded in K around 0 70.4%
+-commutative70.4%
metadata-eval70.4%
metadata-eval70.4%
distribute-lft-neg-in70.4%
associate-*l*70.4%
*-commutative70.4%
associate-*r*70.4%
distribute-lft-neg-in70.4%
*-commutative70.4%
associate-*l*70.4%
*-commutative70.4%
distribute-neg-in70.4%
distribute-lft-in80.4%
distribute-rgt-neg-in80.4%
associate-*r*80.4%
distribute-rgt-out80.4%
Simplified80.4%
if -0.57999999999999996 < (cos.f64 (/.f64 K 2)) < 0.149999999999999994Initial program 84.8%
Taylor expanded in l around 0 65.8%
associate-*r*65.8%
*-commutative65.8%
associate-*l*65.9%
Simplified65.9%
if 0.149999999999999994 < (cos.f64 (/.f64 K 2)) Initial program 87.9%
Taylor expanded in J around 0 87.9%
Taylor expanded in l around 0 86.2%
*-commutative86.2%
associate-*r*86.2%
*-commutative86.2%
associate-*r*86.2%
distribute-rgt-out86.2%
+-commutative86.2%
associate-*r*86.2%
associate-*r*86.2%
distribute-rgt-out86.2%
*-commutative86.2%
*-commutative86.2%
Simplified86.2%
Taylor expanded in K around 0 82.8%
Final simplification79.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* (- (exp l) (exp (- l))) J)))
(t_1 (cos (* 0.5 K)))
(t_2 (* t_1 (* J (* 0.016666666666666666 (pow l 5.0))))))
(if (<= l -1.3e+64)
t_2
(if (<= l -0.235)
t_0
(if (<= l 0.0028)
(+ U (* J (* t_1 (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 2e+52) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((exp(l) - exp(-l)) * J);
double t_1 = cos((0.5 * K));
double t_2 = t_1 * (J * (0.016666666666666666 * pow(l, 5.0)));
double tmp;
if (l <= -1.3e+64) {
tmp = t_2;
} else if (l <= -0.235) {
tmp = t_0;
} else if (l <= 0.0028) {
tmp = U + (J * (t_1 * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2e+52) {
tmp = t_0;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = u + ((exp(l) - exp(-l)) * j)
t_1 = cos((0.5d0 * k))
t_2 = t_1 * (j * (0.016666666666666666d0 * (l ** 5.0d0)))
if (l <= (-1.3d+64)) then
tmp = t_2
else if (l <= (-0.235d0)) then
tmp = t_0
else if (l <= 0.0028d0) then
tmp = u + (j * (t_1 * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 2d+52) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + ((Math.exp(l) - Math.exp(-l)) * J);
double t_1 = Math.cos((0.5 * K));
double t_2 = t_1 * (J * (0.016666666666666666 * Math.pow(l, 5.0)));
double tmp;
if (l <= -1.3e+64) {
tmp = t_2;
} else if (l <= -0.235) {
tmp = t_0;
} else if (l <= 0.0028) {
tmp = U + (J * (t_1 * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2e+52) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.exp(l) - math.exp(-l)) * J) t_1 = math.cos((0.5 * K)) t_2 = t_1 * (J * (0.016666666666666666 * math.pow(l, 5.0))) tmp = 0 if l <= -1.3e+64: tmp = t_2 elif l <= -0.235: tmp = t_0 elif l <= 0.0028: tmp = U + (J * (t_1 * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 2e+52: tmp = t_0 else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) t_1 = cos(Float64(0.5 * K)) t_2 = Float64(t_1 * Float64(J * Float64(0.016666666666666666 * (l ^ 5.0)))) tmp = 0.0 if (l <= -1.3e+64) tmp = t_2; elseif (l <= -0.235) tmp = t_0; elseif (l <= 0.0028) tmp = Float64(U + Float64(J * Float64(t_1 * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 2e+52) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((exp(l) - exp(-l)) * J); t_1 = cos((0.5 * K)); t_2 = t_1 * (J * (0.016666666666666666 * (l ^ 5.0))); tmp = 0.0; if (l <= -1.3e+64) tmp = t_2; elseif (l <= -0.235) tmp = t_0; elseif (l <= 0.0028) tmp = U + (J * (t_1 * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 2e+52) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(J * N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.3e+64], t$95$2, If[LessEqual[l, -0.235], t$95$0, If[LessEqual[l, 0.0028], N[(U + N[(J * N[(t$95$1 * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2e+52], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
t_1 := \cos \left(0.5 \cdot K\right)\\
t_2 := t_1 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5}\right)\right)\\
\mathbf{if}\;\ell \leq -1.3 \cdot 10^{+64}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -0.235:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 0.0028:\\
\;\;\;\;U + J \cdot \left(t_1 \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -1.29999999999999998e64 or 2e52 < l Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in l around 0 98.2%
Taylor expanded in l around inf 98.3%
associate-*r*98.3%
*-commutative98.3%
associate-*r*98.3%
*-commutative98.3%
associate-*r*98.3%
*-commutative98.3%
Simplified98.3%
if -1.29999999999999998e64 < l < -0.23499999999999999 or 0.00279999999999999997 < l < 2e52Initial program 99.9%
Taylor expanded in K around 0 78.7%
if -0.23499999999999999 < l < 0.00279999999999999997Initial program 72.6%
Taylor expanded in J around 0 72.6%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification97.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* (- (exp l) (exp (- l))) J)))
(t_1 (cos (* 0.5 K)))
(t_2 (* t_1 (* J (* 0.016666666666666666 (pow l 5.0))))))
(if (<= l -1.3e+64)
t_2
(if (<= l -0.28)
t_0
(if (<= l 0.003)
(+ U (* 2.0 (* J (* l t_1))))
(if (<= l 1.05e+54) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((exp(l) - exp(-l)) * J);
double t_1 = cos((0.5 * K));
double t_2 = t_1 * (J * (0.016666666666666666 * pow(l, 5.0)));
double tmp;
if (l <= -1.3e+64) {
tmp = t_2;
} else if (l <= -0.28) {
tmp = t_0;
} else if (l <= 0.003) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 1.05e+54) {
tmp = t_0;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = u + ((exp(l) - exp(-l)) * j)
t_1 = cos((0.5d0 * k))
t_2 = t_1 * (j * (0.016666666666666666d0 * (l ** 5.0d0)))
if (l <= (-1.3d+64)) then
tmp = t_2
else if (l <= (-0.28d0)) then
tmp = t_0
else if (l <= 0.003d0) then
tmp = u + (2.0d0 * (j * (l * t_1)))
else if (l <= 1.05d+54) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + ((Math.exp(l) - Math.exp(-l)) * J);
double t_1 = Math.cos((0.5 * K));
double t_2 = t_1 * (J * (0.016666666666666666 * Math.pow(l, 5.0)));
double tmp;
if (l <= -1.3e+64) {
tmp = t_2;
} else if (l <= -0.28) {
tmp = t_0;
} else if (l <= 0.003) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 1.05e+54) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.exp(l) - math.exp(-l)) * J) t_1 = math.cos((0.5 * K)) t_2 = t_1 * (J * (0.016666666666666666 * math.pow(l, 5.0))) tmp = 0 if l <= -1.3e+64: tmp = t_2 elif l <= -0.28: tmp = t_0 elif l <= 0.003: tmp = U + (2.0 * (J * (l * t_1))) elif l <= 1.05e+54: tmp = t_0 else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) t_1 = cos(Float64(0.5 * K)) t_2 = Float64(t_1 * Float64(J * Float64(0.016666666666666666 * (l ^ 5.0)))) tmp = 0.0 if (l <= -1.3e+64) tmp = t_2; elseif (l <= -0.28) tmp = t_0; elseif (l <= 0.003) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_1)))); elseif (l <= 1.05e+54) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((exp(l) - exp(-l)) * J); t_1 = cos((0.5 * K)); t_2 = t_1 * (J * (0.016666666666666666 * (l ^ 5.0))); tmp = 0.0; if (l <= -1.3e+64) tmp = t_2; elseif (l <= -0.28) tmp = t_0; elseif (l <= 0.003) tmp = U + (2.0 * (J * (l * t_1))); elseif (l <= 1.05e+54) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(J * N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.3e+64], t$95$2, If[LessEqual[l, -0.28], t$95$0, If[LessEqual[l, 0.003], N[(U + N[(2.0 * N[(J * N[(l * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.05e+54], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
t_1 := \cos \left(0.5 \cdot K\right)\\
t_2 := t_1 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5}\right)\right)\\
\mathbf{if}\;\ell \leq -1.3 \cdot 10^{+64}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -0.28:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 0.003:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_1\right)\right)\\
\mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+54}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -1.29999999999999998e64 or 1.04999999999999993e54 < l Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in l around 0 98.2%
Taylor expanded in l around inf 98.3%
associate-*r*98.3%
*-commutative98.3%
associate-*r*98.3%
*-commutative98.3%
associate-*r*98.3%
*-commutative98.3%
Simplified98.3%
if -1.29999999999999998e64 < l < -0.28000000000000003 or 0.0030000000000000001 < l < 1.04999999999999993e54Initial program 99.9%
Taylor expanded in K around 0 78.7%
if -0.28000000000000003 < l < 0.0030000000000000001Initial program 72.6%
Taylor expanded in l around 0 99.4%
Final simplification96.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* J (* l (+ 2.0 (* (pow K 2.0) -0.25)))))))
(if (<= l -1.9e+164)
t_0
(if (<= l -60000000000000.0)
(+ U (* (pow K 2.0) (* J -0.03125)))
(if (or (<= l -2700000000.0) (not (<= l 3.5e+15)))
t_0
(+ U (* 2.0 (* J (* l (cos (* 0.5 K)))))))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * (2.0 + (pow(K, 2.0) * -0.25))));
double tmp;
if (l <= -1.9e+164) {
tmp = t_0;
} else if (l <= -60000000000000.0) {
tmp = U + (pow(K, 2.0) * (J * -0.03125));
} else if ((l <= -2700000000.0) || !(l <= 3.5e+15)) {
tmp = t_0;
} else {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
}
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 = u + (j * (l * (2.0d0 + ((k ** 2.0d0) * (-0.25d0)))))
if (l <= (-1.9d+164)) then
tmp = t_0
else if (l <= (-60000000000000.0d0)) then
tmp = u + ((k ** 2.0d0) * (j * (-0.03125d0)))
else if ((l <= (-2700000000.0d0)) .or. (.not. (l <= 3.5d+15))) then
tmp = t_0
else
tmp = u + (2.0d0 * (j * (l * cos((0.5d0 * k)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * (2.0 + (Math.pow(K, 2.0) * -0.25))));
double tmp;
if (l <= -1.9e+164) {
tmp = t_0;
} else if (l <= -60000000000000.0) {
tmp = U + (Math.pow(K, 2.0) * (J * -0.03125));
} else if ((l <= -2700000000.0) || !(l <= 3.5e+15)) {
tmp = t_0;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (J * (l * (2.0 + (math.pow(K, 2.0) * -0.25)))) tmp = 0 if l <= -1.9e+164: tmp = t_0 elif l <= -60000000000000.0: tmp = U + (math.pow(K, 2.0) * (J * -0.03125)) elif (l <= -2700000000.0) or not (l <= 3.5e+15): tmp = t_0 else: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64((K ^ 2.0) * -0.25))))) tmp = 0.0 if (l <= -1.9e+164) tmp = t_0; elseif (l <= -60000000000000.0) tmp = Float64(U + Float64((K ^ 2.0) * Float64(J * -0.03125))); elseif ((l <= -2700000000.0) || !(l <= 3.5e+15)) tmp = t_0; else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (J * (l * (2.0 + ((K ^ 2.0) * -0.25)))); tmp = 0.0; if (l <= -1.9e+164) tmp = t_0; elseif (l <= -60000000000000.0) tmp = U + ((K ^ 2.0) * (J * -0.03125)); elseif ((l <= -2700000000.0) || ~((l <= 3.5e+15))) tmp = t_0; else tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(l * N[(2.0 + N[(N[Power[K, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e+164], t$95$0, If[LessEqual[l, -60000000000000.0], N[(U + N[(N[Power[K, 2.0], $MachinePrecision] * N[(J * -0.03125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, -2700000000.0], N[Not[LessEqual[l, 3.5e+15]], $MachinePrecision]], t$95$0, N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot \left(2 + {K}^{2} \cdot -0.25\right)\right)\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+164}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -60000000000000:\\
\;\;\;\;U + {K}^{2} \cdot \left(J \cdot -0.03125\right)\\
\mathbf{elif}\;\ell \leq -2700000000 \lor \neg \left(\ell \leq 3.5 \cdot 10^{+15}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\end{array}
\end{array}
if l < -1.90000000000000011e164 or -6e13 < l < -2.7e9 or 3.5e15 < l Initial program 100.0%
Taylor expanded in l around 0 35.8%
associate-*r*35.8%
*-commutative35.8%
associate-*l*35.8%
Simplified35.8%
Taylor expanded in K around 0 37.4%
+-commutative37.4%
metadata-eval37.4%
metadata-eval37.4%
distribute-lft-neg-in37.4%
associate-*l*37.4%
*-commutative37.4%
associate-*r*37.4%
distribute-lft-neg-in37.4%
*-commutative37.4%
associate-*l*37.4%
*-commutative37.4%
distribute-neg-in37.4%
distribute-lft-in47.7%
distribute-rgt-neg-in47.7%
associate-*r*47.7%
distribute-rgt-out47.7%
Simplified47.7%
if -1.90000000000000011e164 < l < -6e13Initial program 100.0%
Applied egg-rr1.6%
Taylor expanded in K around 0 32.8%
Taylor expanded in K around inf 33.0%
*-commutative33.0%
*-commutative33.0%
associate-*l*33.0%
Simplified33.0%
if -2.7e9 < l < 3.5e15Initial program 74.3%
Taylor expanded in l around 0 94.4%
Final simplification69.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* J (* l 2.0)))))
(if (<= l -4e+166)
t_0
(if (<= l -19500000000000.0)
(+ U (* (pow K 2.0) (* J -0.03125)))
(if (or (<= l 1.8e+15) (not (<= l 2.7e+177))) t_0 (pow U -3.0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * 2.0));
double tmp;
if (l <= -4e+166) {
tmp = t_0;
} else if (l <= -19500000000000.0) {
tmp = U + (pow(K, 2.0) * (J * -0.03125));
} else if ((l <= 1.8e+15) || !(l <= 2.7e+177)) {
tmp = t_0;
} else {
tmp = pow(U, -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 = u + (j * (l * 2.0d0))
if (l <= (-4d+166)) then
tmp = t_0
else if (l <= (-19500000000000.0d0)) then
tmp = u + ((k ** 2.0d0) * (j * (-0.03125d0)))
else if ((l <= 1.8d+15) .or. (.not. (l <= 2.7d+177))) then
tmp = t_0
else
tmp = u ** (-3.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * 2.0));
double tmp;
if (l <= -4e+166) {
tmp = t_0;
} else if (l <= -19500000000000.0) {
tmp = U + (Math.pow(K, 2.0) * (J * -0.03125));
} else if ((l <= 1.8e+15) || !(l <= 2.7e+177)) {
tmp = t_0;
} else {
tmp = Math.pow(U, -3.0);
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (J * (l * 2.0)) tmp = 0 if l <= -4e+166: tmp = t_0 elif l <= -19500000000000.0: tmp = U + (math.pow(K, 2.0) * (J * -0.03125)) elif (l <= 1.8e+15) or not (l <= 2.7e+177): tmp = t_0 else: tmp = math.pow(U, -3.0) return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(J * Float64(l * 2.0))) tmp = 0.0 if (l <= -4e+166) tmp = t_0; elseif (l <= -19500000000000.0) tmp = Float64(U + Float64((K ^ 2.0) * Float64(J * -0.03125))); elseif ((l <= 1.8e+15) || !(l <= 2.7e+177)) tmp = t_0; else tmp = U ^ -3.0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (J * (l * 2.0)); tmp = 0.0; if (l <= -4e+166) tmp = t_0; elseif (l <= -19500000000000.0) tmp = U + ((K ^ 2.0) * (J * -0.03125)); elseif ((l <= 1.8e+15) || ~((l <= 2.7e+177))) tmp = t_0; else tmp = U ^ -3.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4e+166], t$95$0, If[LessEqual[l, -19500000000000.0], N[(U + N[(N[Power[K, 2.0], $MachinePrecision] * N[(J * -0.03125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 1.8e+15], N[Not[LessEqual[l, 2.7e+177]], $MachinePrecision]], t$95$0, N[Power[U, -3.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+166}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -19500000000000:\\
\;\;\;\;U + {K}^{2} \cdot \left(J \cdot -0.03125\right)\\
\mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+15} \lor \neg \left(\ell \leq 2.7 \cdot 10^{+177}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{U}^{-3}\\
\end{array}
\end{array}
if l < -3.99999999999999976e166 or -1.95e13 < l < 1.8e15 or 2.69999999999999991e177 < l Initial program 82.5%
Taylor expanded in l around 0 79.3%
Taylor expanded in K around 0 68.0%
*-commutative68.0%
associate-*r*68.0%
Simplified68.0%
if -3.99999999999999976e166 < l < -1.95e13Initial program 100.0%
Applied egg-rr1.6%
Taylor expanded in K around 0 32.8%
Taylor expanded in K around inf 33.0%
*-commutative33.0%
*-commutative33.0%
associate-*l*33.0%
Simplified33.0%
if 1.8e15 < l < 2.69999999999999991e177Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr28.0%
Final simplification57.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l 1.8e+15) (not (<= l 2.7e+177))) (+ U (* J (* l 2.0))) (pow U -3.0)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 1.8e+15) || !(l <= 2.7e+177)) {
tmp = U + (J * (l * 2.0));
} else {
tmp = pow(U, -3.0);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= 1.8d+15) .or. (.not. (l <= 2.7d+177))) then
tmp = u + (j * (l * 2.0d0))
else
tmp = u ** (-3.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 1.8e+15) || !(l <= 2.7e+177)) {
tmp = U + (J * (l * 2.0));
} else {
tmp = Math.pow(U, -3.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= 1.8e+15) or not (l <= 2.7e+177): tmp = U + (J * (l * 2.0)) else: tmp = math.pow(U, -3.0) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= 1.8e+15) || !(l <= 2.7e+177)) tmp = Float64(U + Float64(J * Float64(l * 2.0))); else tmp = U ^ -3.0; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= 1.8e+15) || ~((l <= 2.7e+177))) tmp = U + (J * (l * 2.0)); else tmp = U ^ -3.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, 1.8e+15], N[Not[LessEqual[l, 2.7e+177]], $MachinePrecision]], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -3.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.8 \cdot 10^{+15} \lor \neg \left(\ell \leq 2.7 \cdot 10^{+177}\right):\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;{U}^{-3}\\
\end{array}
\end{array}
if l < 1.8e15 or 2.69999999999999991e177 < l Initial program 85.1%
Taylor expanded in l around 0 69.6%
Taylor expanded in K around 0 59.5%
*-commutative59.5%
associate-*r*59.5%
Simplified59.5%
if 1.8e15 < l < 2.69999999999999991e177Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr28.0%
Final simplification54.9%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* 0.5 K)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * cos((0.5 * K)))));
}
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((0.5d0 * k)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((0.5 * K)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)
\end{array}
Initial program 87.2%
Taylor expanded in l around 0 62.0%
Final simplification62.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -200000000000.0) (not (<= l 1000.0))) (* U (+ U -1.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -200000000000.0) || !(l <= 1000.0)) {
tmp = U * (U + -1.0);
} 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 <= (-200000000000.0d0)) .or. (.not. (l <= 1000.0d0))) then
tmp = u * (u + (-1.0d0))
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 <= -200000000000.0) || !(l <= 1000.0)) {
tmp = U * (U + -1.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -200000000000.0) or not (l <= 1000.0): tmp = U * (U + -1.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -200000000000.0) || !(l <= 1000.0)) tmp = Float64(U * Float64(U + -1.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -200000000000.0) || ~((l <= 1000.0))) tmp = U * (U + -1.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -200000000000.0], N[Not[LessEqual[l, 1000.0]], $MachinePrecision]], N[(U * N[(U + -1.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -200000000000 \lor \neg \left(\ell \leq 1000\right):\\
\;\;\;\;U \cdot \left(U + -1\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -2e11 or 1e3 < l Initial program 100.0%
Taylor expanded in l around 0 29.6%
associate-*r*29.6%
*-commutative29.6%
associate-*l*29.6%
Simplified29.6%
Applied egg-rr12.4%
fma-udef12.4%
neg-mul-112.4%
distribute-rgt-out12.4%
Simplified12.4%
if -2e11 < l < 1e3Initial program 73.7%
associate-*l*73.7%
fma-def73.7%
Simplified73.7%
Taylor expanded in J around 0 68.0%
Final simplification39.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -41000000000.0) (not (<= l 620.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -41000000000.0) || !(l <= 620.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 <= (-41000000000.0d0)) .or. (.not. (l <= 620.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 <= -41000000000.0) || !(l <= 620.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -41000000000.0) or not (l <= 620.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -41000000000.0) || !(l <= 620.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 <= -41000000000.0) || ~((l <= 620.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -41000000000.0], N[Not[LessEqual[l, 620.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -41000000000 \lor \neg \left(\ell \leq 620\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -4.1e10 or 620 < l Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr12.4%
if -4.1e10 < l < 620Initial program 73.7%
associate-*l*73.7%
fma-def73.7%
Simplified73.7%
Taylor expanded in J around 0 68.0%
Final simplification39.3%
(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 87.2%
Taylor expanded in l around 0 62.0%
Taylor expanded in K around 0 51.6%
*-commutative51.6%
associate-*r*51.6%
Simplified51.6%
Final simplification51.6%
(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 87.2%
associate-*l*87.3%
fma-def87.3%
Simplified87.3%
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 87.2%
associate-*l*87.3%
fma-def87.3%
Simplified87.3%
Taylor expanded in J around 0 34.1%
Final simplification34.1%
herbie shell --seed 2024011
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))