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


// David Jeffrey - Rectifying Transformations for Trig Integration (1997)

// Problem (1.2)
[3/(5-4*cos(x)),x,2,x+2*arctan(sin(x)/(2-cos(x)))],

// Problem (1.4)
[(1+cos(x)+2*sin(x))/(3+cos(x)^2+2*sin(x)-2*cos(x)*sin(x)),x,-43,-arctan((2*cos(x)-sin(x))/(2+sin(x)))],

// Problem (1.5)
[(2+cos(x)+5*sin(x))/(4*cos(x)-2*sin(x)+cos(x)*sin(x)-2*sin(x)^2),x,-25,-log(1-3*cos(x)+sin(x))+log(3+cos(x)+sin(x))],

// Problem (3.3)
[(3+7*cos(x)+2*sin(x))/(1+4*cos(x)+3*cos(x)^2-5*sin(x)-cos(x)*sin(x)),x,-32,-log(1+cos(x)-2*sin(x))+log(3+cos(x)+sin(x))],

// Problem 
[(-1+4*cos(x)+5*cos(x)^2)/(-1-4*cos(x)-3*cos(x)^2+4*cos(x)^3),x,-2,x-2*arctan(sin(x)/(3+cos(x)))-2*arctan((3*sin(x)+7*cos(x)*sin(x))/(1+2*cos(x)+5*cos(x)^2))],

// Problem 
[(-5+2*cos(x)+7*cos(x)^2)/(-1+2*cos(x)-9*cos(x)^2+4*cos(x)^3),x,-2,x-2*arctan(2*cos(x)*sin(x)/(1-cos(x)+2*cos(x)^2))],

// Problem (3.4)
[3/(5+4*sin(x)),x,2,x+2*arctan(cos(x)/(2+sin(x)))],

// Problem (3.6)
[2/(1+cos(x)^2),x,3,x*sqrt(2)-arctan(cos(x)*sin(x)/(1+cos(x)^2+sqrt(2)))*sqrt(2)],

// Problem (3.8)
[1/(p+q*cos(x)+r*sin(x)),x,3,2*arctan((r+(p-q)*tan(1/2*x))/sqrt(p^2-q^2-r^2))/sqrt(p^2-q^2-r^2)],
];

res:=[]:;
S:=182; S:=size(lst);
failint:=[]; failsimp:=[]; nock:=[]; ass:=[];
print("Integration independent test suites, Jeffrey "+S);
file:=fopen("intindj.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");
  purge(unquote(assumptions));
  fgh:=""+eval([j+1,f,g,h],1);
  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, Jeffrey ","tests: ",S,", integration failures: ",size(failint),failint,", simplification failures: ",size(failsimp),failsimp,", not cheked: ",size(nock),nock,", assumptions: ",size(ass),ass);
//res;
