+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// H/Li exam
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+
+static unsigned inifcns_test_LiG()
+{
+ int digitsbuf = Digits;
+ Digits = 17;
+ ex prec = 5 * pow(10, -(ex)Digits);
+ numeric almostone("0.99999999999999999999");
+ unsigned result = 0;
+
+ lst res;
+
+ res.append(Li(lst{4}, lst{6}).hold() - Li(4, 6.0));
+ res.append(G(lst{0,0,5.0,0,2.0,0,0,0,3.0},0.5).hold()
+ + Li(lst{3,2,4}, lst{numeric(1,10), numeric(5,2), numeric(2,3)}));
+ res.append(Li(lst{2,1,1}, lst{almostone, almostone, almostone}) - zeta(lst{2,1,1}));
+
+ // check Li_{1,1} against known expression
+ symbol x("x"), y("y");
+ ex eps = 1e-30*I;
+ ex s1 = Li(lst{1,1},lst{x,y});
+ ex s2 = log(1-1/x/y-eps)*log((1-1/x-eps)/(1/x/y-1/x)) + Li(2,(1-1/x/y-eps)/(1/x-1/x/y))
+ - log(-1/x/y-eps)*log((-1/x-eps)/(1/x/y-1/x)) - Li(2,(-1/x/y-eps)/(1/x-1/x/y))
+ - log(-1/x/y-eps)*log(1-1/x-eps) + log(-1/x/y-eps)*log(-1/x-eps);
+ res.append(s1.subs(lst{x==numeric(1)/2, y==3}) - s2.subs(lst{x==numeric(1)/2, y==3}));
+ res.append(s1.subs(lst{x==numeric(3)/2, y==numeric(1)/2}) - s2.subs(lst{x==numeric(3)/2, y==numeric(1)/2}));
+ res.append(s1.subs(lst{x==2, y==numeric(4)/5}) - s2.subs(lst{x==2, y==numeric(4)/5}));
+
+ // shuffle and quasi-shuffle identities
+ res.append(G(lst{0,0.2},1).hold() * G(lst{0.5},1).hold() - G(lst{0.5,0,0.2},1).hold()
+ - G(lst{0,0.5,0.2},1).hold() - G(lst{0,0.2,0.5},1).hold());
+ res.append(G(lst{0,0.5},1).hold() * G(lst{0.6},1).hold() - G(lst{0,0.5,0.5*0.6},1).hold()
+ - G(lst{0.6,0,0.5*0.6},1).hold() + G(lst{0,0,0.5*0.6},1).hold());
+ res.append(Li(lst{2},lst{numeric(1,5)}).hold() * Li(lst{3},lst{7}).hold() - Li(lst{2,3},lst{numeric(1,5),7}).hold()
+ - Li(lst{3,2},lst{7,numeric(1,5)}).hold() - Li(lst{5},lst{numeric(7,5)}).hold());
+ symbol a1, a2, a3, a4;
+ res.append((G(lst{a1,a2},1) * G(lst{a3,a4},1) - G(lst{a1,a2,a3,a4},1)
+ - G(lst{a1,a3,a2,a4},1) - G(lst{a3,a1,a2,a4},1)
+ - G(lst{a1,a3,a4,a2},1) - G(lst{a3,a1,a4,a2},1) - G(lst{a3,a4,a1,a2},1))
+ .subs(lst{a1==numeric(1)/10, a2==numeric(3)/10, a3==numeric(7)/10, a4==5}));
+ res.append(G(lst{-0.009},1).hold() * G(lst{-8,1.4999},1).hold() - G(lst{-0.009,-8,1.4999},1).hold()
+ - G(lst{-8,-0.009,1.4999},1).hold() - G(lst{-8,1.4999,-0.009},1).hold());
+ res.append(G(lst{sqrt(numeric(1)/2)+I*sqrt(numeric(1)/2)},1).hold() * G(lst{1.51,-0.999},1).hold()
+ - G(lst{sqrt(numeric(1)/2)+I*sqrt(numeric(1)/2),1.51,-0.999},1).hold()
+ - G(lst{1.51,sqrt(numeric(1)/2)+I*sqrt(numeric(1)/2),-0.999},1).hold()
+ - G(lst{1.51,-0.999,sqrt(numeric(1)/2)+I*sqrt(numeric(1)/2)},1).hold());
+ // checks for hoelder convolution which is used if one argument has a distance to one smaller than 0.01
+ res.append(G(lst{0, 1.2, 1, 1.01}, 1).hold() - G(lst{0, 1.2, 1, numeric("1.009999999999999999")}, 1).hold());
+
+ for (lst::const_iterator it = res.begin(); it != res.end(); it++) {
+ ex diff = abs((*it).evalf());
+ if (diff > prec) {
+ clog << *it << " seems to be wrong: " << diff << endl;
+ result++;
+ }
+ cout << "." << flush;
+ }
+
+ Digits = digitsbuf;
+
+ return result;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// legacy exam - checking for historical bugs
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+
+static unsigned inifcns_test_legacy()
+{
+ int digitsbuf = Digits;
+ Digits = 17;
+ ex prec = 5 * pow(10, -(ex)Digits);
+
+ unsigned result = 0;
+
+ ex r1 = zeta(lst{1,1,1,1,1,1}, lst{-1,-1,-1,1,1,1});
+ if ((r1.evalf() - numeric("-0.0012588769028204890704")) > prec) {
+ clog << "zeta({1,1,1,1,1,1},{-1,-1,-1,1,1,1}) seems to be wrong." << endl;
+ result++;
+ }
+
+ ex x1 = exp(2*Pi*I/13).evalf();
+ ex x2 = exp(24*Pi*I/13).evalf();
+ ex r2 = Li(lst{2},lst{x1}).hold().evalf();
+ ex r3 = Li(lst{2},lst{x2}).hold().evalf();
+ if ( abs(r2-conjugate(r3)) > prec ) {
+ clog << "Legacy test 2 seems to be wrong." << endl;
+ result++;
+ }
+
+ ex x3 = exp(5*Pi*I/3).evalf();
+ ex r4 = Li(lst{3},lst{x3}).hold().evalf();
+ if ( abs(r4 - numeric("0.40068563438653142847-0.95698384815740185713*I")) > prec ) {
+ clog << "Legacy test 3 seems to be wrong." << endl;
+ result++;
+ }
+
+ Digits = 100;
+ prec = 5 * pow(10, -(ex)Digits);
+ ex x0 = 1.;
+ x1 = exp(Pi*I/3).evalf();
+ x2 = exp(2*Pi*I/3).evalf();
+ x3 = -1.;
+ ex x4 = exp(4*Pi*I/3).evalf();
+ ex x5 = exp(5*Pi*I/3).evalf();
+
+ ex r5 = Li(lst{1,1,1,1},lst{x2,x4,x3,x0}).hold().evalf();
+ ex r6 = Li(lst{1,1,1,1},lst{x4,x2,x3,x0}).hold().evalf();
+ if ( abs(r5-conjugate(r6)) > prec ) {
+ clog << "Legacy test 4 seems to be wrong." << endl;
+ result++;
+ }
+
+ ex r7 = Li(lst{1,2,1},lst{x3,x2,x4}).hold().evalf()
+ +Li(lst{1,1,2},lst{x3,x2,x4}).hold().evalf()
+ +Li(lst{1,1,1,1},lst{x3,x0,x2,x4}).hold().evalf()
+ +Li(lst{1,1,1,1},lst{x3,x2,x0,x4}).hold().evalf()
+ +Li(lst{1,1,1,1},lst{x3,x2,x4,x0}).hold().evalf()
+ +Li(lst{1,2,1},lst{x2,x1,x0}).hold().evalf()
+ +Li(lst{1,1,2},lst{x2,x3,x4}).hold().evalf()
+ +Li(lst{1,1,1,1},lst{x2,x4,x3,x0}).hold().evalf()
+ +Li(lst{1,1,1,1},lst{x2,x3,x4,x0}).hold().evalf()
+ +Li(lst{1,1,1,1},lst{x2,x3,x0,x4}).hold().evalf()
+ +Li(lst{2,2},lst{x5,x4}).hold().evalf()
+ +Li(lst{2,1,1},lst{x5,x0,x4}).hold().evalf()
+ +Li(lst{2,1,1},lst{x5,x4,x0}).hold().evalf()
+ -Li(lst{1,1},lst{x3,x0}).hold().evalf()*Li(lst{1,1},lst{x2,x4}).hold().evalf();
+ if ( abs(r7) > prec ) {
+ clog << "Legacy test 5 seems to be wrong." << endl;
+ result++;
+ }
+
+ Digits = digitsbuf;
+
+ return result;
+}
+
+static unsigned check_G_y_one_bug()
+{
+ exvector exprs;
+ exprs.push_back(G(lst{-1,-1, 1,-1, 0}, 1));
+ exprs.push_back(G(lst{-1, 0, 1,-1, 0}, 1));
+ exprs.push_back(G(lst{-1, 1,-1,-1, 0}, 1));
+ exprs.push_back(G(lst{-1, 1,-1, 0, 0}, 1));
+ exprs.push_back(G(lst{-1, 1,-1, 1, 0}, 1));
+ exprs.push_back(G(lst{-1, 1, 0,-1, 0}, 1));
+ exprs.push_back(G(lst{-1, 1, 1,-1, 0}, 1));
+ exprs.push_back(G(lst{ 0,-1, 1,-1, 0}, 1));
+ exprs.push_back(G(lst{ 0, 1, 1,-1, 0}, 1));
+ unsigned err = 0;
+ for (exvector::const_iterator ep = exprs.begin(); ep != exprs.end(); ++ep) {
+ try {
+ ex val = ep->evalf();
+ if (!is_a<numeric>(val)) {
+ clog << "evalf(" << *ep << ") is not a number: " << val << endl;
+ ++err;
+ }
+ } catch (std::exception& oops) {
+ clog << "evalf(" << *ep << "): got an exception" << oops.what() << endl;
+ ++err;
+ }
+ }
+ return err;
+}
+