47 return 0.5 * std::erfc(x) - 0.5 * sqrtpi_inv * x * std::exp(-x * x);
49 const Real gaussian = std::exp(-x * x);
50 Real occupation_value = 0.5 * std::erfc(x);
51 Real hermite_previous = 1.0;
52 Real hermite_current = 2.0 * x;
53 int hermite_degree = 1;
54 Real coefficient = sqrtpi_inv;
55 for (
int n = 1; n <= order_; ++n) {
56 coefficient *= -1.0 / (4.0 * n);
57 occupation_value += coefficient * hermite_current * gaussian;
58 advance_hermite(x, hermite_previous, hermite_current, hermite_degree);
59 advance_hermite(x, hermite_previous, hermite_current, hermite_degree);
61 return occupation_value;
71 return 0.25 * sqrtpi_inv * (2.0 * x * x - 1.0) * std::exp(-x * x);
73 Real hermite_previous = 1.0;
74 Real hermite_current = 2.0 * x;
75 int hermite_degree = 1;
76 while (hermite_degree < 2 * order_) {
77 advance_hermite(x, hermite_previous, hermite_current, hermite_degree);
79 Real coefficient = sqrtpi_inv;
80 for (
int n = 1; n <= order_; ++n) {
81 coefficient *= -1.0 / (4.0 * n);
83 return -0.5 * coefficient * hermite_current * std::exp(-x * x);