Rules for integrands of the form (((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))

0:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ A (b^2)-a b B+(a^2) C==0

Derivation: Algebraic simplification

Basis: If  A (b^2)-a b B+(a^2) C==0, then A+B z+C (z^2)==(((a+b z) (b B-a C+b C z))/(b^2))

Rule: If  b c-a d≠0 ∧ A (b^2)-a b B+(a^2) C==0, then

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  
(1/(b^2))∫(((a+b Tan[e+f x]))^(m+1))(((c+d Tan[e+f x]))^n)(b B-a C+b C Tan[e+f x])dx

Program code:

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  1/b^2*Int[(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^n*(b*B-a*C+b*C*Tan[e+f*x]),x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,m,n},x] && NeQ[b*c-a*d,0] && EqQ[A*b^2-a*b*B+a^2*C,0]

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  -C/b^2*Int[(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^n*(a-b*Tan[e+f*x]),x] /;
FreeQ[{a,b,c,d,e,f,A,C,m,n},x] && NeQ[b*c-a*d,0] && EqQ[A*b^2+a^2*C,0]

1:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+A ((Tan[e+f x])^2))dx

Derivation: Integration by substitution

Basis: F[Tan[e+f x]](A+A ((Tan[e+f x])^2))==(A/f)Subst[F[x],x,Tan[e+f x]](∂_x)Tan[e+f x]

Rule:

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+A ((Tan[e+f x])^2))dx  ⟶  (A/f) Subst[∫(((a+b x))^m)(((c+d x))^n)dx,x,Tan[e+f x]]

Program code:

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  A/f*Subst[Int[(a+b*x)^m*(c+d*x)^n,x],x,Tan[e+f*x]] /;
FreeQ[{a,b,c,d,e,f,A,C,m,n},x] && EqQ[A,C]

2.  ∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (c^2)+(d^2)≠0

1:  ∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (c^2)+(d^2)≠0 ∧ n<-1

Derivation: Algebraic expansion, nondegenerate tangent recurrence 1c with c->1,d->0,A->c,B->d,C->0,n->0,p->0 and algebraic simplification

Basis: A+B z+C (z^2)==(((c^2) C-B c d+A (d^2))/(d^2))-(((c+d z) (c C-B d-C d z))/(d^2))

Rule: If  b c-a d≠0 ∧ (c^2)+(d^2)≠0 ∧ n<-1, then

∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  

(((c^2) C-B c d+A (d^2))/(d^2))∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^n)dx-(1/(d^2))∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^(n+1))(c C-B d-C d Tan[e+f x])dx  ⟶  

-(((b c-a d) ((c^2) C-B c d+A (d^2)) (((c+d Tan[e+f x]))^(n+1)))/((d^2) f (n+1)((c^2)+(d^2))))+(1/(d ((c^2)+(d^2))))∫(((c+d Tan[e+f x]))^(n+1))·
(a d (A c-c C+B d)+b ((c^2) C-B c d+A (d^2))+d (A b c+a B c-b c C-a A d+b B d+a C d) Tan[e+f x]+b C ((c^2)+(d^2)) ((Tan[e+f x])^2))dx

Program code:

Int[(a_.+b_.*tan[e_.+f_.*x_])*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  -(b*c-a*d)*(c^2*C-B*c*d+A*d^2)*(c+d*Tan[e+f*x])^(n+1)/(d^2*f*(n+1)*(c^2+d^2)) + 
  1/(d*(c^2+d^2))*Int[(c+d*Tan[e+f*x])^(n+1)*
    Simp[a*d*(A*c-c*C+B*d)+b*(c^2*C-B*c*d+A*d^2)+d*(A*b*c+a*B*c-b*c*C-a*A*d+b*B*d+a*C*d)*Tan[e+f*x]+b*C*(c^2+d^2)*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C},x] && NeQ[b*c-a*d,0] && NeQ[c^2+d^2,0] && LtQ[n,-1]

Int[(a_.+b_.*tan[e_.+f_.*x_])*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  -(b*c-a*d)*(c^2*C+A*d^2)*(c+d*Tan[e+f*x])^(n+1)/(d^2*f*(n+1)*(c^2+d^2)) + 
  1/(d*(c^2+d^2))*Int[(c+d*Tan[e+f*x])^(n+1)*
    Simp[a*d*(A*c-c*C)+b*(c^2*C+A*d^2)+d*(A*b*c-b*c*C-a*A*d+a*C*d)*Tan[e+f*x]+b*C*(c^2+d^2)*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,C},x] && NeQ[b*c-a*d,0] && NeQ[c^2+d^2,0] && LtQ[n,-1]

2:  ∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (c^2)+(d^2)≠0 ∧ n≮-1

Derivation: Algebraic expansion, nondegenerate tangent recurrence 1b with c->0,d->1,A->a c,B->b c+a d,C->b d,m->1+m,n->0,p->0 and algebraic simplification

Basis: A+B z+C (z^2)==((C (((c+d z))^2))/(d^2))-(((c^2) C-A (d^2)+d (2 c C-B d) z)/(d^2))

Rule: If  b c-a d≠0 ∧ (c^2)+(d^2)≠0 ∧ n≮-1, then

∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  

(C/(d^2))∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^(n+2))dx-(1/(d^2))∫(a+b Tan[e+f x])(((c+d Tan[e+f x]))^n)((c^2) C-A (d^2)+d (2 c C-B d) Tan[e+f x])dx  ⟶  

((b C Tan[e+f x] (((c+d Tan[e+f x]))^(n+1)))/(d f (n+2)))-(1/(d(n+2)))∫(((c+d Tan[e+f x]))^n)·
(b c C-a A d (n+2)-(A b+a B-b C) d (n+2) Tan[e+f x]-(a C d (n+2)-b (c C-B d (n+2))) ((Tan[e+f x])^2))dx

Program code:

Int[(a_+b_.*tan[e_.+f_.*x_])*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  b*C*Tan[e+f*x]*(c+d*Tan[e+f*x])^(n+1)/(d*f*(n+2)) - 
  1/(d*(n+2))*Int[(c+d*Tan[e+f*x])^n*
    Simp[b*c*C-a*A*d*(n+2)-(A*b+a*B-b*C)*d*(n+2)*Tan[e+f*x]-(a*C*d*(n+2)-b*(c*C-B*d*(n+2)))*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,n},x] && NeQ[b*c-a*d,0] && NeQ[c^2+d^2,0] && Not[LtQ[n,-1]]

Int[(a_+b_.*tan[e_.+f_.*x_])*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  b*C*Tan[e+f*x]*(c+d*Tan[e+f*x])^(n+1)/(d*f*(n+2)) - 
  1/(d*(n+2))*Int[(c+d*Tan[e+f*x])^n*
    Simp[b*c*C-a*A*d*(n+2)-(A*b-b*C)*d*(n+2)*Tan[e+f*x]-(a*C*d*(n+2)-b*c*C)*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,C,n},x] && NeQ[b*c-a*d,0] && NeQ[c^2+d^2,0] && Not[LtQ[n,-1]]

3.  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)==0

1:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)==0 ∧ m<0

Derivation: Algebraic expansion, singly degenerate tangent recurrence 2b with A->1,B->0,p->0 and algebraic simplification

Basis: If  (a^2)+(b^2)==0, then A+B z+C (z^2)==((a A+b B-a C)/a)+(((a+b z) (b B-a C+b C z))/(b^2))

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)==0 ∧ m<0, then

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  

((A b-a B-b C)/b)∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)dx+(1/(b^2))∫(((a+b Tan[e+f x]))^(m+1))(((c+d Tan[e+f x]))^n)(b B-a C+b C Tan[e+f x])dx   ⟶  

(((a A+b B-a C) (((a+b Tan[e+f x]))^m) (((c+d Tan[e+f x]))^(n+1)))/(2 f m(b c-a d))) +
(1/(2 a m(b c-a d)))∫(((a+b Tan[e+f x]))^(m+1)) (((c+d Tan[e+f x]))^n)·
(b (c (A+C) m-B d (n+1))+a (B c m+C d (n+1)-A d (2 m+n+1))+(b C d (m-n-1)+A b d (m+n+1)+a (2 c C m-B d (m+n+1))) Tan[e+f x])dx

Program code:

Int[(a_+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  (a*A+b*B-a*C)*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(2*f*m*(b*c-a*d)) + 
  1/(2*a*m*(b*c-a*d))*Int[(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^n*
    Simp[b*(c*(A+C)*m-B*d*(n+1))+a*(B*c*m+C*d*(n+1)-A*d*(2*m+n+1))+
      (b*C*d*(m-n-1)+A*b*d*(m+n+1)+a*(2*c*C*m-B*d*(m+n+1)))*Tan[e+f*x],x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,n},x] && NeQ[b*c-a*d,0] && EqQ[a^2+b^2,0] && (LtQ[m,0] || EqQ[m+n+1,0])

Int[(a_+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  a*(A-C)*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(2*f*m*(b*c-a*d)) + 
  1/(2*a*m*(b*c-a*d))*Int[(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^n*
    Simp[b*c*(A+C)*m+a*(C*d*(n+1)-A*d*(2*m+n+1))+(b*C*d*(m-n-1)+A*b*d*(m+n+1)+2*a*c*C*m)*Tan[e+f*x],x],x] /;
FreeQ[{a,b,c,d,e,f,A,C,n},x] && NeQ[b*c-a*d,0] && EqQ[a^2+b^2,0] && (LtQ[m,0] || EqQ[m+n+1,0])

2.  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)==0 ∧ m≮0

1:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)==0 ∧ m≮0 ∧ n<-1 ∧ (c^2)+(d^2)≠0

Derivation: Algebraic expansion and singly degenerate tangent recurrence 1c with A->1,B->0,p->0

Basis: A+B z+C (z^2)==(((c^2) C-B c d+A (d^2))/(d^2))-(((c+d z) (c C-B d-C d z))/(d^2))

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)==0 ∧ m≮0 ∧ n<-1 ∧ (c^2)+(d^2)≠0, then

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  

(((c^2) C-B c d+A (d^2))/(d^2))∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)dx-(1/(d^2))∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^(n+1))(c C-B d-C d Tan[e+f x])dx   ⟶  

((((c^2) C-B c d+A (d^2)) (((a+b Tan[e+f x]))^m) (((c+d Tan[e+f x]))^(n+1)))/(d f (n+1)((c^2)+(d^2))))-
(1/(a d(n+1)((c^2)+(d^2))))∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^(n+1))·
(b ((c^2) C-B c d+A (d^2)) m-a d(n+1)(A c-c C+B d)-a (d (B c-A d) (m+n+1)-C ((c^2) m-(d^2) (n+1))) Tan[e+f x])dx

Program code:

Int[(a_+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  (c^2*C-B*c*d+A*d^2)*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(n+1)*(c^2+d^2)) - 
  1/(a*d*(n+1)*(c^2+d^2))*Int[(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)*
    Simp[b*(c^2*C-B*c*d+A*d^2)*m-a*d*(n+1)*(A*c-c*C+B*d)-a*(d*(B*c-A*d)*(m+n+1)-C*(c^2*m-d^2*(n+1)))*Tan[e+f*x],x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,m},x] && NeQ[b*c-a*d,0] && EqQ[a^2+b^2,0] && Not[LtQ[m,0]] && LtQ[n,-1] && NeQ[c^2+d^2,0]

Int[(a_+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  (c^2*C+A*d^2)*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(n+1)*(c^2+d^2)) - 
  1/(a*d*(n+1)*(c^2+d^2))*Int[(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)*
    Simp[b*(c^2*C+A*d^2)*m-a*d*(n+1)*(A*c-c*C)-a*(-A*d^2*(m+n+1)-C*(c^2*m-d^2*(n+1)))*Tan[e+f*x],x],x] /;
FreeQ[{a,b,c,d,e,f,A,C,m},x] && NeQ[b*c-a*d,0] && EqQ[a^2+b^2,0] && Not[LtQ[m,0]] && LtQ[n,-1] && NeQ[c^2+d^2,0]

2:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)==0 ∧ m≮0 ∧ m+n+1≠0

Derivation: Algebraic expansion and singly degenerate tangent recurrence 2c with A->c,B->d,n->n+1,p->0

Basis: A+B z+C (z^2)==((C (((c+d z))^2))/(d^2))+((A (d^2)-(c^2) C-d (2 c C-B d) z)/(d^2))

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)==0 ∧ m≮0 ∧ m+n+1≠0, then

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  

(C/(d^2))∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^(n+2))dx+(1/(d^2))∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A (d^2)-(c^2) C-d (2 c C-B d) Tan[e+f x])dx  ⟶  

((C (((a+b Tan[e+f x]))^m) (((c+d Tan[e+f x]))^(n+1)))/(d f (m+n+1)))+
(1/(b d (m+n+1)))∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A b d (m+n+1)+C (a c m-b d (n+1))-(C m(b c-a d)-b B d (m+n+1)) Tan[e+f x])dx

Program code:

Int[(a_+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  C*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(m+n+1)) + 
  1/(b*d*(m+n+1))*Int[(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^n*
    Simp[A*b*d*(m+n+1)+C*(a*c*m-b*d*(n+1))-(C*m*(b*c-a*d)-b*B*d*(m+n+1))*Tan[e+f*x],x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,m,n},x] && NeQ[b*c-a*d,0] && EqQ[a^2+b^2,0] && Not[LtQ[m,0]] && NeQ[m+n+1,0]

Int[(a_+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_.*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  C*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(m+n+1)) + 
  1/(b*d*(m+n+1))*Int[(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^n*
    Simp[A*b*d*(m+n+1)+C*(a*c*m-b*d*(n+1))-C*m*(b*c-a*d)*Tan[e+f*x],x],x] /;
FreeQ[{a,b,c,d,e,f,A,C,m,n},x] && NeQ[b*c-a*d,0] && EqQ[a^2+b^2,0] && Not[LtQ[m,0]] && NeQ[m+n+1,0]

4.  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0

1.  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ m>0

1:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ m>0 ∧ n<-1

Derivation: Nondegenerate tangent recurrence 1a with p->0

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ m>0 ∧ n<-1, then

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  
(((A (d^2)+c (c C-B d)) (((a+b Tan[e+f x]))^m) (((c+d Tan[e+f x]))^(n+1)))/(d f(n+1)((c^2)+(d^2))))-
(1/(d(n+1)((c^2)+(d^2))))∫(((a+b Tan[e+f x]))^(m-1)) (((c+d Tan[e+f x]))^(n+1))·
(A d (b d m-a c (n+1))+(c C-B d) (b c m+a d (n+1))-
d (n+1)((A-C) (b c-a d)+B (a c+b d)) Tan[e+f x]-
b (d (B c-A d) (m+n+1)-C ((c^2) m-(d^2) (n+1))) ((Tan[e+f x])^2))dx

Program code:

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  (A*d^2+c*(c*C-B*d))*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(n+1)*(c^2+d^2)) - 
  1/(d*(n+1)*(c^2+d^2))*Int[(a+b*Tan[e+f*x])^(m-1)*(c+d*Tan[e+f*x])^(n+1)*
    Simp[A*d*(b*d*m-a*c*(n+1))+(c*C-B*d)*(b*c*m+a*d*(n+1)) - 
      d*(n+1)*((A-C)*(b*c-a*d)+B*(a*c+b*d))*Tan[e+f*x] - 
      b*(d*(B*c-A*d)*(m+n+1)-C*(c^2*m-d^2*(n+1)))*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && GtQ[m,0] && LtQ[n,-1]

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  (A*d^2+c^2*C)*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(n+1)*(c^2+d^2)) - 
  1/(d*(n+1)*(c^2+d^2))*Int[(a+b*Tan[e+f*x])^(m-1)*(c+d*Tan[e+f*x])^(n+1)*
    Simp[A*d*(b*d*m-a*c*(n+1))+c*C*(b*c*m+a*d*(n+1)) - 
      d*(n+1)*((A-C)*(b*c-a*d))*Tan[e+f*x] + 
      b*(A*d^2*(m+n+1)+C*(c^2*m-d^2*(n+1)))*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,C},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && GtQ[m,0] && LtQ[n,-1]

2:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ m>0 ∧ n≮-1

Derivation: Nondegenerate tangent recurrence 1b with p->0

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ m>0 ∧ n≮-1, then

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  
((C(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^(n+1)))/(d f(m+n+1)))+
(1/(d(m+n+1)))∫(((a+b Tan[e+f x]))^(m-1)) (((c+d Tan[e+f x]))^n)·
(a A d (m+n+1)-C (b c m+a d (n+1))+d(A b+a B-b C)(m+n+1) Tan[e+f x]-(C m(b c-a d)-b B d (m+n+1)) ((Tan[e+f x])^2))dx

Program code:

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  C*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(m+n+1)) + 
  1/(d*(m+n+1))*Int[(a+b*Tan[e+f*x])^(m-1)*(c+d*Tan[e+f*x])^n*
    Simp[a*A*d*(m+n+1)-C*(b*c*m+a*d*(n+1))+d*(A*b+a*B-b*C)*(m+n+1)*Tan[e+f*x]-(C*m*(b*c-a*d)-b*B*d*(m+n+1))*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && GtQ[m,0] && 
  Not[IGtQ[n,0] && (Not[IntegerQ[m]] || EqQ[c,0] && NeQ[a,0])]

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_.*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  C*(a+b*Tan[e+f*x])^m*(c+d*Tan[e+f*x])^(n+1)/(d*f*(m+n+1)) + 
  1/(d*(m+n+1))*Int[(a+b*Tan[e+f*x])^(m-1)*(c+d*Tan[e+f*x])^n*
    Simp[a*A*d*(m+n+1)-C*(b*c*m+a*d*(n+1))+d*(A*b-b*C)*(m+n+1)*Tan[e+f*x]-C*m*(b*c-a*d)*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,C,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && GtQ[m,0] && 
  Not[IGtQ[n,0] && (Not[IntegerQ[m]] || EqQ[c,0] && NeQ[a,0])]

2:  ∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ m<-1

Derivation: Nondegenerate tangent recurrence 1c with p->0

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ m<-1, then

∫(((a+b Tan[e+f x]))^m)(((c+d Tan[e+f x]))^n)(A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  
(((A (b^2)-a (b B-a C))(((a+b Tan[e+f x]))^(m+1))(((c+d Tan[e+f x]))^(n+1)))/(f(m+1)(b c-a d)((a^2)+(b^2))))+
(1/((m+1)(b c-a d)((a^2)+(b^2))))∫(((a+b Tan[e+f x]))^(m+1)) (((c+d Tan[e+f x]))^n)·
(A (a (b c-a d) (m+1)-(b^2) d (m+n+2))+(b B-a C) (b c (m+1)+a d (n+1))-
(m+1)(b c-a d)(A b-a B-b C)Tan[e+f x]-
d(A (b^2)-a (b B-a C))(m+n+2) ((Tan[e+f x])^2))dx

Program code:

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  (A*b^2-a*(b*B-a*C))*(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^(n+1)/(f*(m+1)*(b*c-a*d)*(a^2+b^2)) + 
  1/((m+1)*(b*c-a*d)*(a^2+b^2))*Int[(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^n*
     Simp[A*(a*(b*c -a*d)*(m+1)-b^2*d*(m+n+2))+(b*B-a*C)*(b*c*(m+1)+a*d*(n+1)) - 
      (m+1)*(b*c-a*d)*(A*b-a*B-b*C)*Tan[e+f*x] - 
      d*(A*b^2-a*(b*B-a*C))*(m+n+2)*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && LtQ[m,-1] &&
  Not[ILtQ[n,-1] && (Not[IntegerQ[m]] || EqQ[c,0] && NeQ[a,0])]

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  (A*b^2+a^2*C)*(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^(n+1)/(f*(m+1)*(b*c-a*d)*(a^2+b^2)) + 
  1/((m+1)*(b*c-a*d)*(a^2+b^2))*Int[(a+b*Tan[e+f*x])^(m+1)*(c+d*Tan[e+f*x])^n*
     Simp[A*(a*(b*c -a*d)*(m+1)-b^2*d*(m+n+2))-a*C*(b*c*(m+1)+a*d*(n+1)) - 
      (m+1)*(b*c-a*d)*(A*b-b*C)*Tan[e+f*x] - 
      d*(A*b^2+a^2*C)*(m+n+2)*Tan[e+f*x]^2,x],x] /;
FreeQ[{a,b,c,d,e,f,A,C,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && LtQ[m,-1] &&
  Not[ILtQ[n,-1] && (Not[IntegerQ[m]] || EqQ[c,0] && NeQ[a,0])]

3.  ∫(((((c+d Tan[e+f x]))^n) (A+B Tan[e+f x]+C ((Tan[e+f x])^2)))/(a+b Tan[e+f x]))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ n≯0 ∧ n≮-1

1:  ∫((A+B Tan[e+f x]+C ((Tan[e+f x])^2))/((a+b Tan[e+f x])(c+d Tan[e+f x])))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0

Derivation: Algebraic expansion

Basis: ((A+B z+C (z^2))/((a+b z) (c+d z)))==((a (A c-c C+B d)+b (B c-A d+C d))/(((a^2)+(b^2)) ((c^2)+(d^2))))+(((A (b^2)-a b B+(a^2) C) (b-a z))/((b c-a d)((a^2)+(b^2))(a+b z)))-((((c^2) C-B c d+A (d^2)) (d-c z))/((b c-a d) ((c^2)+(d^2)) (c+d z)))

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0, then

∫((A+B Tan[e+f x]+C ((Tan[e+f x])^2))/((a+b Tan[e+f x])(c+d Tan[e+f x])))dx  ⟶  
(((a (A c-c C+B d)+b (B c-A d+C d))x)/(((a^2)+(b^2)) ((c^2)+(d^2))))+((A (b^2)-a b B+(a^2) C)/((b c-a d)((a^2)+(b^2))))∫((b-a Tan[e+f x])/(a+b Tan[e+f x]))dx-(((c^2) C-B c d+A (d^2))/((b c-a d) ((c^2)+(d^2))))∫((d-c Tan[e+f x])/(c+d Tan[e+f x]))dx

Program code:

Int[(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2)/((a_+b_.*tan[e_.+f_.*x_])*(c_.+d_.*tan[e_.+f_.*x_])),x_Symbol] :=
  (a*(A*c-c*C+B*d)+b*(B*c-A*d+C*d))*x/((a^2+b^2)*(c^2+d^2)) + 
  (A*b^2-a*b*B+a^2*C)/((b*c-a*d)*(a^2+b^2))*Int[(b-a*Tan[e+f*x])/(a+b*Tan[e+f*x]),x] - 
  (c^2*C-B*c*d+A*d^2)/((b*c-a*d)*(c^2+d^2))*Int[(d-c*Tan[e+f*x])/(c+d*Tan[e+f*x]),x] /;
FreeQ[{a,b,c,d,e,f,A,B,C},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0]

Int[(A_.+C_.*tan[e_.+f_.*x_]^2)/((a_+b_.*tan[e_.+f_.*x_])*(c_.+d_.*tan[e_.+f_.*x_])),x_Symbol] :=
  (a*(A*c-c*C)-b*(A*d-C*d))*x/((a^2+b^2)*(c^2+d^2)) + 
  (A*b^2+a^2*C)/((b*c-a*d)*(a^2+b^2))*Int[(b-a*Tan[e+f*x])/(a+b*Tan[e+f*x]),x] - 
  (c^2*C+A*d^2)/((b*c-a*d)*(c^2+d^2))*Int[(d-c*Tan[e+f*x])/(c+d*Tan[e+f*x]),x] /;
FreeQ[{a,b,c,d,e,f,A,C},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0]

2:  ∫(((((c+d Tan[e+f x]))^n) (A+B Tan[e+f x]+C ((Tan[e+f x])^2)))/(a+b Tan[e+f x]))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ n≯0 ∧ n≰-1

Derivation: Algebraic expansion

Basis: ((A+B z+C (z^2))/(a+b z))==((b B+a (A-C)-(A b-a B-b C) z)/((a^2)+(b^2)))+(((A (b^2)-a b B+(a^2) C) (1+(z^2)))/(((a^2)+(b^2))(a+b z)))

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0 ∧ n≯0 ∧ n≰-1, then

∫(((((c+d Tan[e+f x]))^n) (A+B Tan[e+f x]+C ((Tan[e+f x])^2)))/(a+b Tan[e+f x]))dx  ⟶  
(1/((a^2)+(b^2)))∫(((c+d Tan[e+f x]))^n)(b B+a (A-C)+(a B-b (A-C)) Tan[e+f x])dx+
((A (b^2)-a b B+(a^2) C)/((a^2)+(b^2)))∫(((((c+d Tan[e+f x]))^n)(1+((Tan[e+f x])^2)))/(a+b Tan[e+f x]))dx

Program code:

Int[(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2)/(a_.+b_.*tan[e_.+f_.*x_]),x_Symbol] :=
  1/(a^2+b^2)*Int[(c+d*Tan[e+f*x])^n*Simp[b*B+a*(A-C)+(a*B-b*(A-C))*Tan[e+f*x],x],x] + 
  (A*b^2-a*b*B+a^2*C)/(a^2+b^2)*Int[(c+d*Tan[e+f*x])^n*(1+Tan[e+f*x]^2)/(a+b*Tan[e+f*x]),x] /;
FreeQ[{a,b,c,d,e,f,A,B,C,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && Not[GtQ[n,0]] && Not[LeQ[n,-1]]

Int[(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+C_.*tan[e_.+f_.*x_]^2)/(a_.+b_.*tan[e_.+f_.*x_]),x_Symbol] :=
  1/(a^2+b^2)*Int[(c+d*Tan[e+f*x])^n*Simp[a*(A-C)-(A*b-b*C)*Tan[e+f*x],x],x] + 
  (A*b^2+a^2*C)/(a^2+b^2)*Int[(c+d*Tan[e+f*x])^n*(1+Tan[e+f*x]^2)/(a+b*Tan[e+f*x]),x] /;
FreeQ[{a,b,c,d,e,f,A,C,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0] && Not[GtQ[n,0]] && Not[LeQ[n,-1]]

4:  ∫(((a+b Tan[e+f x]))^m) (((c+d Tan[e+f x]))^n) (A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  when  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0

Derivation: Integration by substitution

Basis: F[Tan[e+f x]]==(1/f)Subst[((F[x])/(1+(x^2))),x,Tan[e+f x]](∂_x)Tan[e+f x]

Rule: If  b c-a d≠0 ∧ (a^2)+(b^2)≠0 ∧ (c^2)+(d^2)≠0, then

∫(((a+b Tan[e+f x]))^m) (((c+d Tan[e+f x]))^n) (A+B Tan[e+f x]+C ((Tan[e+f x])^2))dx  ⟶  
(1/f) Subst[∫(((((a+b x))^m) (((c+d x))^n) (A+B x+C (x^2)))/(1+(x^2)))dx,x,Tan[e+f x]]

Program code:

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+B_.*tan[e_.+f_.*x_]+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  With[{ff=FreeFactors[Tan[e+f*x],x]},
  ff/f*Subst[Int[(a+b*ff*x)^m*(c+d*ff*x)^n*(A+B*ff*x+C*ff^2*x^2)/(1+ff^2*x^2),x],x,Tan[e+f*x]/ff]] /;
FreeQ[{a,b,c,d,e,f,A,B,C,m,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0]

Int[(a_.+b_.*tan[e_.+f_.*x_])^m_*(c_.+d_.*tan[e_.+f_.*x_])^n_*(A_.+C_.*tan[e_.+f_.*x_]^2),x_Symbol] :=
  With[{ff=FreeFactors[Tan[e+f*x],x]},
  ff/f*Subst[Int[(a+b*ff*x)^m*(c+d*ff*x)^n*(A+C*ff^2*x^2)/(1+ff^2*x^2),x],x,Tan[e+f*x]/ff]] /;
FreeQ[{a,b,c,d,e,f,A,C,m,n},x] && NeQ[b*c-a*d,0] && NeQ[a^2+b^2,0] && NeQ[c^2+d^2,0]