105std::vector<std::vector<cln::cl_N>> Xn;
107const int xninitsizestep = 26;
108int xninitsize = xninitsizestep;
126 std::vector<cln::cl_N> buf(xninitsize);
127 auto it = buf.begin();
129 *it = -(cln::expt(cln::cl_I(2),
n+1) - 1) / cln::expt(cln::cl_I(2),
n+1);
131 for (
int i=2; i<=xninitsize; i++) {
135 result = Xn[0][i/2-1];
137 for (
int k=1;
k<i-1;
k++) {
138 if ( !(((i-
k) & 1) && ((i-
k) > 1)) ) {
139 result = result + cln::binomial(i,
k) * Xn[0][(i-
k)/2-1] * Xn[
n-1][
k-1] / (
k+1);
142 result = result - cln::binomial(i,i-1) * Xn[
n-1][i-2] / 2 / i;
143 result = result + Xn[
n-1][i-1] / (i+1);
151 std::vector<cln::cl_N> buf(xninitsize);
152 auto it = buf.begin();
154 *it = cln::cl_I(-3)/cln::cl_I(4);
156 *it = cln::cl_I(17)/cln::cl_I(36);
158 for (
int i=3; i<=xninitsize; i++) {
160 result = -Xn[0][(i-3)/2]/2;
161 *it = (cln::binomial(i,1)/cln::cl_I(2) + cln::binomial(i,i-1)/cln::cl_I(i))*result;
164 result = Xn[0][i/2-1] + Xn[0][i/2-1]/(i+1);
165 for (
int k=1;
k<i/2;
k++) {
166 result = result + cln::binomial(i,
k*2) * Xn[0][
k-1] * Xn[0][i/2-
k-1] / (
k*2+1);
175 std::vector<cln::cl_N> buf(xninitsize/2);
176 auto it = buf.begin();
177 for (
int i=1; i<=xninitsize/2; i++) {
190 const int pos0 = xninitsize / 2;
192 for (
int i=1; i<=xninitsizestep/2; ++i) {
193 Xn[0].push_back(
bernoulli((i+pos0)*2).to_cl_N());
196 int xend = xninitsize + xninitsizestep;
199 for (
int i=xninitsize+1; i<=xend; ++i) {
201 result = -Xn[0][(i-3)/2]/2;
202 Xn[1].push_back((cln::binomial(i,1)/cln::cl_I(2) + cln::binomial(i,i-1)/cln::cl_I(i))*result);
204 result = Xn[0][i/2-1] + Xn[0][i/2-1]/(i+1);
205 for (
int k=1;
k<i/2;
k++) {
206 result = result + cln::binomial(i,
k*2) * Xn[0][
k-1] * Xn[0][i/2-
k-1] / (
k*2+1);
208 Xn[1].push_back(result);
212 for (
size_t n=2;
n<Xn.size(); ++
n) {
213 for (
int i=xninitsize+1; i<=xend; ++i) {
217 result = Xn[0][i/2-1];
219 for (
int k=1;
k<i-1; ++
k) {
220 if ( !(((i-
k) & 1) && ((i-
k) > 1)) ) {
221 result = result + cln::binomial(i,
k) * Xn[0][(i-
k)/2-1] * Xn[
n-1][
k-1] / (
k+1);
224 result = result - cln::binomial(i,i-1) * Xn[
n-1][i-2] / 2 / i;
225 result = result + Xn[
n-1][i-1] / (i+1);
226 Xn[
n].push_back(result);
230 xninitsize += xninitsizestep;
235cln::cl_N Li2_do_sum(
const cln::cl_N&
x)
239 cln::cl_N num =
x * cln::cl_float(1, cln::float_format(
Digits));
247 res = res + num / den;
248 }
while (res != resbuf);
254cln::cl_N Li2_do_sum_Xn(
const cln::cl_N&
x)
256 std::vector<cln::cl_N>::const_iterator it = Xn[0].
begin();
257 std::vector<cln::cl_N>::const_iterator xend = Xn[0].end();
258 cln::cl_N u = -cln::log(1-
x);
259 cln::cl_N
factor = u * cln::cl_float(1, cln::float_format(
Digits));
260 cln::cl_N uu = cln::square(u);
261 cln::cl_N res = u - uu/4;
267 res = res + (*it) *
factor;
271 it = Xn[0].begin() + (i-1);
274 }
while (res != resbuf);
280cln::cl_N Lin_do_sum(
int n,
const cln::cl_N&
x)
282 cln::cl_N
factor =
x * cln::cl_float(1, cln::float_format(
Digits));
289 res = res +
factor / cln::expt(cln::cl_I(i),
n);
291 }
while (res != resbuf);
297cln::cl_N Lin_do_sum_Xn(
int n,
const cln::cl_N&
x)
299 std::vector<cln::cl_N>::const_iterator it = Xn[
n-2].begin();
300 std::vector<cln::cl_N>::const_iterator xend = Xn[
n-2].end();
301 cln::cl_N u = -cln::log(1-
x);
302 cln::cl_N
factor = u * cln::cl_float(1, cln::float_format(
Digits));
309 res = res + (*it) *
factor;
313 it = Xn[
n-2].begin() + (i-2);
314 xend = Xn[
n-2].end();
316 }
while (res != resbuf);
322const cln::cl_N S_num(
int n,
int p,
const cln::cl_N&
x);
326cln::cl_N Li_projection(
int n,
const cln::cl_N&
x,
const cln::float_format_t& prec)
335 if (cln::realpart(
x) < 0.5) {
340 if (cln::abs(
x) < 0.25) {
341 return Li2_do_sum(
x);
344 return Li2_do_sum_Xn(
x);
348 if (cln::abs(cln::realpart(
x)) > 0.75) {
352 return -Li2_do_sum(1-
x) - cln::log(
x) * cln::log(1-
x) + cln::zeta(2);
355 return -Li2_do_sum_Xn(1-
x) - cln::log(
x) * cln::log(1-
x) + cln::zeta(2);
361 for (
int i=xnsize; i<
n-1; i++) {
366 if (cln::realpart(
x) < 0.5) {
369 if ((cln::abs(
x) < 0.3) || (
n >= 12)) {
370 return Lin_do_sum(
n,
x);
373 return Lin_do_sum_Xn(
n,
x);
376 cln::cl_N result = 0;
377 if (
x != 1 ) result = -cln::expt(cln::log(
x),
n-1) * cln::log(1-
x) / cln::factorial(
n-1);
378 for (
int j=0; j<
n-1; j++) {
379 result = result + (S_num(
n-j-1, 1, 1) - S_num(1,
n-j-1, 1-
x))
380 * cln::expt(cln::log(
x), j) / cln::factorial(j);
388const cln::cl_N Lin_numeric(
const int n,
const cln::cl_N&
x)
392 return -cln::log(1-
x);
403 return -(1-cln::expt(cln::cl_I(2),1-
n)) * cln::zeta(
n);
405 if (cln::abs(realpart(
x)) < 0.4 && cln::abs(cln::abs(
x)-1) < 0.01) {
406 cln::cl_N result = -cln::expt(cln::log(
x),
n-1) * cln::log(1-
x) / cln::factorial(
n-1);
407 for (
int j=0; j<
n-1; j++) {
408 result = result + (S_num(
n-j-1, 1, 1) - S_num(1,
n-j-1, 1-
x))
409 * cln::expt(cln::log(
x), j) / cln::factorial(j);
416 cln::float_format_t prec = cln::default_float_format;
417 const cln::cl_N
value =
x;
419 if (!instanceof(realpart(
x), cln::cl_RA_ring))
420 prec = cln::float_format(cln::the<cln::cl_F>(cln::realpart(
value)));
421 else if (!instanceof(imagpart(
x), cln::cl_RA_ring))
422 prec = cln::float_format(cln::the<cln::cl_F>(cln::imagpart(
value)));
425 if (cln::abs(
value) > 1) {
426 cln::cl_N result = -cln::expt(cln::log(-
value),
n) / cln::factorial(
n);
428 if (cln::zerop(cln::imagpart(
value))) {
430 result = result +
conjugate(Li_projection(
n, cln::recip(
value), prec));
433 result = result -
conjugate(Li_projection(
n, cln::recip(
value), prec));
438 result = result + Li_projection(
n, cln::recip(
value), prec);
441 result = result - Li_projection(
n, cln::recip(
value), prec);
445 for (
int j=0; j<
n-1; j++) {
446 add = add + (1+cln::expt(cln::cl_I(-1),
n-j)) * (1-cln::expt(cln::cl_I(2),1-
n+j))
447 * Lin_numeric(
n-j,1) * cln::expt(cln::log(-
value),j) / cln::factorial(j);
449 result = result - add;
453 return Li_projection(
n,
value, prec);
475cln::cl_N multipleLi_do_sum(
const std::vector<int>& s,
const std::vector<cln::cl_N>&
x)
478 for (
const auto & it :
x) {
479 if (it == 0)
return cln::cl_float(0, cln::float_format(
Digits));
482 const int j = s.size();
483 bool flag_accidental_zero =
false;
485 std::vector<cln::cl_N> t(j);
486 cln::cl_F
one = cln::cl_float(1, cln::float_format(
Digits));
493 t[j-1] = t[j-1] + cln::expt(
x[j-1], q) / cln::expt(cln::cl_I(q),s[j-1]) *
one;
494 for (
int k=j-2;
k>=0;
k--) {
495 t[
k] = t[
k] + t[
k+1] * cln::expt(
x[
k], q+j-1-
k) / cln::expt(cln::cl_I(q+j-1-
k), s[
k]);
498 t[j-1] = t[j-1] + cln::expt(
x[j-1], q) / cln::expt(cln::cl_I(q),s[j-1]) *
one;
499 for (
int k=j-2;
k>=0;
k--) {
500 flag_accidental_zero = cln::zerop(t[
k+1]);
501 t[
k] = t[
k] + t[
k+1] * cln::expt(
x[
k], q+j-1-
k) / cln::expt(cln::cl_I(q+j-1-
k), s[
k]);
503 }
while ( (t[0] != t0buf) || cln::zerop(t[0]) || flag_accidental_zero );
510lst convert_parameter_Li_to_H(
const lst&
m,
const lst&
x, ex& pf);
514typedef std::vector<int> Gparameter;
518ex G_eval1(
int a,
int scale,
const exvector& gsyms)
521 const ex& scs = gsyms[std::abs(scale)];
522 const ex& as = gsyms[std::abs(a)];
524 return -
log(1 - scs/as);
529 return log(gsyms[std::abs(scale)]);
535ex G_eval(
const Gparameter& a,
int scale,
const exvector& gsyms)
538 ex sc = gsyms[std::abs(scale)];
540 bool all_zero =
true;
541 bool all_ones =
true;
543 for (
const auto & it : a) {
545 const ex sym = gsyms[std::abs(it)];
561 if (newa.nops() > 1 && newa.op(0) == sc && !all_ones && a.front()!=0) {
563 Gparameter short_a(a.begin()+1, a.end());
564 ex result = G_eval1(a.front(), scale, gsyms) * G_eval(short_a, scale, gsyms);
566 auto it = short_a.begin();
567 advance(it, count_ones-1);
568 for (; it != short_a.end(); ++it) {
570 Gparameter newa(short_a.begin(), it);
572 newa.push_back(a[0]);
573 newa.insert(newa.end(), it+1, short_a.end());
574 result -= G_eval(newa, scale, gsyms);
576 return result / count_ones;
580 if (all_ones && a.size() > 1) {
581 return pow(G_eval1(a.front(),scale, gsyms), count_ones) /
factorial(count_ones);
586 return pow(
log(gsyms[std::abs(scale)]), a.size()) /
factorial(a.size());
592 ex argbuf = gsyms[std::abs(scale)];
594 for (
const auto & it : a) {
596 const ex& sym = gsyms[std::abs(it)];
597 x.append(argbuf / sym);
609ex G_eval_to_G(
const Gparameter& a,
int scale,
const exvector& gsyms)
613 for (
const auto & it : a) {
615 z.append(gsyms[std::abs(it)]);
626 return G(z,s,gsyms[std::abs(scale)]);
631Gparameter convert_pending_integrals_G(
const Gparameter& pending_integrals)
635 if (pending_integrals.size() > 0) {
637 Gparameter new_a(pending_integrals.begin()+1, pending_integrals.end());
652Gparameter::const_iterator check_parameter_G(
const Gparameter& a,
int scale,
653 bool& convergent,
int& depth,
int& trailing_zeros, Gparameter::const_iterator& min_it)
659 auto lastnonzero = a.end();
660 for (
auto it = a.begin(); it != a.end(); ++it) {
661 if (std::abs(*it) > 0) {
665 if (std::abs(*it) < scale) {
667 if ((min_it == a.end()) || (std::abs(*it) < std::abs(*min_it))) {
675 if (lastnonzero == a.end())
677 return ++lastnonzero;
682Gparameter prepare_pending_integrals(
const Gparameter& pending_integrals,
int scale)
686 if (pending_integrals.size() > 0) {
687 return pending_integrals;
689 Gparameter new_pending_integrals;
690 new_pending_integrals.push_back(scale);
691 return new_pending_integrals;
697ex trailing_zeros_G(
const Gparameter& a,
int scale,
const exvector& gsyms)
700 int depth, trailing_zeros;
701 Gparameter::const_iterator
last, dummyit;
702 last = check_parameter_G(a, scale, convergent, depth, trailing_zeros, dummyit);
706 if ((trailing_zeros > 0) && (depth > 0)) {
708 Gparameter new_a(a.begin(), a.end()-1);
709 result += G_eval1(0, scale, gsyms) * trailing_zeros_G(new_a, scale, gsyms);
710 for (
auto it = a.begin(); it !=
last; ++it) {
711 Gparameter new_a(a.begin(), it);
713 new_a.insert(new_a.end(), it, a.end()-1);
714 result -= trailing_zeros_G(new_a, scale, gsyms);
717 return result / trailing_zeros;
719 return G_eval(a, scale, gsyms);
725ex depth_one_trafo_G(
const Gparameter& pending_integrals,
const Gparameter& a,
int scale,
const exvector& gsyms)
738 Gparameter new_pending_integrals = prepare_pending_integrals(pending_integrals, std::abs(a.back()));
739 const int psize = pending_integrals.size();
747 result +=
log(gsyms[ex_to<numeric>(scale).
to_int()]);
749 new_pending_integrals.push_back(-scale);
752 new_pending_integrals.push_back(scale);
756 result *= trailing_zeros_G(convert_pending_integrals_G(pending_integrals),
757 pending_integrals.front(),
762 result += trailing_zeros_G(convert_pending_integrals_G(new_pending_integrals),
763 new_pending_integrals.front(),
767 new_pending_integrals.back() = 0;
768 result -= trailing_zeros_G(convert_pending_integrals_G(new_pending_integrals),
769 new_pending_integrals.front(),
780 result -=
zeta(a.size());
782 result *= trailing_zeros_G(convert_pending_integrals_G(pending_integrals),
783 pending_integrals.front(),
789 Gparameter new_a(a.begin()+1, a.end());
790 new_pending_integrals.push_back(0);
791 result -= depth_one_trafo_G(new_pending_integrals, new_a, scale, gsyms);
795 Gparameter new_pending_integrals_2;
796 new_pending_integrals_2.push_back(scale);
797 new_pending_integrals_2.push_back(0);
799 result += trailing_zeros_G(convert_pending_integrals_G(pending_integrals),
800 pending_integrals.front(),
802 * depth_one_trafo_G(new_pending_integrals_2, new_a, scale, gsyms);
804 result += depth_one_trafo_G(new_pending_integrals_2, new_a, scale, gsyms);
812ex shuffle_G(
const Gparameter & a0,
const Gparameter & a1,
const Gparameter & a2,
813 const Gparameter& pendint,
const Gparameter& a_old,
int scale,
814 const exvector& gsyms,
bool flag_trailing_zeros_only);
818ex G_transform(
const Gparameter& pendint,
const Gparameter& a,
int scale,
819 const exvector& gsyms,
bool flag_trailing_zeros_only)
832 int depth, trailing_zeros;
833 Gparameter::const_iterator min_it;
834 auto firstzero = check_parameter_G(a, scale, convergent, depth, trailing_zeros, min_it);
835 int min_it_pos = distance(a.begin(), min_it);
844 result = G_eval(a, scale, gsyms);
846 if (pendint.size() > 0) {
847 result *= trailing_zeros_G(convert_pending_integrals_G(pendint),
855 if (trailing_zeros > 0) {
857 Gparameter new_a(a.begin(), a.end()-1);
858 result += G_eval1(0, scale, gsyms) * G_transform(pendint, new_a, scale, gsyms, flag_trailing_zeros_only);
859 for (
auto it = a.begin(); it != firstzero; ++it) {
860 Gparameter new_a(a.begin(), it);
862 new_a.insert(new_a.end(), it, a.end()-1);
863 result -= G_transform(pendint, new_a, scale, gsyms, flag_trailing_zeros_only);
865 return result / trailing_zeros;
869 if (flag_trailing_zeros_only)
870 return G_eval_to_G(a, scale, gsyms);
874 if (pendint.size() > 0) {
875 return G_eval(convert_pending_integrals_G(pendint),
876 pendint.front(), gsyms) *
877 G_eval(a, scale, gsyms);
879 return G_eval(a, scale, gsyms);
885 return depth_one_trafo_G(pendint, a, scale, gsyms);
894 if (min_it + 1 == a.end()) {
895 do { --min_it; }
while (*min_it == 0);
897 Gparameter a1(a.begin(),min_it+1);
898 Gparameter a2(min_it+1,a.end());
900 ex result = G_transform(pendint, a2, scale, gsyms, flag_trailing_zeros_only)*
901 G_transform(empty, a1, scale, gsyms, flag_trailing_zeros_only);
903 result -= shuffle_G(empty, a1, a2, pendint, a, scale, gsyms, flag_trailing_zeros_only);
908 Gparameter::iterator changeit;
911 Gparameter new_pendint = prepare_pending_integrals(pendint, a[min_it_pos]);
912 Gparameter new_a = a;
913 new_a[min_it_pos] = 0;
914 ex result = G_transform(empty, new_a, scale, gsyms, flag_trailing_zeros_only);
915 if (pendint.size() > 0) {
916 result *= trailing_zeros_G(convert_pending_integrals_G(pendint),
917 pendint.front(), gsyms);
921 changeit = new_a.begin() + min_it_pos;
922 changeit = new_a.erase(changeit);
923 if (changeit != new_a.begin()) {
925 new_pendint.push_back(*changeit);
926 result -= trailing_zeros_G(convert_pending_integrals_G(new_pendint),
927 new_pendint.front(), gsyms)*
928 G_transform(empty, new_a, scale, gsyms, flag_trailing_zeros_only);
929 int buffer = *changeit;
931 result += G_transform(new_pendint, new_a, scale, gsyms, flag_trailing_zeros_only);
933 new_pendint.pop_back();
935 new_pendint.push_back(*changeit);
936 result += trailing_zeros_G(convert_pending_integrals_G(new_pendint),
937 new_pendint.front(), gsyms)*
938 G_transform(empty, new_a, scale, gsyms, flag_trailing_zeros_only);
940 result -= G_transform(new_pendint, new_a, scale, gsyms, flag_trailing_zeros_only);
943 new_pendint.push_back(scale);
944 result += trailing_zeros_G(convert_pending_integrals_G(new_pendint),
945 new_pendint.front(), gsyms)*
946 G_transform(empty, new_a, scale, gsyms, flag_trailing_zeros_only);
947 new_pendint.back() = *changeit;
948 result -= trailing_zeros_G(convert_pending_integrals_G(new_pendint),
949 new_pendint.front(), gsyms)*
950 G_transform(empty, new_a, scale, gsyms, flag_trailing_zeros_only);
952 result += G_transform(new_pendint, new_a, scale, gsyms, flag_trailing_zeros_only);
960ex shuffle_G(
const Gparameter & a0,
const Gparameter & a1,
const Gparameter & a2,
961 const Gparameter& pendint,
const Gparameter& a_old,
int scale,
962 const exvector& gsyms,
bool flag_trailing_zeros_only)
964 if (a1.size()==0 && a2.size()==0) {
966 if ( a0 == a_old )
return 0;
968 return G_transform(pendint, a0, scale, gsyms, flag_trailing_zeros_only);
974 aa0.insert(aa0.end(),a1.begin(),a1.end());
975 return shuffle_G(aa0, empty, empty, pendint, a_old, scale, gsyms, flag_trailing_zeros_only);
981 aa0.insert(aa0.end(),a2.begin(),a2.end());
982 return shuffle_G(aa0, empty, empty, pendint, a_old, scale, gsyms, flag_trailing_zeros_only);
985 Gparameter a1_removed(a1.begin()+1,a1.end());
986 Gparameter a2_removed(a2.begin()+1,a2.end());
991 a01.push_back( a1[0] );
992 a02.push_back( a2[0] );
994 return shuffle_G(a01, a1_removed, a2, pendint, a_old, scale, gsyms, flag_trailing_zeros_only)
995 + shuffle_G(a02, a1, a2_removed, pendint, a_old, scale, gsyms, flag_trailing_zeros_only);
1001G_numeric(
const std::vector<cln::cl_N>&
x,
const std::vector<int>& s,
1002 const cln::cl_N& y);
1007G_do_hoelder(std::vector<cln::cl_N>
x,
1008 const std::vector<int>& s,
const cln::cl_N& y)
1011 const std::size_t size =
x.size();
1012 for (std::size_t i = 0; i < size; ++i)
1020 for (std::size_t i = 0; i < size; ++i) {
1023 if (cln::zerop(
x[i] - cln::cl_RA(1)/p) ) {
1024 p = p/2 + cln::cl_RA(3)/2;
1030 cln::cl_RA q = p/(p-1);
1032 for (std::size_t
r = 0;
r <= size; ++
r) {
1033 cln::cl_N buffer(1 &
r ? -1 : 1);
1034 std::vector<cln::cl_N> qlstx;
1035 std::vector<int> qlsts;
1036 for (std::size_t j =
r; j >= 1; --j) {
1037 qlstx.push_back(cln::cl_N(1) -
x[j-1]);
1038 if (imagpart(
x[j-1])==0 && realpart(
x[j-1]) >= 1) {
1041 qlsts.push_back(-s[j-1]);
1044 if (qlstx.size() > 0) {
1045 buffer = buffer*G_numeric(qlstx, qlsts, 1/q);
1047 std::vector<cln::cl_N> plstx;
1048 std::vector<int> plsts;
1049 for (std::size_t j =
r+1; j <= size; ++j) {
1050 plstx.push_back(
x[j-1]);
1051 plsts.push_back(s[j-1]);
1053 if (plstx.size() > 0) {
1054 buffer = buffer*G_numeric(plstx, plsts, 1/p);
1056 result = result + buffer;
1061class less_object_for_cl_N
1064 bool operator() (
const cln::cl_N & a,
const cln::cl_N & b)
const
1068 return (
abs(a) <
abs(b)) ? true :
false;
1071 if (phase(a) != phase(b))
1072 return (phase(a) < phase(b)) ? true :
false;
1083G_do_trafo(
const std::vector<cln::cl_N>&
x,
const std::vector<int>& s,
1084 const cln::cl_N& y,
bool flag_trailing_zeros_only)
1087 typedef std::multimap<cln::cl_N, std::size_t, less_object_for_cl_N> sortmap_t;
1089 std::size_t size = 0;
1090 for (std::size_t i = 0; i <
x.size(); ++i) {
1092 sortmap.insert(std::make_pair(
x[i], i));
1097 sortmap.insert(std::make_pair(y,
x.size()));
1103 gsyms.push_back(symbol(
"GSYMS_ERROR"));
1104 cln::cl_N lastentry(0);
1105 for (sortmap_t::const_iterator it = sortmap.begin(); it != sortmap.end(); ++it) {
1106 if (it != sortmap.begin()) {
1107 if (it->second <
x.size()) {
1108 if (
x[it->second] == lastentry) {
1109 gsyms.push_back(gsyms.back());
1113 if (y == lastentry) {
1114 gsyms.push_back(gsyms.back());
1119 std::ostringstream os;
1121 gsyms.push_back(symbol(os.str()));
1123 if (it->second <
x.size()) {
1124 lastentry =
x[it->second];
1131 Gparameter a(
x.size());
1133 std::size_t pos = 1;
1135 for (sortmap_t::const_iterator it = sortmap.begin(); it != sortmap.end(); ++it) {
1136 if (it->second <
x.size()) {
1137 if (s[it->second] > 0) {
1138 a[it->second] = pos;
1140 a[it->second] = -int(pos);
1142 subslst[gsyms[pos]] = numeric(
x[it->second]);
1145 subslst[gsyms[pos]] = numeric(y);
1152 ex result = G_transform(pendint, a, scale, gsyms, flag_trailing_zeros_only);
1154 result = result.expand();
1155 result = result.subs(subslst).evalf();
1156 if (!is_a<numeric>(result))
1157 throw std::logic_error(
"G_do_trafo: G_transform returned non-numeric result");
1159 cln::cl_N ret = ex_to<numeric>(result).to_cl_N();
1166G_numeric(
const std::vector<cln::cl_N>&
x,
const std::vector<int>& s,
1170 bool need_trafo =
false;
1171 bool need_hoelder =
false;
1172 bool have_trailing_zero =
false;
1173 std::size_t depth = 0;
1174 for (
auto & xi :
x) {
1177 const cln::cl_N x_y =
abs(xi) - y;
1178 if (instanceof(x_y, cln::cl_R_ring) &&
1179 realpart(x_y) < cln::least_negative_float(cln::float_format(
Digits - 2)))
1182 if (
abs(
abs(xi/y) - 1) < 0.01)
1183 need_hoelder =
true;
1186 if (zerop(
x.back())) {
1187 have_trailing_zero =
true;
1191 if (depth == 1 &&
x.size() == 2 && !need_trafo)
1192 return - Li_projection(2, y/
x[1], cln::float_format(
Digits));
1195 if (need_hoelder && !have_trailing_zero)
1196 return G_do_hoelder(
x, s, y);
1200 return G_do_trafo(
x, s, y, have_trailing_zero);
1203 std::vector<cln::cl_N> newx;
1204 newx.reserve(
x.size());
1206 m.reserve(
x.size());
1210 for (
auto & xi :
x) {
1214 newx.push_back(
factor/xi);
1216 m.push_back(mcount);
1222 return sign*multipleLi_do_sum(
m, newx);
1226ex mLi_numeric(
const lst&
m,
const lst&
x)
1229 std::vector<cln::cl_N> newx;
1230 newx.reserve(
x.
nops());
1232 s.reserve(
x.
nops());
1234 for (
auto itm =
m.begin(), itx =
x.
begin(); itm !=
m.end(); ++itm, ++itx) {
1235 for (
int i = 1; i < *itm; ++i) {
1236 newx.push_back(cln::cl_N(0));
1239 const cln::cl_N xi = ex_to<numeric>(*itx).to_cl_N();
1242 if ( !instanceof(
factor, cln::cl_R_ring) && imagpart(
factor) < 0 ) {
1249 return numeric(cln::cl_N(1 &
m.nops() ? - 1 : 1)*G_numeric(newx, s, cln::cl_N(1)));
1268 return G(x_, y).
hold();
1270 lst x = is_a<lst>(x_) ? ex_to<lst>(x_) :
lst{x_};
1271 if (
x.
nops() == 0) {
1275 return G(x_, y).
hold();
1278 s.reserve(
x.
nops());
1279 bool all_zero =
true;
1280 for (
const auto & it :
x) {
1282 return G(x_, y).
hold();
1287 if ( !ex_to<numeric>(it).
is_real() && ex_to<numeric>(it).
imag() < 0 ) {
1297 std::vector<cln::cl_N> xv;
1298 xv.reserve(
x.
nops());
1299 for (
const auto & it :
x)
1300 xv.push_back(ex_to<numeric>(it).to_cl_N());
1301 cln::cl_N result = G_numeric(xv, s, ex_to<numeric>(y).to_cl_N());
1311 return G(x_, y).
hold();
1313 lst x = is_a<lst>(x_) ? ex_to<lst>(x_) :
lst{x_};
1314 if (
x.
nops() == 0) {
1318 return G(x_, y).
hold();
1321 s.reserve(
x.
nops());
1322 bool all_zero =
true;
1323 bool crational =
true;
1324 for (
const auto & it :
x) {
1326 return G(x_, y).
hold();
1334 if ( !ex_to<numeric>(it).
is_real() && ex_to<numeric>(it).
imag() < 0 ) {
1348 return G(x_, y).
hold();
1350 std::vector<cln::cl_N> xv;
1351 xv.reserve(
x.
nops());
1352 for (
const auto & it :
x)
1353 xv.push_back(ex_to<numeric>(it).to_cl_N());
1354 cln::cl_N result = G_numeric(xv, s, ex_to<numeric>(y).to_cl_N());
1372 return G(x_, s_, y).
hold();
1374 lst x = is_a<lst>(x_) ? ex_to<lst>(x_) :
lst{x_};
1375 lst s = is_a<lst>(s_) ? ex_to<lst>(s_) :
lst{s_};
1377 return G(x_, s_, y).
hold();
1379 if (
x.
nops() == 0) {
1383 return G(x_, s_, y).
hold();
1385 std::vector<int> sn;
1386 sn.reserve(s.
nops());
1387 bool all_zero =
true;
1388 for (
auto itx =
x.
begin(), its = s.
begin(); itx !=
x.
end(); ++itx, ++its) {
1390 return G(x_, y).
hold();
1393 return G(x_, y).
hold();
1398 if ( ex_to<numeric>(*itx).is_real() ) {
1399 if ( ex_to<numeric>(*itx).is_positive() ) {
1411 if ( ex_to<numeric>(*itx).imag() > 0 ) {
1422 std::vector<cln::cl_N> xn;
1423 xn.reserve(
x.
nops());
1424 for (
const auto & it :
x)
1425 xn.push_back(ex_to<numeric>(it).to_cl_N());
1426 cln::cl_N result = G_numeric(xn, sn, ex_to<numeric>(y).to_cl_N());
1436 return G(x_, s_, y).
hold();
1438 lst x = is_a<lst>(x_) ? ex_to<lst>(x_) :
lst{x_};
1439 lst s = is_a<lst>(s_) ? ex_to<lst>(s_) :
lst{s_};
1441 return G(x_, s_, y).
hold();
1443 if (
x.
nops() == 0) {
1447 return G(x_, s_, y).
hold();
1449 std::vector<int> sn;
1450 sn.reserve(s.
nops());
1451 bool all_zero =
true;
1452 bool crational =
true;
1453 for (
auto itx =
x.
begin(), its = s.
begin(); itx !=
x.
end(); ++itx, ++its) {
1455 return G(x_, s_, y).
hold();
1458 return G(x_, s_, y).
hold();
1466 if ( ex_to<numeric>(*itx).is_real() ) {
1467 if ( ex_to<numeric>(*itx).is_positive() ) {
1479 if ( ex_to<numeric>(*itx).imag() > 0 ) {
1494 return G(x_, s_, y).
hold();
1496 std::vector<cln::cl_N> xn;
1497 xn.reserve(
x.
nops());
1498 for (
const auto & it :
x)
1499 xn.push_back(ex_to<numeric>(it).to_cl_N());
1500 cln::cl_N result = G_numeric(xn, sn, ex_to<numeric>(y).to_cl_N());
1531 int m__ = ex_to<numeric>(m_).to_int();
1532 const cln::cl_N x__ = ex_to<numeric>(x_).to_cl_N();
1533 const cln::cl_N result = Lin_numeric(m__, x__);
1539 int m__ = ex_to<numeric>(m_).to_int();
1540 const cln::cl_N x__ = ex_to<numeric>(x_val).to_cl_N();
1541 const cln::cl_N result = Lin_numeric(m__, x__);
1547 if (is_a<lst>(m_) && is_a<lst>(x_)) {
1549 const lst&
m = ex_to<lst>(m_);
1550 const lst&
x = ex_to<lst>(x_);
1551 if (
m.nops() !=
x.
nops()) {
1552 return Li(m_,x_).hold();
1554 if (
x.
nops() == 0) {
1558 return Li(m_,x_).hold();
1561 for (
auto itm =
m.begin(), itx =
x.
begin(); itm !=
m.end(); ++itm, ++itx) {
1563 return Li(m_, x_).hold();
1566 return Li(m_, x_).hold();
1573 return mLi_numeric(
m,
x);
1576 return Li(m_,x_).hold();
1582 if (is_a<lst>(m_)) {
1583 if (is_a<lst>(x_)) {
1585 const lst&
m = ex_to<lst>(m_);
1586 const lst&
x = ex_to<lst>(x_);
1587 if (
m.nops() !=
x.
nops()) {
1588 return Li(m_,x_).hold();
1590 if (
x.
nops() == 0) {
1594 bool is_zeta =
true;
1595 bool do_evalf =
true;
1596 bool crational =
true;
1597 for (
auto itm =
m.begin(), itx =
x.
begin(); itm !=
m.end(); ++itm, ++itx) {
1599 return Li(m_,x_).hold();
1601 if ((*itx !=
_ex1) && (*itx !=
_ex_1)) {
1619 for (
const auto & itx :
x) {
1628 return zeta(m_, newx);
1632 lst newm = convert_parameter_Li_to_H(
m,
x, prefactor);
1633 return prefactor * H(newm,
x[0]);
1635 if (do_evalf && !crational) {
1636 return mLi_numeric(
m,
x);
1639 return Li(m_, x_).hold();
1640 }
else if (is_a<lst>(x_)) {
1641 return Li(m_, x_).hold();
1652 return (
pow(2,1-m_)-1) *
zeta(m_);
1666 int m__ = ex_to<numeric>(m_).
to_int();
1667 const cln::cl_N x__ = ex_to<numeric>(x_).to_cl_N();
1668 const cln::cl_N result = Lin_numeric(m__, x__);
1672 return Li(m_, x_).hold();
1678 if (is_a<lst>(
m) || is_a<lst>(
x)) {
1681 return pseries(rel, std::move(seq));
1692 for (
int i=1; i<
order; ++i)
1698 ser +=
pseries(rel, std::move(nseq));
1703 throw std::runtime_error(
"Li_series: don't know how to do the series expansion at this point!");
1713 if (deriv_param == 0) {
1716 if (m_.
nops() > 1) {
1717 throw std::runtime_error(
"don't know how to derivate multiple polylogarithm!");
1720 if (is_a<lst>(m_)) {
1726 if (is_a<lst>(x_)) {
1732 return Li(
m-1,
x) /
x;
1742 if (is_a<lst>(m_)) {
1748 if (is_a<lst>(x_)) {
1753 c.s <<
"\\mathrm{Li}_{";
1757 for (; itm !=
m.end(); itm++) {
1765 for (; itx !=
x.
end(); itx++) {
1779 do_not_evalf_params());
1797std::vector<std::vector<cln::cl_N>> Yn;
1810void fill_Yn(
int n,
const cln::float_format_t& prec)
1812 const int initsize = ynlength;
1814 cln::cl_N
one = cln::cl_float(1, prec);
1817 std::vector<cln::cl_N> buf(initsize);
1818 auto it = buf.begin();
1819 auto itprev = Yn[
n-1].begin();
1820 *it = (*itprev) / cln::cl_N(
n+1) *
one;
1825 for (
int i=
n+2; i<=initsize+
n; i++) {
1826 *it = *(it-1) + (*itprev) / cln::cl_N(i) *
one;
1832 std::vector<cln::cl_N> buf(initsize);
1833 auto it = buf.begin();
1836 for (
int i=2; i<=initsize; i++) {
1837 *it = *(it-1) + 1 / cln::cl_N(i) *
one;
1847void make_Yn_longer(
int newsize,
const cln::float_format_t& prec)
1850 cln::cl_N
one = cln::cl_float(1, prec);
1852 Yn[0].resize(newsize);
1853 auto it = Yn[0].begin();
1855 for (
int i=ynlength+1; i<=newsize; i++) {
1856 *it = *(it-1) + 1 / cln::cl_N(i) *
one;
1860 for (
int n=1;
n<ynsize;
n++) {
1861 Yn[
n].resize(newsize);
1862 auto it = Yn[
n].begin();
1863 auto itprev = Yn[
n-1].begin();
1866 for (
int i=ynlength+
n+1; i<=newsize+
n; i++) {
1867 *it = *(it-1) + (*itprev) / cln::cl_N(i) *
one;
1879cln::cl_N C(
int n,
int p)
1883 for (
int k=0;
k<p;
k++) {
1884 for (
int j=0; j<=(
n+
k-1)/2; j++) {
1888 result = result - 2 * cln::expt(cln::pi(),2*j) * S_num(
n-2*j,p,1) / cln::factorial(2*j);
1891 result = result + 2 * cln::expt(cln::pi(),2*j) * S_num(
n-2*j,p,1) / cln::factorial(2*j);
1898 result = result + cln::factorial(
n+
k-1)
1899 * cln::expt(cln::pi(),2*j) * S_num(
n+
k-2*j,p-
k,1)
1900 / (cln::factorial(
k) * cln::factorial(
n-1) * cln::factorial(2*j));
1903 result = result - cln::factorial(
n+
k-1)
1904 * cln::expt(cln::pi(),2*j) * S_num(
n+
k-2*j,p-
k,1)
1905 / (cln::factorial(
k) * cln::factorial(
n-1) * cln::factorial(2*j));
1910 result = result - cln::factorial(
n+
k-1) * cln::expt(cln::pi(),2*j) * S_num(
n+
k-2*j,p-
k,1)
1911 / (cln::factorial(
k) * cln::factorial(
n-1) * cln::factorial(2*j));
1914 result = result + cln::factorial(
n+
k-1)
1915 * cln::expt(cln::pi(),2*j) * S_num(
n+
k-2*j,p-
k,1)
1916 / (cln::factorial(
k) * cln::factorial(
n-1) * cln::factorial(2*j));
1924 if (((np)/2+
n) & 1) {
1925 result = -result - cln::expt(cln::pi(),np) / (np * cln::factorial(
n-1) * cln::factorial(p));
1928 result = -result + cln::expt(cln::pi(),np) / (np * cln::factorial(
n-1) * cln::factorial(p));
1947 for (
int m=2;
m<=
k;
m++) {
1948 result = result + cln::expt(cln::cl_N(-1),
m) * cln::zeta(
m) * a_k(
k-
m);
1966 for (
int m=2;
m<=
k;
m++) {
1967 result = result + cln::expt(cln::cl_N(-1),
m) * cln::zeta(
m) * b_k(
k-
m);
1975cln::cl_N S_do_sum(
int n,
int p,
const cln::cl_N&
x,
const cln::float_format_t& prec)
1977 static cln::float_format_t oldprec = cln::default_float_format;
1980 return Li_projection(
n+1,
x, prec);
1984 if ( oldprec != prec ) {
1993 for (
int i=ynsize; i<p-1; i++) {
1999 cln::cl_F
one = cln::cl_float(1, cln::float_format(
Digits));
2000 cln::cl_N xf =
x *
one;
2005 cln::cl_N
factor = cln::expt(xf, p);
2009 if (i-p >= ynlength) {
2011 make_Yn_longer(ynlength*2, prec);
2013 res = res +
factor / cln::expt(cln::cl_I(i),
n+1) * Yn[p-2][i-p];
2017 }
while (res != resbuf);
2024cln::cl_N S_projection(
int n,
int p,
const cln::cl_N&
x,
const cln::float_format_t& prec)
2027 if (cln::abs(cln::realpart(
x)) > cln::cl_F(
"0.5")) {
2029 cln::cl_N result = cln::expt(cln::cl_I(-1),p) * cln::expt(cln::log(
x),
n)
2030 * cln::expt(cln::log(1-
x),p) / cln::factorial(
n) / cln::factorial(p);
2032 for (
int s=0; s<
n; s++) {
2034 for (
int r=0;
r<p;
r++) {
2035 res2 = res2 + cln::expt(cln::cl_I(-1),
r) * cln::expt(cln::log(1-
x),
r)
2036 * S_do_sum(p-
r,
n-s,1-
x,prec) / cln::factorial(
r);
2038 result = result + cln::expt(cln::log(
x),s) * (S_num(
n-s,p,1) - res2) / cln::factorial(s);
2044 return S_do_sum(
n, p,
x, prec);
2049const cln::cl_N S_num(
int n,
int p,
const cln::cl_N&
x)
2054 return cln::zeta(p+1);
2059 return cln::zeta(
n+1);
2064 for (
int nu=0; nu<
n; nu++) {
2065 for (
int rho=0; rho<=p; rho++) {
2066 result = result + b_k(
n-nu-1) * b_k(p-rho) * a_k(nu+rho+1)
2067 * cln::factorial(nu+rho+1) / cln::factorial(rho) / cln::factorial(nu+1);
2070 result = result * cln::expt(cln::cl_I(-1),
n+p-1);
2077 return -(1-cln::expt(cln::cl_I(2),-
n)) * cln::zeta(
n+1);
2084 cln::float_format_t prec = cln::default_float_format;
2085 const cln::cl_N
value =
x;
2087 if (!instanceof(realpart(
value), cln::cl_RA_ring))
2088 prec = cln::float_format(cln::the<cln::cl_F>(cln::realpart(
value)));
2089 else if (!instanceof(imagpart(
value), cln::cl_RA_ring))
2090 prec = cln::float_format(cln::the<cln::cl_F>(cln::imagpart(
value)));
2095 if ((cln::realpart(
value) < -0.5) || (
n == 0) || ((cln::abs(
value) <= 1) && (cln::abs(
value) > 0.95) && (cln::abs(1-
value) > 1) )) {
2097 cln::cl_N result = cln::expt(cln::cl_I(-1),p) * cln::expt(cln::log(
value),
n)
2098 * cln::expt(cln::log(1-
value),p) / cln::factorial(
n) / cln::factorial(p);
2100 for (
int s=0; s<
n; s++) {
2102 for (
int r=0;
r<p;
r++) {
2103 res2 = res2 + cln::expt(cln::cl_I(-1),
r) * cln::expt(cln::log(1-
value),
r)
2104 * S_num(p-
r,
n-s,1-
value) / cln::factorial(
r);
2106 result = result + cln::expt(cln::log(
value),s) * (S_num(
n-s,p,1) - res2) / cln::factorial(s);
2113 if (cln::abs(
value) > 1) {
2117 for (
int s=0; s<p; s++) {
2118 for (
int r=0;
r<=s;
r++) {
2119 result = result + cln::expt(cln::cl_I(-1),s) * cln::expt(cln::log(-
value),
r) * cln::factorial(
n+s-
r-1)
2120 / cln::factorial(
r) / cln::factorial(s-
r) / cln::factorial(
n-1)
2121 * S_num(
n+s-
r,p-s,cln::recip(
value));
2124 result = result * cln::expt(cln::cl_I(-1),
n);
2127 for (
int r=0;
r<
n;
r++) {
2128 res2 = res2 + cln::expt(cln::log(-
value),
r) * C(
n-
r,p) / cln::factorial(
r);
2130 res2 = res2 + cln::expt(cln::log(-
value),
n+p) / cln::factorial(
n+p);
2132 result = result + cln::expt(cln::cl_I(-1),p) * res2;
2137 if ((cln::abs(
value) > 0.95) && (cln::abs(
value-9.53) < 9.47)) {
2140 for (
int s=0; s<p-1; s++)
2143 ex res = H(
m,numeric(
value)).evalf();
2144 return ex_to<numeric>(res).to_cl_N();
2147 return S_projection(
n, p,
value, prec);
2167 const int n_ = ex_to<numeric>(
n).to_int();
2168 const int p_ = ex_to<numeric>(p).to_int();
2169 if (is_a<numeric>(
x)) {
2170 const cln::cl_N x_ = ex_to<numeric>(
x).to_cl_N();
2171 const cln::cl_N result = S_num(n_, p_, x_);
2175 if (is_a<numeric>(x_val)) {
2176 const cln::cl_N x_val_ = ex_to<numeric>(x_val).to_cl_N();
2177 const cln::cl_N result = S_num(n_, p_, x_val_);
2182 return S(
n, p,
x).hold();
2194 for (
int i=ex_to<numeric>(p).
to_int()-1; i>0; i--) {
2203 int n_ = ex_to<numeric>(
n).to_int();
2204 int p_ = ex_to<numeric>(p).to_int();
2205 const cln::cl_N x_ = ex_to<numeric>(
x).to_cl_N();
2206 const cln::cl_N result = S_num(n_, p_, x_);
2214 return S(
n, p,
x).hold();
2233 std::vector<ex> presubsum, subsum;
2234 subsum.push_back(0);
2235 for (
int i=1; i<
order-1; ++i) {
2236 subsum.push_back(subsum[i-1] +
numeric(1, i));
2238 for (
int depth=2; depth<p; ++depth) {
2240 for (
int i=1; i<
order-1; ++i) {
2241 subsum[i] = subsum[i-1] +
numeric(1, i) * presubsum[i-1];
2245 for (
int i=1; i<
order; ++i) {
2252 ser +=
pseries(rel, std::move(nseq));
2257 throw std::runtime_error(
"S_series: don't know how to do the series expansion at this point!");
2267 if (deriv_param < 2) {
2271 return S(
n-1, p,
x) /
x;
2273 return S(
n, p-1,
x) / (1-
x);
2280 c.s <<
"\\mathrm{S}_{";
2296 do_not_evalf_params());
2313symbol H_polesign(
"IMSIGN");
2319bool convert_parameter_H_to_Li(
const lst& l,
lst&
m,
lst& s,
ex& pf)
2323 for (
const auto & it : l) {
2325 for (
ex count=it-1; count > 0; count--) {
2329 }
else if (it < -1) {
2330 for (ex count=it+1; count < 0; count++) {
2341 bool has_negative_parameters =
false;
2343 for (
const auto & it : mexp) {
2349 m.append((it+acc-1) * signum);
2351 m.append((it-acc+1) * signum);
2357 has_negative_parameters =
true;
2360 if (has_negative_parameters) {
2361 for (std::size_t i=0; i<
m.nops(); i++) {
2371 return has_negative_parameters;
2376struct map_trafo_H_convert_to_Li :
public map_function
2378 ex operator()(
const ex& e)
override
2380 if (is_a<add>(e) || is_a<mul>(e)) {
2381 return e.
map(*
this);
2383 if (is_a<function>(e)) {
2384 std::string name = ex_to<function>(e).get_name();
2387 if (is_a<lst>(e.op(0))) {
2388 parameter = ex_to<lst>(e.op(0));
2390 parameter =
lst{e.op(0)};
2397 if (convert_parameter_H_to_Li(parameter,
m, s, pf)) {
2399 return pf * Li(
m, s).hold();
2401 for (std::size_t i=0; i<
m.nops(); i++) {
2405 return Li(
m, s).hold();
2415struct map_trafo_H_convert_to_zeta :
public map_function
2417 ex operator()(
const ex& e)
override
2419 if (is_a<add>(e) || is_a<mul>(e)) {
2420 return e.
map(*
this);
2422 if (is_a<function>(e)) {
2423 std::string name = ex_to<function>(e).get_name();
2426 if (is_a<lst>(e.op(0))) {
2427 parameter = ex_to<lst>(e.op(0));
2429 parameter =
lst{e.op(0)};
2435 if (convert_parameter_H_to_Li(parameter,
m, s, pf)) {
2436 return pf *
zeta(
m, s);
2448struct map_trafo_H_reduce_trailing_zeros :
public map_function
2450 ex operator()(
const ex& e)
override
2452 if (is_a<add>(e) || is_a<mul>(e)) {
2453 return e.map(*
this);
2455 if (is_a<function>(e)) {
2456 std::string name = ex_to<function>(e).get_name();
2459 if (is_a<lst>(e.op(0))) {
2460 parameter = ex_to<lst>(e.op(0));
2462 parameter =
lst{e.op(0)};
2465 if (parameter.op(parameter.nops()-1) == 0) {
2468 if (parameter.nops() == 1) {
2473 auto it = parameter.begin();
2474 while ((it != parameter.end()) && (*it == 0)) {
2477 if (it == parameter.end()) {
2482 parameter.remove_last();
2483 std::size_t lastentry = parameter.nops();
2484 while ((lastentry > 0) && (parameter[lastentry-1] == 0)) {
2489 ex result =
log(arg) * H(parameter,arg).
hold();
2491 for (ex i=0; i<lastentry; i++) {
2492 if (parameter[i] > 0) {
2494 result -= (acc + parameter[i]-1) * H(parameter, arg).
hold();
2497 }
else if (parameter[i] < 0) {
2499 result -= (acc +
abs(parameter[i]+1)) * H(parameter, arg).
hold();
2507 if (lastentry < parameter.nops()) {
2508 result = result / (parameter.nops()-lastentry+1);
2509 return result.
map(*
this);
2522ex convert_H_to_zeta(
const lst&
m)
2524 symbol xtemp(
"xtemp");
2525 map_trafo_H_reduce_trailing_zeros filter;
2526 map_trafo_H_convert_to_zeta filter2;
2527 return filter2(filter(H(
m, xtemp).hold())).subs(xtemp == 1);
2532lst convert_parameter_Li_to_H(
const lst&
m,
const lst&
x, ex& pf)
2535 auto itm =
m.begin();
2541 while (itx !=
x.
end()) {
2547 signum *= (*itx !=
_ex_1) ? 1 : -1;
2549 res.append((*itm) * signum);
2559ex trafo_H_mult(
const ex& h1,
const ex& h2)
2564 ex h1nops = h1.op(0).nops();
2565 ex h2nops = h2.op(0).nops();
2567 hshort = h2.op(0).op(0);
2568 hlong = ex_to<lst>(h1.op(0));
2570 hshort = h1.op(0).op(0);
2572 hlong = ex_to<lst>(h2.op(0));
2574 hlong =
lst{h2.op(0).op(0)};
2577 for (std::size_t i=0; i<=hlong.nops(); i++) {
2581 newparameter.append(hlong[j]);
2583 newparameter.append(hshort);
2584 for (; j<hlong.nops(); j++) {
2585 newparameter.append(hlong[j]);
2587 res += H(newparameter, h1.op(1)).hold();
2594struct map_trafo_H_mult :
public map_function
2596 ex operator()(
const ex& e)
override
2599 return e.map(*
this);
2607 for (std::size_t pos=0; pos<e.nops(); pos++) {
2608 if (is_a<power>(e.op(pos)) && is_a<function>(e.op(pos).op(0))) {
2609 std::string name = ex_to<function>(e.op(pos).op(0)).get_name();
2611 for (ex i=0; i<e.op(pos).
op(1); i++) {
2612 Hlst.append(e.op(pos).op(0));
2616 }
else if (is_a<function>(e.op(pos))) {
2617 std::string name = ex_to<function>(e.op(pos)).get_name();
2619 if (e.op(pos).op(0).nops() > 1) {
2622 Hlst.append(e.op(pos));
2627 result *= e.op(pos);
2630 if (Hlst.nops() > 0) {
2631 firstH = Hlst[Hlst.nops()-1];
2638 if (Hlst.nops() > 0) {
2639 ex buffer = trafo_H_mult(firstH, Hlst.op(0));
2641 for (std::size_t i=1; i<Hlst.nops(); i++) {
2642 result *= Hlst.op(i);
2644 result = result.expand();
2645 map_trafo_H_mult recursion;
2646 return recursion(result);
2659ex trafo_H_1tx_prepend_zero(
const ex& e,
const ex& arg)
2663 if (is_a<function>(e)) {
2664 name = ex_to<function>(e).get_name();
2669 for (std::size_t i=0; i<e.nops(); i++) {
2670 if (is_a<function>(e.op(i))) {
2671 std::string name = ex_to<function>(e.op(i)).get_name();
2679 lst newparameter = ex_to<lst>(h.op(0));
2680 newparameter.prepend(0);
2681 ex addzeta = convert_H_to_zeta(newparameter);
2682 return e.subs(h == (addzeta-H(newparameter, h.op(1)).hold())).expand();
2684 return e * (-H(
lst{ex(0)},1/arg).hold());
2691ex trafo_H_prepend_one(
const ex& e,
const ex& arg)
2695 if (is_a<function>(e)) {
2696 name = ex_to<function>(e).get_name();
2701 for (std::size_t i=0; i<e.nops(); i++) {
2702 if (is_a<function>(e.op(i))) {
2703 std::string name = ex_to<function>(e.op(i)).get_name();
2711 lst newparameter = ex_to<lst>(h.op(0));
2712 newparameter.prepend(1);
2713 return e.subs(h == H(newparameter, h.op(1)).hold());
2715 return e * H(
lst{ex(1)},1-arg).hold();
2722ex trafo_H_1tx_prepend_minusone(
const ex& e,
const ex& arg)
2726 if (is_a<function>(e)) {
2727 name = ex_to<function>(e).get_name();
2732 for (std::size_t i=0; i<e.nops(); i++) {
2733 if (is_a<function>(e.op(i))) {
2734 std::string name = ex_to<function>(e.op(i)).get_name();
2742 lst newparameter = ex_to<lst>(h.op(0));
2743 newparameter.prepend(-1);
2744 ex addzeta = convert_H_to_zeta(newparameter);
2745 return e.subs(h == (addzeta-H(newparameter, h.op(1)).hold())).expand();
2747 ex addzeta = convert_H_to_zeta(
lst{ex(-1)});
2748 return (e * (addzeta - H(
lst{ex(-1)},1/arg).hold())).expand();
2755ex trafo_H_1mxt1px_prepend_minusone(
const ex& e,
const ex& arg)
2759 if (is_a<function>(e)) {
2760 name = ex_to<function>(e).get_name();
2765 for (std::size_t i = 0; i < e.nops(); i++) {
2766 if (is_a<function>(e.op(i))) {
2767 std::string name = ex_to<function>(e.op(i)).get_name();
2775 lst newparameter = ex_to<lst>(h.op(0));
2776 newparameter.prepend(-1);
2777 return e.subs(h == H(newparameter, h.op(1)).hold()).expand();
2779 return (e * H(
lst{ex(-1)},(1-arg)/(1+arg)).hold()).
expand();
2786ex trafo_H_1mxt1px_prepend_one(
const ex& e,
const ex& arg)
2790 if (is_a<function>(e)) {
2791 name = ex_to<function>(e).get_name();
2796 for (std::size_t i = 0; i < e.nops(); i++) {
2797 if (is_a<function>(e.op(i))) {
2798 std::string name = ex_to<function>(e.op(i)).get_name();
2806 lst newparameter = ex_to<lst>(h.op(0));
2807 newparameter.prepend(1);
2808 return e.subs(h == H(newparameter, h.op(1)).hold()).expand();
2810 return (e * H(
lst{ex(1)},(1-arg)/(1+arg)).hold()).
expand();
2816struct map_trafo_H_1mx :
public map_function
2818 ex operator()(
const ex& e)
override
2820 if (is_a<add>(e) || is_a<mul>(e)) {
2821 return e.
map(*
this);
2824 if (is_a<function>(e)) {
2825 std::string name = ex_to<function>(e).get_name();
2828 lst parameter = ex_to<lst>(e.op(0));
2832 bool allthesame =
true;
2833 if (parameter.op(0) == 0) {
2834 for (std::size_t i = 1; i < parameter.nops(); i++) {
2835 if (parameter.op(i) != 0) {
2842 for (
int i=parameter.nops(); i>0; i--) {
2843 newparameter.append(1);
2845 return pow(-1, parameter.nops()) * H(newparameter, 1-arg).
hold();
2847 }
else if (parameter.op(0) == -1) {
2848 throw std::runtime_error(
"map_trafo_H_1mx: cannot handle weights equal -1!");
2850 for (std::size_t i = 1; i < parameter.nops(); i++) {
2851 if (parameter.op(i) != 1) {
2858 for (
int i=parameter.nops(); i>0; i--) {
2859 newparameter.append(0);
2861 return pow(-1, parameter.nops()) * H(newparameter, 1-arg).
hold();
2865 lst newparameter = parameter;
2866 newparameter.remove_first();
2868 if (parameter.op(0) == 0) {
2871 ex res = convert_H_to_zeta(parameter);
2873 map_trafo_H_1mx recursion;
2874 ex buffer = recursion(H(newparameter, arg).hold());
2875 if (is_a<add>(buffer)) {
2876 for (std::size_t i = 0; i < buffer.nops(); i++) {
2877 res -= trafo_H_prepend_one(buffer.op(i), arg);
2880 res -= trafo_H_prepend_one(buffer, arg);
2887 map_trafo_H_1mx recursion;
2888 map_trafo_H_mult unify;
2889 ex res = H(
lst{ex(1)}, arg).hold() * H(newparameter, arg).hold();
2890 std::size_t firstzero = 0;
2891 while (parameter.op(firstzero) == 1) {
2894 for (std::size_t i = firstzero-1; i < parameter.nops()-1; i++) {
2898 newparameter.append(parameter[j+1]);
2900 newparameter.append(1);
2901 for (; j<parameter.nops()-1; j++) {
2902 newparameter.append(parameter[j+1]);
2904 res -= H(newparameter, arg).hold();
2906 res = recursion(res).expand() / firstzero;
2917struct map_trafo_H_1overx :
public map_function
2919 ex operator()(
const ex& e)
override
2921 if (is_a<add>(e) || is_a<mul>(e)) {
2922 return e.map(*
this);
2925 if (is_a<function>(e)) {
2926 std::string name = ex_to<function>(e).get_name();
2929 lst parameter = ex_to<lst>(e.op(0));
2933 bool allthesame =
true;
2934 if (parameter.op(0) == 0) {
2935 for (std::size_t i = 1; i < parameter.nops(); i++) {
2936 if (parameter.op(i) != 0) {
2942 return pow(-1, parameter.nops()) * H(parameter, 1/arg).
hold();
2944 }
else if (parameter.op(0) == -1) {
2945 for (std::size_t i = 1; i < parameter.nops(); i++) {
2946 if (parameter.op(i) != -1) {
2952 map_trafo_H_mult unify;
2953 return unify((
pow(H(
lst{ex(-1)},1/arg).hold() - H(
lst{ex(0)},1/arg).hold(), parameter.nops())
2954 /
factorial(parameter.nops())).expand());
2957 for (std::size_t i = 1; i < parameter.nops(); i++) {
2958 if (parameter.op(i) != 1) {
2964 map_trafo_H_mult unify;
2965 return unify((
pow(H(
lst{ex(1)},1/arg).hold() + H(
lst{ex(0)},1/arg).hold() + H_polesign, parameter.nops())
2966 /
factorial(parameter.nops())).expand());
2970 lst newparameter = parameter;
2971 newparameter.remove_first();
2973 if (parameter.op(0) == 0) {
2976 ex res = convert_H_to_zeta(parameter);
2977 map_trafo_H_1overx recursion;
2978 ex buffer = recursion(H(newparameter, arg).hold());
2979 if (is_a<add>(buffer)) {
2980 for (std::size_t i = 0; i < buffer.nops(); i++) {
2981 res += trafo_H_1tx_prepend_zero(buffer.op(i), arg);
2984 res += trafo_H_1tx_prepend_zero(buffer, arg);
2988 }
else if (parameter.op(0) == -1) {
2991 ex res = convert_H_to_zeta(parameter);
2992 map_trafo_H_1overx recursion;
2993 ex buffer = recursion(H(newparameter, arg).hold());
2994 if (is_a<add>(buffer)) {
2995 for (std::size_t i = 0; i < buffer.nops(); i++) {
2996 res += trafo_H_1tx_prepend_zero(buffer.op(i), arg) - trafo_H_1tx_prepend_minusone(buffer.op(i), arg);
2999 res += trafo_H_1tx_prepend_zero(buffer, arg) - trafo_H_1tx_prepend_minusone(buffer, arg);
3006 map_trafo_H_1overx recursion;
3007 map_trafo_H_mult unify;
3008 ex res = H(
lst{ex(1)}, arg).hold() * H(newparameter, arg).hold();
3009 std::size_t firstzero = 0;
3010 while (parameter.op(firstzero) == 1) {
3013 for (std::size_t i = firstzero-1; i < parameter.nops() - 1; i++) {
3017 newparameter.append(parameter[j+1]);
3019 newparameter.append(1);
3020 for (; j<parameter.nops()-1; j++) {
3021 newparameter.append(parameter[j+1]);
3023 res -= H(newparameter, arg).hold();
3025 res = recursion(res).expand() / firstzero;
3038struct map_trafo_H_1mxt1px :
public map_function
3040 ex operator()(
const ex& e)
override
3042 if (is_a<add>(e) || is_a<mul>(e)) {
3043 return e.map(*
this);
3046 if (is_a<function>(e)) {
3047 std::string name = ex_to<function>(e).get_name();
3050 lst parameter = ex_to<lst>(e.op(0));
3054 bool allthesame =
true;
3055 if (parameter.op(0) == 0) {
3056 for (std::size_t i = 1; i < parameter.nops(); i++) {
3057 if (parameter.op(i) != 0) {
3063 map_trafo_H_mult unify;
3064 return unify((
pow(-H(
lst{ex(1)},(1-arg)/(1+arg)).hold() - H(
lst{ex(-1)},(1-arg)/(1+arg)).hold(), parameter.nops())
3065 /
factorial(parameter.nops())).expand());
3067 }
else if (parameter.op(0) == -1) {
3068 for (std::size_t i = 1; i < parameter.nops(); i++) {
3069 if (parameter.op(i) != -1) {
3075 map_trafo_H_mult unify;
3076 return unify((
pow(
log(2) - H(
lst{ex(-1)},(1-arg)/(1+arg)).hold(), parameter.
nops())
3077 /
factorial(parameter.nops())).expand());
3080 for (std::size_t i = 1; i < parameter.nops(); i++) {
3081 if (parameter.op(i) != 1) {
3087 map_trafo_H_mult unify;
3088 return unify((
pow(-
log(2) - H(
lst{ex(0)},(1-arg)/(1+arg)).hold() + H(
lst{ex(-1)},(1-arg)/(1+arg)).hold(), parameter.
nops())
3089 /
factorial(parameter.nops())).expand());
3093 lst newparameter = parameter;
3094 newparameter.remove_first();
3096 if (parameter.op(0) == 0) {
3099 ex res = convert_H_to_zeta(parameter);
3100 map_trafo_H_1mxt1px recursion;
3101 ex buffer = recursion(H(newparameter, arg).hold());
3102 if (is_a<add>(buffer)) {
3103 for (std::size_t i = 0; i < buffer.nops(); i++) {
3104 res -= trafo_H_1mxt1px_prepend_one(buffer.op(i), arg) + trafo_H_1mxt1px_prepend_minusone(buffer.op(i), arg);
3107 res -= trafo_H_1mxt1px_prepend_one(buffer, arg) + trafo_H_1mxt1px_prepend_minusone(buffer, arg);
3111 }
else if (parameter.op(0) == -1) {
3114 ex res = convert_H_to_zeta(parameter);
3115 map_trafo_H_1mxt1px recursion;
3116 ex buffer = recursion(H(newparameter, arg).hold());
3117 if (is_a<add>(buffer)) {
3118 for (std::size_t i = 0; i < buffer.nops(); i++) {
3119 res -= trafo_H_1mxt1px_prepend_minusone(buffer.op(i), arg);
3122 res -= trafo_H_1mxt1px_prepend_minusone(buffer, arg);
3129 map_trafo_H_1mxt1px recursion;
3130 map_trafo_H_mult unify;
3131 ex res = H(
lst{ex(1)}, arg).hold() * H(newparameter, arg).hold();
3132 std::size_t firstzero = 0;
3133 while (parameter.op(firstzero) == 1) {
3136 for (std::size_t i = firstzero - 1; i < parameter.nops() - 1; i++) {
3140 newparameter.append(parameter[j+1]);
3142 newparameter.append(1);
3143 for (; j<parameter.nops()-1; j++) {
3144 newparameter.append(parameter[j+1]);
3146 res -= H(newparameter, arg).hold();
3148 res = recursion(res).expand() / firstzero;
3161cln::cl_N H_do_sum(
const std::vector<int>&
m,
const cln::cl_N&
x)
3163 const int j =
m.size();
3165 std::vector<cln::cl_N> t(j);
3167 cln::cl_F
one = cln::cl_float(1, cln::float_format(
Digits));
3174 t[j-1] = t[j-1] + 1 / cln::expt(cln::cl_I(q),
m[j-1]);
3175 for (
int k=j-2;
k>=1;
k--) {
3176 t[
k] = t[
k] + t[
k+1] / cln::expt(cln::cl_I(q+j-1-
k),
m[
k]);
3178 t[0] = t[0] + t[1] *
factor / cln::expt(cln::cl_I(q+j-1),
m[0]);
3180 }
while (t[0] != t0buf);
3200 if (is_a<lst>(x1)) {
3203 if (is_a<numeric>(x2)) {
3204 x = ex_to<numeric>(x2).to_cl_N();
3207 if (is_a<numeric>(x2_val)) {
3208 x = ex_to<numeric>(x2_val).to_cl_N();
3212 for (std::size_t i = 0; i < x1.
nops(); i++) {
3214 return H(x1, x2).hold();
3217 if (x1.
nops() < 1) {
3218 return H(x1, x2).hold();
3221 const lst& morg = ex_to<lst>(x1);
3223 if (*(--morg.
end()) == 0) {
3225 map_trafo_H_reduce_trailing_zeros filter;
3226 return filter(H(x1, xtemp).hold()).subs(xtemp==x2).evalf();
3230 for (
const auto & it : morg) {
3232 for (
ex count=it-1; count > 0; count--) {
3236 }
else if (it <= -1) {
3237 for (
ex count=it+1; count < 0; count++) {
3247 if (cln::abs(
x) < 0.95) {
3251 if (convert_parameter_H_to_Li(
m, m_lst, s_lst, pf)) {
3253 std::vector<int> m_int;
3254 std::vector<cln::cl_N> x_cln;
3255 for (
auto it_int = m_lst.
begin(), it_cln = s_lst.
begin();
3256 it_int != m_lst.
end(); it_int++, it_cln++) {
3257 m_int.push_back(ex_to<numeric>(*it_int).to_int());
3258 x_cln.push_back(ex_to<numeric>(*it_cln).to_cl_N());
3260 x_cln.front() = x_cln.front() *
x;
3261 return pf *
numeric(multipleLi_do_sum(m_int, x_cln));
3265 if (m_lst.
nops() == 1) {
3266 return Li(m_lst.
op(0), x2).evalf();
3268 std::vector<int> m_int;
3269 for (
const auto & it : m_lst) {
3270 m_int.push_back(ex_to<numeric>(it).to_int());
3272 return numeric(H_do_sum(m_int,
x));
3280 if (cln::realpart(
x) < 0) {
3282 for (std::size_t i = 0; i <
m.nops(); i++) {
3291 if (cln::abs(
x) >= 2.0) {
3292 map_trafo_H_1overx trafo;
3293 res *= trafo(H(
m, xtemp).hold());
3294 if (cln::imagpart(
x) <= 0) {
3295 res = res.
subs(H_polesign == -
I*
Pi);
3297 res = res.
subs(H_polesign ==
I*
Pi);
3303 bool has_minus_one =
false;
3304 for (
const auto & it :
m) {
3306 has_minus_one =
true;
3312 if (cln::abs(
x-9.53) <= 9.47) {
3314 map_trafo_H_1mxt1px trafo;
3315 res *= trafo(H(
m, xtemp).hold());
3318 if (has_minus_one) {
3319 map_trafo_H_convert_to_Li filter;
3321 res *= filter(H(
m,
numeric(
x)).hold()).evalf();
3324 map_trafo_H_1mx trafo;
3325 res *= trafo(H(
m, xtemp).hold());
3331 return H(x1,x2).hold();
3338 if (is_a<lst>(m_)) {
3343 if (
m.nops() == 0) {
3351 if (*
m.begin() >
_ex1) {
3357 }
else if (*
m.begin() <
_ex_1) {
3363 }
else if (*
m.begin() ==
_ex0) {
3370 for (
auto it = ++
m.begin(); it !=
m.end(); it++) {
3382 }
else if (*it <
_ex_1) {
3402 }
else if (
step == 1) {
3415 return H(m_,
x).hold();
3419 return convert_H_to_zeta(
m);
3425 return H(m_,
x).hold();
3432 }
else if ((
step == 1) && (pos1 ==
_ex0)){
3437 return pow(-1, p) * S(
n, p, -
x);
3446 return H(m_,
x).hold();
3453 return pseries(rel, std::move(seq));
3460 if (deriv_param == 0) {
3464 if (is_a<lst>(m_)) {
3480 return 1/(1-
x) * H(
m,
x);
3481 }
else if (mb ==
_ex_1) {
3482 return 1/(1+
x) * H(
m,
x);
3492 if (is_a<lst>(m_)) {
3497 c.s <<
"\\mathrm{H}_{";
3501 for (; itm !=
m.end(); itm++) {
3517 do_not_evalf_params());
3523 map_trafo_H_reduce_trailing_zeros filter;
3524 map_trafo_H_convert_to_Li filter2;
3526 return filter2(filter(H(
m,
x).hold()));
3528 return filter2(filter(H(
lst{
m},
x).hold()));
3547const cln::cl_N lambda = cln::cl_N(
"319/320");
3549void halfcyclic_convolute(
const std::vector<cln::cl_N>& a,
const std::vector<cln::cl_N>& b, std::vector<cln::cl_N>&
c)
3551 const int size = a.size();
3552 for (
int n=0;
n<size;
n++) {
3554 for (
int m=0;
m<=
n;
m++) {
3562static void initcX(std::vector<cln::cl_N>& crX,
3563 const std::vector<int>& s,
3566 std::vector<cln::cl_N> crB(L2 + 1);
3567 for (
int i=0; i<=L2; i++)
3572 std::vector<std::vector<cln::cl_N>> crG(s.size() - 1, std::vector<cln::cl_N>(L2 + 1));
3573 for (
int m=0;
m < (int)s.size() - 1;
m++) {
3576 for (
int i = 0; i <= L2; i++)
3577 crG[
m][i] = cln::factorial(i + Sm -
m - 2) / cln::factorial(i + Smp1 -
m - 2);
3582 for (std::size_t
m = 0;
m < s.size() - 1;
m++) {
3583 std::vector<cln::cl_N> Xbuf(L2 + 1);
3584 for (
int i = 0; i <= L2; i++)
3585 Xbuf[i] = crX[i] * crG[
m][i];
3587 halfcyclic_convolute(Xbuf, crB, crX);
3593static cln::cl_N crandall_Y_loop(
const cln::cl_N& Sqk,
3594 const std::vector<cln::cl_N>& crX)
3596 cln::cl_F
one = cln::cl_float(1, cln::float_format(
Digits));
3597 cln::cl_N
factor = cln::expt(lambda, Sqk);
3598 cln::cl_N res =
factor / Sqk * crX[0] *
one;
3605 res = res + crX[N] *
factor / (N+Sqk);
3606 }
while (((res != resbuf) || cln::zerop(crX[N])) && (N+1 < crX.size()));
3612static void calc_f(std::vector<std::vector<cln::cl_N>>& f_kj,
3613 const int maxr,
const int L1)
3615 cln::cl_N t0, t1, t2, t3, t4;
3617 auto it = f_kj.
begin();
3618 cln::cl_F
one = cln::cl_float(1, cln::float_format(
Digits));
3620 t0 = cln::exp(-lambda);
3622 for (
k=1;
k<=L1;
k++) {
3625 for (j=1; j<=maxr; j++) {
3628 for (i=2; i<=j; i++) {
3632 (*it).push_back(t2 * t3 * cln::expt(cln::cl_I(
k),-j) *
one);
3640static cln::cl_N crandall_Z(
const std::vector<int>& s,
3641 const std::vector<std::vector<cln::cl_N>>& f_kj)
3643 const int j = s.size();
3652 t0 = t0 + f_kj[q+j-2][s[0]-1];
3653 }
while ((t0 != t0buf) && (q+j-1 < f_kj.size()));
3655 return t0 / cln::factorial(s[0]-1);
3658 std::vector<cln::cl_N> t(j);
3665 t[j-1] = t[j-1] + 1 / cln::expt(cln::cl_I(q),s[j-1]);
3666 for (
int k=j-2;
k>=1;
k--) {
3667 t[
k] = t[
k] + t[
k+1] / cln::expt(cln::cl_I(q+j-1-
k), s[
k]);
3669 t[0] = t[0] + t[1] * f_kj[q+j-2][s[0]-1];
3670 }
while ((t[0] != t0buf) && (q+j-1 < f_kj.size()));
3672 return t[0] / cln::factorial(s[0]-1);
3677cln::cl_N zeta_do_sum_Crandall(
const std::vector<int>& s)
3679 std::vector<int>
r = s;
3680 const int j =
r.size();
3695 }
else if (
Digits < 86) {
3697 }
else if (
Digits < 192) {
3699 }
else if (
Digits < 394) {
3701 }
else if (
Digits < 808) {
3703 }
else if (
Digits < 1636) {
3707 L2 = std::pow(2, ceil( std::log2((
long(
Digits))/0.79 + 40 )) ) - 1;
3714 for (
int i=0; i<j; i++) {
3721 std::vector<std::vector<cln::cl_N>> f_kj(L1);
3722 calc_f(f_kj, maxr, L1);
3724 const cln::cl_N r0factorial = cln::factorial(
r[0]-1);
3726 std::vector<int> rz;
3729 for (
int k=
r.size()-1;
k>0;
k--) {
3731 rz.insert(rz.begin(),
r.back());
3732 skp1buf = rz.front();
3736 std::vector<cln::cl_N> crX;
3739 for (
int q=0; q<skp1buf; q++) {
3741 cln::cl_N pp1 = crandall_Y_loop(Srun+q-
k, crX);
3742 cln::cl_N pp2 = crandall_Z(rz, f_kj);
3747 res = res - pp1 * pp2 / cln::factorial(q);
3749 res = res + pp1 * pp2 / cln::factorial(q);
3752 rz.front() = skp1buf;
3754 rz.insert(rz.begin(),
r.back());
3756 std::vector<cln::cl_N> crX;
3757 initcX(crX, rz, L2);
3759 res = (res + crandall_Y_loop(S-j, crX)) / r0factorial
3760 + crandall_Z(rz, f_kj);
3766cln::cl_N zeta_do_sum_simple(
const std::vector<int>&
r)
3768 const int j =
r.size();
3771 std::vector<cln::cl_N> t(j);
3772 cln::cl_F
one = cln::cl_float(1, cln::float_format(
Digits));
3779 t[j-1] = t[j-1] +
one / cln::expt(cln::cl_I(q),
r[j-1]);
3780 for (
int k=j-2;
k>=0;
k--) {
3781 t[
k] = t[
k] +
one * t[
k+1] / cln::expt(cln::cl_I(q+j-1-
k),
r[
k]);
3783 }
while (t[0] != t0buf);
3790cln::cl_N zeta_do_Hoelder_convolution(
const std::vector<int>& m_,
const std::vector<int>& s_)
3794 std::vector<int> s = s_;
3795 std::vector<int> m_p = m_;
3796 std::vector<int> m_q;
3798 std::vector<cln::cl_N> s_p(s.size(), cln::cl_N(1));
3799 s_p[0] = s_p[0] * cln::cl_N(
"1/2");
3802 for (std::size_t i = 0; i < s_.size(); i++) {
3807 s[i] = sig * std::abs(s[i]);
3809 std::vector<cln::cl_N> s_q;
3810 cln::cl_N signum = 1;
3813 cln::cl_N res = multipleLi_do_sum(m_p, s_p);
3819 if (s.front() > 0) {
3820 if (m_p.front() == 1) {
3821 m_p.erase(m_p.begin());
3822 s_p.erase(s_p.begin());
3823 if (s_p.size() > 0) {
3824 s_p.front() = s_p.front() * cln::cl_N(
"1/2");
3830 m_q.insert(m_q.begin(), 1);
3831 if (s_q.size() > 0) {
3832 s_q.front() = s_q.front() * 2;
3834 s_q.insert(s_q.begin(), cln::cl_N(
"1/2"));
3837 if (m_p.front() == 1) {
3838 m_p.erase(m_p.begin());
3839 cln::cl_N spbuf = s_p.front();
3840 s_p.erase(s_p.begin());
3841 if (s_p.size() > 0) {
3842 s_p.front() = s_p.front() * spbuf;
3845 m_q.insert(m_q.begin(), 1);
3846 if (s_q.size() > 0) {
3847 s_q.front() = s_q.front() * 4;
3849 s_q.insert(s_q.begin(), cln::cl_N(
"1/4"));
3853 m_q.insert(m_q.begin(), 1);
3854 if (s_q.size() > 0) {
3855 s_q.front() = s_q.front() * 2;
3857 s_q.insert(s_q.begin(), cln::cl_N(
"1/2"));
3862 if (m_p.size() == 0)
break;
3864 res = res + signum * multipleLi_do_sum(m_p, s_p) * multipleLi_do_sum(m_q, s_q);
3869 res = res + signum * multipleLi_do_sum(m_q, s_q);
3889 if (is_exactly_a<lst>(
x) && (
x.
nops()>1)) {
3892 const int count =
x.
nops();
3893 const lst& xlst = ex_to<lst>(
x);
3894 std::vector<int>
r(count);
3895 std::vector<int> si(count);
3898 auto it1 = xlst.
begin();
3899 auto it2 =
r.begin();
3900 auto it_swrite = si.begin();
3905 *it2 = ex_to<numeric>(*it1).to_int();
3910 }
while (it2 !=
r.end());
3919 return numeric(zeta_do_Hoelder_convolution(
r, si));
3923 int limit = (
Digits>17) ? 10 : 6;
3924 if ((
r[0] < limit) || ((count > 3) && (
r[1] < limit/2))) {
3925 return numeric(zeta_do_sum_Crandall(
r));
3927 return numeric(zeta_do_sum_simple(
r));
3932 if (is_exactly_a<numeric>(
x) && (
x != 1)) {
3934 return zeta(ex_to<numeric>(
x));
3935 }
catch (
const dunno &e) { }
3944 if (is_exactly_a<lst>(
m)) {
3945 if (
m.nops() == 1) {
3946 return zeta(
m.op(0));
3952 const numeric& y = ex_to<numeric>(
m);
3988 if (is_exactly_a<lst>(
m)) {
3991 return zetaderiv(
_ex1,
m);
3999 if (is_a<lst>(m_)) {
4000 const lst&
m = ex_to<lst>(m_);
4001 auto it =
m.begin();
4004 for (; it !=
m.end(); it++) {
4020 do_not_evalf_params().
4035 if (is_exactly_a<lst>(
x)) {
4038 const int count =
x.
nops();
4039 const lst& xlst = ex_to<lst>(
x);
4040 const lst& slst = ex_to<lst>(s);
4041 std::vector<int> xi(count);
4042 std::vector<int> si(count);
4045 auto it_xread = xlst.
begin();
4046 auto it_sread = slst.
begin();
4047 auto it_xwrite = xi.begin();
4048 auto it_swrite = si.begin();
4053 *it_xwrite = ex_to<numeric>(*it_xread).to_int();
4054 if (*it_sread > 0) {
4063 }
while (it_xwrite != xi.end());
4066 if ((xi[0] == 1) && (si[0] == 1)) {
4071 return numeric(zeta_do_Hoelder_convolution(xi, si));
4081 if (is_exactly_a<lst>(s_)) {
4082 const lst& s = ex_to<lst>(s_);
4083 for (
const auto & it : s) {
4102 if (is_exactly_a<lst>(
m)) {
4106 return zetaderiv(
_ex1,
m);
4116 if (is_a<lst>(m_)) {
4122 if (is_a<lst>(s_)) {
4129 auto its = s.
begin();
4131 c.s <<
"\\overline{";
4139 for (; itm !=
m.end(); itm++, its++) {
4142 c.s <<
"\\overline{";
4158 do_not_evalf_params().
Interface to GiNaC's sums of expressions.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
virtual size_t nops() const
Number of operands/members.
const basic & hold() const
Stop further evaluation.
virtual ex map(map_function &f) const
Construct new expression by applying the specified function to all sub-expressions (one level only,...
Wrapper template for making GiNaC classes out of STL containers.
const_iterator end() const
const_iterator begin() const
size_t nops() const override
Number of operands/members.
ex op(size_t i) const override
Return operand/member at position i.
container & append(const ex &b)
Add element at back.
Exception class thrown by classes which provide their own series expansion to signal that ordinary Ta...
Exception class thrown by functions to signal unimplemented functionality so the expression may just ...
Lightweight wrapper for GiNaC's symbolic objects.
ex map(map_function &f) const
const_iterator begin() const noexcept
bool is_equal(const ex &other) const
ex & let_op(size_t i)
Return modifiable operand/member at position i.
const_iterator end() const noexcept
ex series(const ex &r, int order, unsigned options=0) const
Compute the truncated series expansion of an expression.
ex subs(const exmap &m, unsigned options=0) const
bool info(unsigned inf) const
void print(const print_context &c, unsigned level=0) const
Print expression to stream.
static unsigned register_new(function_options const &opt)
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
bool info(unsigned inf) const override
Information about the object.
bool is_integer() const
True if object is a non-complex integer.
cln::cl_N to_cl_N() const
Returns a new CLN object of type cl_N, representing the value of *this.
bool is_equal(const numeric &other) const
int to_int() const
Converts numeric types to machine's int.
bool is_zero() const
True if object is zero.
This class holds a two-component object, a basis and and exponent representing exponentiation.
Base class for print_contexts.
This class holds a extended truncated power series (positive and negative integer powers).
This class holds a relation consisting of two expressions and a logical relation between them.
@ no_pattern
disable pattern matching
Interface to GiNaC's constant types and some special constants.
#define REGISTER_FUNCTION(NAME, OPT)
Interface to GiNaC's initially known functions.
Definition of GiNaC's lst.
Interface to GiNaC's products of expressions.
static ex G3_eval(const ex &x_, const ex &s_, const ex &y)
const numeric I
Imaginary unit.
static ex zeta2_evalf(const ex &x, const ex &s)
static ex Li_evalf(const ex &m_, const ex &x_)
const numeric pow(const numeric &x, const numeric &y)
static ex H_deriv(const ex &m_, const ex &x, unsigned deriv_param)
static ex S_eval(const ex &n, const ex &p, const ex &x)
container< std::list > lst
static ex Li_deriv(const ex &m_, const ex &x_, unsigned deriv_param)
std::map< ex, ex, ex_is_less > exmap
const numeric bernoulli(const numeric &nn)
Bernoulli number.
std::vector< expair > epvector
expair-vector
const numeric abs(const numeric &x)
Absolute value.
function zeta(const T1 &p1)
static void S_print_latex(const ex &n, const ex &p, const ex &x, const print_context &c)
static ex S_evalf(const ex &n, const ex &p, const ex &x)
ex conjugate(const ex &thisex)
static ex zeta2_eval(const ex &m, const ex &s_)
const numeric imag(const numeric &x)
static ex S_deriv(const ex &n, const ex &p, const ex &x, unsigned deriv_param)
static ex Li_series(const ex &m, const ex &x, const relational &rel, int order, unsigned options)
const numeric factorial(const numeric &n)
Factorial combinatorial function.
static void H_print_latex(const ex &m_, const ex &x, const print_context &c)
const constant Pi("Pi", PiEvalf, "\\pi", domain::positive)
Pi.
static ex Li_eval(const ex &m_, const ex &x_)
static ex H_series(const ex &m, const ex &x, const relational &rel, int order, unsigned options)
static void Li_print_latex(const ex &m_, const ex &x_, const print_context &c)
static ex zeta1_eval(const ex &m)
static ex G2_eval(const ex &x_, const ex &y)
const numeric log(const numeric &x)
Natural logarithm.
ex evalf(const ex &thisex)
_numeric_digits Digits
Accuracy in decimal digits.
bool is_real(const numeric &x)
ex op(const ex &thisex, size_t i)
static void zeta1_print_latex(const ex &m_, const print_context &c)
const constant Catalan("Catalan", CatalanEvalf, "G", domain::positive)
Catalan's constant.
static ex zeta2_deriv(const ex &m, const ex &s, unsigned deriv_param)
static void zeta2_print_latex(const ex &m_, const ex &s_, const print_context &c)
static ex G2_evalf(const ex &x_, const ex &y)
static ex S_series(const ex &n, const ex &p, const ex &x, const relational &rel, int order, unsigned options)
ex factor(const ex &poly, unsigned options)
Interface function to the outside world.
int to_int(const numeric &x)
ex convert_H_to_Li(const ex ¶meterlst, const ex &arg)
Converts a given list containing parameters for H in Remiddi/Vermaseren notation into the correspondi...
static ex H_evalf(const ex &x1, const ex &x2)
static ex G3_evalf(const ex &x_, const ex &s_, const ex &y)
static ex zeta1_evalf(const ex &x)
std::vector< ex > exvector
static ex zeta1_deriv(const ex &m, unsigned deriv_param)
static ex H_eval(const ex &m_, const ex &x)
numeric step(const numeric &x)
function G(const T1 &x, const T2 &y)
ex expand(const ex &thisex, unsigned options=0)
Makes the interface to the underlying bignum package available.
Interface to GiNaC's overloaded operators.
Interface to GiNaC's symbolic exponentiation (basis^exponent).
Interface to class for extended truncated power series.
Interface to relations between expressions.
Interface to GiNaC's symbolic objects.
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...
Interface to GiNaC's wildcard objects.