// Giac integration test file: "0 Independent test suites\Apostol Problems.txt"
// "nock" means we do not check the antiderivative
I:=i;
lst:=[


// Manuel Bronstein - Symbolic Integration Tutorial (1998)

// 2  Algebraic Functions
[(1+2*x^8)*sqrt(1+x^8)/(x+2*x^9+x^17),x,6,-1/4*arctanh(sqrt(1+x^8))+(-1/4)/sqrt(1+x^8)],
[1/(1+x^2),x,1,arctan(x)],
[sqrt(1+x^8)/(x*(1+x^8)),x,3,-1/4*arctanh(sqrt(1+x^8))],
[x/sqrt(1-x^3),x,3,2*sqrt(1-x^3)/(1-x+sqrt(3))+2*(1-x)*EllipticF((1-x-sqrt(3))/(1-x+sqrt(3)),sqrt(-7-4*sqrt(3)))*sqrt(2)*sqrt((1+x+x^2)/(1-x+sqrt(3))^2)/(3^(1/4)*sqrt(1-x^3)*sqrt((1-x)/(1-x+sqrt(3))^2))-3^(1/4)*(1-x)*EllipticE((1-x-sqrt(3))/(1-x+sqrt(3)),sqrt(-7-4*sqrt(3)))*sqrt(2-sqrt(3))*sqrt((1+x+x^2)/(1-x+sqrt(3))^2)/(sqrt(1-x^3)*sqrt((1-x)/(1-x+sqrt(3))^2))],
[1/(x*sqrt(1-x^3)),x,3,-2/3*arctanh(sqrt(1-x^3))],
[x/sqrt(-71-96*x+10*x^2+x^4),x,1,1/8*log(10001+3124*x^2-1408*x^3+54*x^4-128*x^5+20*x^6+x^8+(781-528*x+27*x^2-80*x^3+15*x^4+x^6)*sqrt(-71-96*x+10*x^2+x^4))],

// 3  Elementary Functions
[(x-tan(x))/tan(x)^2,x,6,-1/2*x^2-x*cot(x)],
[1+x*tan(x)+tan(x)^2,x,7,1/2*I*x^2-x*log(1+exp(2*I*x))+1/2*I*polylog(2,-exp(2*I*x))+tan(x)],
[sin(x)/x,x,1,Si(x)],
[(5*x^2+3*(exp(x)+x)^(1/3)+exp(x)*(3*x+2*x^2))/(x*(exp(x)+x)^(1/3)),x,8,3*x*(exp(x)+x)^(2/3)+3*log(x)],
[1/x+(1+1/x)/(x+log(x))^(3/2),x,2,log(x)+(-2)/sqrt(x+log(x))],
[(x^2+2*x*log(x)+log(x)^2+(1+x)*sqrt(x+log(x)))/(x^3+2*x^2*log(x)+x*log(x)^2),x,-3,log(x)+(-2)/sqrt(x+log(x))],
[(-x^2-log(x)+2*log(x)^2)/(-x^2*log(x)+log(x)^3),x,6,Li(x)-1/2*log(x-log(x))+1/2*log(x+log(x))],

//  {Log[1 + E^x]^(1/3)/(1 + Log[1 + E^x]), x, 0, CannotIntegrate[Log[1 + E^x]^(1/3)/(1 + Log[1 + E^x]), x]} 

//  {((x^2 + 2*x + 1)*Sqrt[x + Log[x]] + (3*x + 1)*Log[x] + 3*x^2 + x)/((x*Log[x] + x^2)*Sqrt[x + Log[x]] + x^2*Log[x] + x^3), x, 0, 2*Sqrt[x + Log[x]] + 2*Log[x + Sqrt[x + Log[x]]]} 

// Manuel Bronstein - Symbolic Integration I; Transcendental FunctionsTutorial (2005)

// 2.8  Rioboo's Algorithm for Real Rational Functions
[(6-3*x^2+x^4)/(4+5*x^2-5*x^4+x^6),x,1,arctan(1/2*x*(1-3*x^2+x^4))-arctan(-2*x+sqrt(3))+arctan(2*x+sqrt(3))]
];

res:=[]:;
S:=182; S:=size(lst);
failint:=[]; failsimp:=[]; nock:=[]; ass:=[];
print("Integration independent test suites, Bronstein "+S);
file:=fopen("intindbr.tst");
T0:=time();
for j from 0 to S-1 do
  l:=eval(lst,1)[j]; 
  f:=l[0]; v:=l[1]; hyp:=l[2]; print(f);
  purge(unquote(v));
  if (type(hyp)==string) expr(hyp); // eval assumption
  print(j+1,f,v,hyp,about(unquote(v)));
  try { g:=integrate(f,unquote(v)); } catch(err){ g:="integrate(err)"; }
  s:=""+eval(g,1);
  h:=false;
  fail:=size(s.find("integrate("))>0 || hyp==x;
  if (fail) failint.append(j+1);
  if (hyp=="nock") nock.append(j+1);
  if (hyp.type==string && size(hyp.find("assume("))>0) ass.append(j+1);
  if (hyp!="nock" && !fail)  h:=simplify(diff(g,unquote(v))-f); else print("nock");
  fgh:=""+eval([j+1,f,g,h],1);
  purge(unquote(assumptions));
  if (eval(h,1)!=0) failsimp.append(j+1);
  print(fgh);
  //res.append([f,g,h]); print(res[size(res)-1]);
  fprint(file,"",fgh);
od:;
fprint(file,"","Time:",time()-T0,", tests: ",S,", integration failures: ",size(failint),failint,", simplification failures: ",size(failsimp),failsimp,", not cheked: ",size(nock),nock,", assumptions: ",size(ass),ass);
fclose(file);
print("Integration independent test suites, Bronstein ","tests: ",S,", integration failures: ",size(failint),failint,", simplification failures: ",size(failsimp),failsimp,", not cheked: ",size(nock),nock,", assumptions: ",size(ass),ass);
//res;
