
(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 14 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 -0.01) (not (<= t_0 2e-5)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
l
(* (* J (cos (* K 0.5))) (fma 0.3333333333333333 (pow l 2.0) 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -0.01) || !(t_0 <= 2e-5)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (l * ((J * cos((K * 0.5))) * fma(0.3333333333333333, pow(l, 2.0), 2.0)));
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -0.01) || !(t_0 <= 2e-5)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(l * Float64(Float64(J * cos(Float64(K * 0.5))) * fma(0.3333333333333333, (l ^ 2.0), 2.0)))); 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, -0.01], N[Not[LessEqual[t$95$0, 2e-5]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(l * N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -0.01 \lor \neg \left(t\_0 \leq 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{2}, 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.0100000000000000002 or 2.00000000000000016e-5 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2.00000000000000016e-5Initial program 69.5%
Taylor expanded in l around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
distribute-lft-out99.9%
fma-define99.9%
Simplified99.9%
Final simplification99.9%
(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 2e-5)))
(+ (* (* t_1 J) t_0) U)
(+
U
(* t_0 (* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* J 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 <= 2e-5)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (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) :: 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 <= 2d-5))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (l * ((0.3333333333333333d0 * (j * (l ** 2.0d0))) + (j * 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 <= 2e-5)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (J * 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 <= 2e-5): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (J * 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 <= 2e-5)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(J * 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 <= 2e-5))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (J * 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, 2e-5]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 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 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + J \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.0100000000000000002 or 2.00000000000000016e-5 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2.00000000000000016e-5Initial program 69.5%
Taylor expanded in l around 0 99.8%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (pow l 5.0) (* J (* (cos (* K 0.5)) 0.016666666666666666))))))
(if (<= l -6e+76)
t_0
(if (<= l -0.006)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 5.0)
(+
U
(*
(cos (/ K 2.0))
(* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* J 2.0)))))
t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (pow(l, 5.0) * (J * (cos((K * 0.5)) * 0.016666666666666666)));
double tmp;
if (l <= -6e+76) {
tmp = t_0;
} else if (l <= -0.006) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 5.0) {
tmp = U + (cos((K / 2.0)) * (l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (J * 2.0))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = u + ((l ** 5.0d0) * (j * (cos((k * 0.5d0)) * 0.016666666666666666d0)))
if (l <= (-6d+76)) then
tmp = t_0
else if (l <= (-0.006d0)) then
tmp = ((exp(l) - exp(-l)) * j) + u
else if (l <= 5.0d0) then
tmp = u + (cos((k / 2.0d0)) * (l * ((0.3333333333333333d0 * (j * (l ** 2.0d0))) + (j * 2.0d0))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.pow(l, 5.0) * (J * (Math.cos((K * 0.5)) * 0.016666666666666666)));
double tmp;
if (l <= -6e+76) {
tmp = t_0;
} else if (l <= -0.006) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 5.0) {
tmp = U + (Math.cos((K / 2.0)) * (l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (J * 2.0))));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.pow(l, 5.0) * (J * (math.cos((K * 0.5)) * 0.016666666666666666))) tmp = 0 if l <= -6e+76: tmp = t_0 elif l <= -0.006: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 5.0: tmp = U + (math.cos((K / 2.0)) * (l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (J * 2.0)))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64((l ^ 5.0) * Float64(J * Float64(cos(Float64(K * 0.5)) * 0.016666666666666666)))) tmp = 0.0 if (l <= -6e+76) tmp = t_0; elseif (l <= -0.006) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 5.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(J * 2.0))))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((l ^ 5.0) * (J * (cos((K * 0.5)) * 0.016666666666666666))); tmp = 0.0; if (l <= -6e+76) tmp = t_0; elseif (l <= -0.006) tmp = ((exp(l) - exp(-l)) * J) + U; elseif (l <= 5.0) tmp = U + (cos((K / 2.0)) * (l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (J * 2.0)))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -6e+76], t$95$0, If[LessEqual[l, -0.006], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 5.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + {\ell}^{5} \cdot \left(J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -6 \cdot 10^{+76}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -0.006:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 5:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -5.9999999999999996e76 or 5 < l Initial program 100.0%
Taylor expanded in l around 0 95.6%
*-commutative95.6%
Simplified95.6%
Taylor expanded in l around inf 95.6%
*-commutative95.6%
associate-*r*95.6%
associate-*l*95.6%
*-commutative95.6%
*-commutative95.6%
associate-*l*95.6%
Simplified95.6%
if -5.9999999999999996e76 < l < -0.0060000000000000001Initial program 99.7%
Taylor expanded in K around 0 84.7%
if -0.0060000000000000001 < l < 5Initial program 69.5%
Taylor expanded in l around 0 99.8%
Final simplification96.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (pow l 5.0) (* J (* (cos (* K 0.5)) 0.016666666666666666))))))
(if (<= l -5.1e+76)
t_0
(if (<= l -0.006)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 5.0)
(+
U
(*
(cos (/ K 2.0))
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (pow(l, 5.0) * (J * (cos((K * 0.5)) * 0.016666666666666666)));
double tmp;
if (l <= -5.1e+76) {
tmp = t_0;
} else if (l <= -0.006) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 5.0) {
tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = u + ((l ** 5.0d0) * (j * (cos((k * 0.5d0)) * 0.016666666666666666d0)))
if (l <= (-5.1d+76)) then
tmp = t_0
else if (l <= (-0.006d0)) then
tmp = ((exp(l) - exp(-l)) * j) + u
else if (l <= 5.0d0) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.pow(l, 5.0) * (J * (Math.cos((K * 0.5)) * 0.016666666666666666)));
double tmp;
if (l <= -5.1e+76) {
tmp = t_0;
} else if (l <= -0.006) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 5.0) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.pow(l, 5.0) * (J * (math.cos((K * 0.5)) * 0.016666666666666666))) tmp = 0 if l <= -5.1e+76: tmp = t_0 elif l <= -0.006: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 5.0: tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64((l ^ 5.0) * Float64(J * Float64(cos(Float64(K * 0.5)) * 0.016666666666666666)))) tmp = 0.0 if (l <= -5.1e+76) tmp = t_0; elseif (l <= -0.006) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 5.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((l ^ 5.0) * (J * (cos((K * 0.5)) * 0.016666666666666666))); tmp = 0.0; if (l <= -5.1e+76) tmp = t_0; elseif (l <= -0.006) tmp = ((exp(l) - exp(-l)) * J) + U; elseif (l <= 5.0) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.1e+76], t$95$0, If[LessEqual[l, -0.006], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 5.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + {\ell}^{5} \cdot \left(J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -5.1 \cdot 10^{+76}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -0.006:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 5:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -5.1000000000000002e76 or 5 < l Initial program 100.0%
Taylor expanded in l around 0 95.6%
*-commutative95.6%
Simplified95.6%
Taylor expanded in l around inf 95.6%
*-commutative95.6%
associate-*r*95.6%
associate-*l*95.6%
*-commutative95.6%
*-commutative95.6%
associate-*l*95.6%
Simplified95.6%
if -5.1000000000000002e76 < l < -0.0060000000000000001Initial program 99.7%
Taylor expanded in K around 0 84.7%
if -0.0060000000000000001 < l < 5Initial program 69.5%
Taylor expanded in l around 0 99.8%
Final simplification96.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (pow l 5.0) (* J (* t_0 0.016666666666666666))))))
(if (<= l -5.1e+76)
t_1
(if (<= l -0.0048)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 3.3) (+ U (* l (* J (* 2.0 t_0)))) t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + (pow(l, 5.0) * (J * (t_0 * 0.016666666666666666)));
double tmp;
if (l <= -5.1e+76) {
tmp = t_1;
} else if (l <= -0.0048) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 3.3) {
tmp = U + (l * (J * (2.0 * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k * 0.5d0))
t_1 = u + ((l ** 5.0d0) * (j * (t_0 * 0.016666666666666666d0)))
if (l <= (-5.1d+76)) then
tmp = t_1
else if (l <= (-0.0048d0)) then
tmp = ((exp(l) - exp(-l)) * j) + u
else if (l <= 3.3d0) then
tmp = u + (l * (j * (2.0d0 * t_0)))
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 * 0.5));
double t_1 = U + (Math.pow(l, 5.0) * (J * (t_0 * 0.016666666666666666)));
double tmp;
if (l <= -5.1e+76) {
tmp = t_1;
} else if (l <= -0.0048) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 3.3) {
tmp = U + (l * (J * (2.0 * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + (math.pow(l, 5.0) * (J * (t_0 * 0.016666666666666666))) tmp = 0 if l <= -5.1e+76: tmp = t_1 elif l <= -0.0048: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 3.3: tmp = U + (l * (J * (2.0 * t_0))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64((l ^ 5.0) * Float64(J * Float64(t_0 * 0.016666666666666666)))) tmp = 0.0 if (l <= -5.1e+76) tmp = t_1; elseif (l <= -0.0048) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 3.3) tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 * t_0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); t_1 = U + ((l ^ 5.0) * (J * (t_0 * 0.016666666666666666))); tmp = 0.0; if (l <= -5.1e+76) tmp = t_1; elseif (l <= -0.0048) tmp = ((exp(l) - exp(-l)) * J) + U; elseif (l <= 3.3) tmp = U + (l * (J * (2.0 * t_0))); else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * N[(t$95$0 * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.1e+76], t$95$1, If[LessEqual[l, -0.0048], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 3.3], N[(U + N[(l * N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + {\ell}^{5} \cdot \left(J \cdot \left(t\_0 \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -5.1 \cdot 10^{+76}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -0.0048:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 3.3:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -5.1000000000000002e76 or 3.2999999999999998 < l Initial program 100.0%
Taylor expanded in l around 0 95.6%
*-commutative95.6%
Simplified95.6%
Taylor expanded in l around inf 95.6%
*-commutative95.6%
associate-*r*95.6%
associate-*l*95.6%
*-commutative95.6%
*-commutative95.6%
associate-*l*95.6%
Simplified95.6%
if -5.1000000000000002e76 < l < -0.00479999999999999958Initial program 99.7%
Taylor expanded in K around 0 84.7%
if -0.00479999999999999958 < l < 3.2999999999999998Initial program 69.5%
Taylor expanded in l around 0 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in l around 0 99.4%
*-commutative99.4%
associate-*r*99.4%
associate-*l*99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r*99.5%
Simplified99.5%
Final simplification96.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.0004) (not (<= l 2.8e-9))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* l (* J (* 2.0 (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.0004) || !(l <= 2.8e-9)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (l * (J * (2.0 * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-0.0004d0)) .or. (.not. (l <= 2.8d-9))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + (l * (j * (2.0d0 * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.0004) || !(l <= 2.8e-9)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (l * (J * (2.0 * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.0004) or not (l <= 2.8e-9): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (l * (J * (2.0 * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.0004) || !(l <= 2.8e-9)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.0004) || ~((l <= 2.8e-9))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (l * (J * (2.0 * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.0004], N[Not[LessEqual[l, 2.8e-9]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(l * N[(J * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.0004 \lor \neg \left(\ell \leq 2.8 \cdot 10^{-9}\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -4.00000000000000019e-4 or 2.79999999999999984e-9 < l Initial program 99.8%
Taylor expanded in K around 0 74.8%
if -4.00000000000000019e-4 < l < 2.79999999999999984e-9Initial program 69.2%
Taylor expanded in l around 0 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in l around 0 99.6%
*-commutative99.6%
associate-*r*99.6%
associate-*l*99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.7%
Simplified99.7%
Final simplification86.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.05) (+ U (* (* l (pow K 2.0)) (* J -0.25))) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = U + ((l * pow(K, 2.0)) * (J * -0.25));
} else {
tmp = U + (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 (cos((k / 2.0d0)) <= (-0.05d0)) then
tmp = u + ((l * (k ** 2.0d0)) * (j * (-0.25d0)))
else
tmp = u + (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 (Math.cos((K / 2.0)) <= -0.05) {
tmp = U + ((l * Math.pow(K, 2.0)) * (J * -0.25));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.05: tmp = U + ((l * math.pow(K, 2.0)) * (J * -0.25)) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = Float64(U + Float64(Float64(l * (K ^ 2.0)) * Float64(J * -0.25))); else tmp = Float64(U + Float64(l * Float64(J * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.05) tmp = U + ((l * (K ^ 2.0)) * (J * -0.25)); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(U + N[(N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision] * N[(J * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;U + \left(\ell \cdot {K}^{2}\right) \cdot \left(J \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.050000000000000003Initial program 86.1%
Taylor expanded in l around 0 66.2%
associate-*r*66.2%
Simplified66.2%
Taylor expanded in K around 0 46.8%
Taylor expanded in K around inf 61.3%
associate-*r*61.3%
*-commutative61.3%
*-commutative61.3%
*-commutative61.3%
Simplified61.3%
if -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.5%
Taylor expanded in l around 0 93.0%
*-commutative93.0%
Simplified93.0%
Taylor expanded in l around 0 66.6%
*-commutative66.6%
associate-*r*66.6%
associate-*l*66.6%
*-commutative66.6%
*-commutative66.6%
associate-*r*66.6%
Simplified66.6%
Taylor expanded in K around 0 61.4%
Final simplification61.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.05) (+ U (+ (* -0.25 (* J (* l (* K K)))) (* 2.0 (* l J)))) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J)));
} else {
tmp = U + (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 (cos((k / 2.0d0)) <= (-0.05d0)) then
tmp = u + (((-0.25d0) * (j * (l * (k * k)))) + (2.0d0 * (l * j)))
else
tmp = u + (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 (Math.cos((K / 2.0)) <= -0.05) {
tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J)));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.05: tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J))) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = Float64(U + Float64(Float64(-0.25 * Float64(J * Float64(l * Float64(K * K)))) + Float64(2.0 * Float64(l * J)))); else tmp = Float64(U + Float64(l * Float64(J * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.05) tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J))); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(U + N[(N[(-0.25 * N[(J * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;U + \left(-0.25 \cdot \left(J \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.050000000000000003Initial program 86.1%
Taylor expanded in l around 0 66.2%
associate-*r*66.2%
Simplified66.2%
Taylor expanded in K around 0 46.8%
unpow246.8%
Applied egg-rr46.8%
if -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.5%
Taylor expanded in l around 0 93.0%
*-commutative93.0%
Simplified93.0%
Taylor expanded in l around 0 66.6%
*-commutative66.6%
associate-*r*66.6%
associate-*l*66.6%
*-commutative66.6%
*-commutative66.6%
associate-*r*66.6%
Simplified66.6%
Taylor expanded in K around 0 61.4%
Final simplification57.9%
(FPCore (J l K U) :precision binary64 (if (<= (/ K 2.0) 400000000.0) (+ U (* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* J 2.0)))) (+ U (* l (* J (* 2.0 (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 400000000.0) {
tmp = U + (l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (J * 2.0)));
} else {
tmp = U + (l * (J * (2.0 * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((k / 2.0d0) <= 400000000.0d0) then
tmp = u + (l * ((0.3333333333333333d0 * (j * (l ** 2.0d0))) + (j * 2.0d0)))
else
tmp = u + (l * (j * (2.0d0 * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 400000000.0) {
tmp = U + (l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (J * 2.0)));
} else {
tmp = U + (l * (J * (2.0 * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 400000000.0: tmp = U + (l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (J * 2.0))) else: tmp = U + (l * (J * (2.0 * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 400000000.0) tmp = Float64(U + Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(J * 2.0)))); else tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((K / 2.0) <= 400000000.0) tmp = U + (l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (J * 2.0))); else tmp = U + (l * (J * (2.0 * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 400000000.0], N[(U + N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 400000000:\\
\;\;\;\;U + \ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + J \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 4e8Initial program 84.9%
Taylor expanded in l around 0 87.4%
Taylor expanded in K around 0 77.0%
if 4e8 < (/.f64 K #s(literal 2 binary64)) Initial program 84.6%
Taylor expanded in l around 0 92.2%
*-commutative92.2%
Simplified92.2%
Taylor expanded in l around 0 65.5%
*-commutative65.5%
associate-*r*65.5%
associate-*l*65.5%
*-commutative65.5%
*-commutative65.5%
associate-*r*65.5%
Simplified65.5%
Final simplification74.2%
(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 84.9%
Taylor expanded in l around 0 66.5%
Final simplification66.5%
(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(J * Float64(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[(J * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 84.9%
Taylor expanded in l around 0 93.2%
*-commutative93.2%
Simplified93.2%
Taylor expanded in l around 0 66.5%
*-commutative66.5%
associate-*r*66.5%
associate-*l*66.5%
*-commutative66.5%
*-commutative66.5%
associate-*r*66.5%
Simplified66.5%
Final simplification66.5%
(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 84.9%
Taylor expanded in l around 0 93.2%
*-commutative93.2%
Simplified93.2%
Taylor expanded in l around 0 66.5%
*-commutative66.5%
associate-*r*66.5%
associate-*l*66.5%
*-commutative66.5%
*-commutative66.5%
associate-*r*66.5%
Simplified66.5%
Taylor expanded in K around 0 55.4%
Final simplification55.4%
(FPCore (J l K U) :precision binary64 (+ U (* J -4.0)))
double code(double J, double l, double K, double U) {
return U + (J * -4.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 * (-4.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * -4.0);
}
def code(J, l, K, U): return U + (J * -4.0)
function code(J, l, K, U) return Float64(U + Float64(J * -4.0)) end
function tmp = code(J, l, K, U) tmp = U + (J * -4.0); end
code[J_, l_, K_, U_] := N[(U + N[(J * -4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot -4
\end{array}
Initial program 84.9%
Applied egg-rr27.1%
Taylor expanded in K around 0 27.3%
*-commutative27.3%
Simplified27.3%
Final simplification27.3%
(FPCore (J l K U) :precision binary64 (+ U (* J -0.5)))
double code(double J, double l, double K, double U) {
return U + (J * -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 + (j * (-0.5d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * -0.5);
}
def code(J, l, K, U): return U + (J * -0.5)
function code(J, l, K, U) return Float64(U + Float64(J * -0.5)) end
function tmp = code(J, l, K, U) tmp = U + (J * -0.5); end
code[J_, l_, K_, U_] := N[(U + N[(J * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot -0.5
\end{array}
Initial program 84.9%
Applied egg-rr27.1%
Taylor expanded in K around 0 27.3%
*-commutative27.3%
Simplified27.3%
Final simplification27.3%
herbie shell --seed 2024077
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))