\(\int (c (d \tan (e+f x))^p)^n (a+b \tan (e+f x))^2 \, dx\) [1341]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [F]
Fricas [F]
Sympy [F]
Maxima [F]
Giac [F]
Mupad [F(-1)]
Reduce [F]

Optimal result

Integrand size = 27, antiderivative size = 171 \[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\frac {b^2 \tan (e+f x) \left (c (d \tan (e+f x))^p\right )^n}{f (1+n p)}+\frac {\left (a^2-b^2\right ) \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2} (1+n p),\frac {1}{2} (3+n p),-\tan ^2(e+f x)\right ) \tan (e+f x) \left (c (d \tan (e+f x))^p\right )^n}{f (1+n p)}+\frac {2 a b \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2} (2+n p),\frac {1}{2} (4+n p),-\tan ^2(e+f x)\right ) \tan ^2(e+f x) \left (c (d \tan (e+f x))^p\right )^n}{f (2+n p)} \] Output:

b^2*tan(f*x+e)*(c*(d*tan(f*x+e))^p)^n/f/(n*p+1)+(a^2-b^2)*hypergeom([1, 1/ 
2*n*p+1/2],[1/2*n*p+3/2],-tan(f*x+e)^2)*tan(f*x+e)*(c*(d*tan(f*x+e))^p)^n/ 
f/(n*p+1)+2*a*b*hypergeom([1, 1/2*n*p+1],[1/2*n*p+2],-tan(f*x+e)^2)*tan(f* 
x+e)^2*(c*(d*tan(f*x+e))^p)^n/f/(n*p+2)
 

Mathematica [A] (verified)

Time = 0.42 (sec) , antiderivative size = 136, normalized size of antiderivative = 0.80 \[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\frac {\tan (e+f x) \left (c (d \tan (e+f x))^p\right )^n \left (\left (a^2-b^2\right ) (2+n p) \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2} (1+n p),\frac {1}{2} (3+n p),-\tan ^2(e+f x)\right )+b \left (b (2+n p)+2 a (1+n p) \operatorname {Hypergeometric2F1}\left (1,1+\frac {n p}{2},2+\frac {n p}{2},-\tan ^2(e+f x)\right ) \tan (e+f x)\right )\right )}{f (1+n p) (2+n p)} \] Input:

Integrate[(c*(d*Tan[e + f*x])^p)^n*(a + b*Tan[e + f*x])^2,x]
 

Output:

(Tan[e + f*x]*(c*(d*Tan[e + f*x])^p)^n*((a^2 - b^2)*(2 + n*p)*Hypergeometr 
ic2F1[1, (1 + n*p)/2, (3 + n*p)/2, -Tan[e + f*x]^2] + b*(b*(2 + n*p) + 2*a 
*(1 + n*p)*Hypergeometric2F1[1, 1 + (n*p)/2, 2 + (n*p)/2, -Tan[e + f*x]^2] 
*Tan[e + f*x])))/(f*(1 + n*p)*(2 + n*p))
 

Rubi [A] (verified)

Time = 0.39 (sec) , antiderivative size = 165, normalized size of antiderivative = 0.96, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.259, Rules used = {3042, 4853, 2042, 559, 27, 557, 278}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (a+b \tan (e+f x))^2 \left (c (d \tan (e+f x))^p\right )^n \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (e+f x))^2 \left (c (d \tan (e+f x))^p\right )^ndx\)

\(\Big \downarrow \) 4853

\(\displaystyle \frac {\int \frac {\left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2}{\tan ^2(e+f x)+1}d\tan (e+f x)}{f}\)

\(\Big \downarrow \) 2042

\(\displaystyle \frac {\tan ^{-n p}(e+f x) \left (c (d \tan (e+f x))^p\right )^n \int \frac {\tan ^{n p}(e+f x) (a+b \tan (e+f x))^2}{\tan ^2(e+f x)+1}d\tan (e+f x)}{f}\)

\(\Big \downarrow \) 559

\(\displaystyle \frac {\tan ^{-n p}(e+f x) \left (c (d \tan (e+f x))^p\right )^n \left (\frac {\int \frac {(n p+1) \tan ^{n p}(e+f x) \left (a^2+2 b \tan (e+f x) a-b^2\right )}{\tan ^2(e+f x)+1}d\tan (e+f x)}{n p+1}+\frac {b^2 \tan ^{n p+1}(e+f x)}{n p+1}\right )}{f}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {\tan ^{-n p}(e+f x) \left (c (d \tan (e+f x))^p\right )^n \left (\int \frac {\tan ^{n p}(e+f x) \left (a^2+2 b \tan (e+f x) a-b^2\right )}{\tan ^2(e+f x)+1}d\tan (e+f x)+\frac {b^2 \tan ^{n p+1}(e+f x)}{n p+1}\right )}{f}\)

\(\Big \downarrow \) 557

\(\displaystyle \frac {\tan ^{-n p}(e+f x) \left (c (d \tan (e+f x))^p\right )^n \left (\left (a^2-b^2\right ) \int \frac {\tan ^{n p}(e+f x)}{\tan ^2(e+f x)+1}d\tan (e+f x)+2 a b \int \frac {\tan ^{n p+1}(e+f x)}{\tan ^2(e+f x)+1}d\tan (e+f x)+\frac {b^2 \tan ^{n p+1}(e+f x)}{n p+1}\right )}{f}\)

\(\Big \downarrow \) 278

\(\displaystyle \frac {\tan ^{-n p}(e+f x) \left (c (d \tan (e+f x))^p\right )^n \left (\frac {\left (a^2-b^2\right ) \tan ^{n p+1}(e+f x) \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2} (n p+1),\frac {1}{2} (n p+3),-\tan ^2(e+f x)\right )}{n p+1}+\frac {2 a b \tan ^{n p+2}(e+f x) \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2} (n p+2),\frac {1}{2} (n p+4),-\tan ^2(e+f x)\right )}{n p+2}+\frac {b^2 \tan ^{n p+1}(e+f x)}{n p+1}\right )}{f}\)

Input:

Int[(c*(d*Tan[e + f*x])^p)^n*(a + b*Tan[e + f*x])^2,x]
 

Output:

((c*(d*Tan[e + f*x])^p)^n*((b^2*Tan[e + f*x]^(1 + n*p))/(1 + n*p) + ((a^2 
- b^2)*Hypergeometric2F1[1, (1 + n*p)/2, (3 + n*p)/2, -Tan[e + f*x]^2]*Tan 
[e + f*x]^(1 + n*p))/(1 + n*p) + (2*a*b*Hypergeometric2F1[1, (2 + n*p)/2, 
(4 + n*p)/2, -Tan[e + f*x]^2]*Tan[e + f*x]^(2 + n*p))/(2 + n*p)))/(f*Tan[e 
 + f*x]^(n*p))
 

Defintions of rubi rules used

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 278
Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^2)^(p_), x_Symbol] :> Simp[a^p*(( 
c*x)^(m + 1)/(c*(m + 1)))*Hypergeometric2F1[-p, (m + 1)/2, (m + 1)/2 + 1, ( 
-b)*(x^2/a)], x] /; FreeQ[{a, b, c, m, p}, x] &&  !IGtQ[p, 0] && (ILtQ[p, 0 
] || GtQ[a, 0])
 

rule 557
Int[((e_.)*(x_))^(m_)*((c_) + (d_.)*(x_))*((a_) + (b_.)*(x_)^2)^(p_), x_Sym 
bol] :> Simp[c   Int[(e*x)^m*(a + b*x^2)^p, x], x] + Simp[d/e   Int[(e*x)^( 
m + 1)*(a + b*x^2)^p, x], x] /; FreeQ[{a, b, c, d, e, m, p}, x]
 

rule 559
Int[((e_.)*(x_))^(m_)*((c_) + (d_.)*(x_))^(n_)*((a_) + (b_.)*(x_)^2)^(p_), 
x_Symbol] :> Simp[d^n*(e*x)^(m + n - 1)*((a + b*x^2)^(p + 1)/(b*e^(n - 1)*( 
m + n + 2*p + 1))), x] + Simp[1/(b*(m + n + 2*p + 1))   Int[(e*x)^m*(a + b* 
x^2)^p*ExpandToSum[b*(m + n + 2*p + 1)*(c + d*x)^n - b*d^n*(m + n + 2*p + 1 
)*x^n - a*d^n*(m + n - 1)*x^(n - 2), x], x], x] /; FreeQ[{a, b, c, d, e, m, 
 p}, x] && IGtQ[n, 1] &&  !IntegerQ[m] && NeQ[m + n + 2*p + 1, 0]
 

rule 2042
Int[(u_.)*((c_.)*((d_)*((a_.) + (b_.)*(x_)))^(q_))^(p_), x_Symbol] :> Simp[ 
(c*(d*(a + b*x))^q)^p/(a + b*x)^(p*q)   Int[u*(a + b*x)^(p*q), x], x] /; Fr 
eeQ[{a, b, c, d, q, p}, x] &&  !IntegerQ[q] &&  !IntegerQ[p]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4853
Int[u_, x_Symbol] :> With[{v = FunctionOfTrig[u, x]}, Simp[With[{d = FreeFa 
ctors[Tan[v], x]}, d/Coefficient[v, x, 1]   Subst[Int[SubstFor[1/(1 + d^2*x 
^2), Tan[v]/d, u, x], x], x, Tan[v]/d]], x] /;  !FalseQ[v] && FunctionOfQ[N 
onfreeFactors[Tan[v], x], u, x, True] && TryPureTanSubst[ActivateTrig[u], x 
]]
 
Maple [F]

\[\int \left (c \left (d \tan \left (f x +e \right )\right )^{p}\right )^{n} \left (a +b \tan \left (f x +e \right )\right )^{2}d x\]

Input:

int((c*(d*tan(f*x+e))^p)^n*(a+b*tan(f*x+e))^2,x)
 

Output:

int((c*(d*tan(f*x+e))^p)^n*(a+b*tan(f*x+e))^2,x)
 

Fricas [F]

\[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\int { {\left (b \tan \left (f x + e\right ) + a\right )}^{2} \left (\left (d \tan \left (f x + e\right )\right )^{p} c\right )^{n} \,d x } \] Input:

integrate((c*(d*tan(f*x+e))^p)^n*(a+b*tan(f*x+e))^2,x, algorithm="fricas")
 

Output:

integral((b^2*tan(f*x + e)^2 + 2*a*b*tan(f*x + e) + a^2)*((d*tan(f*x + e)) 
^p*c)^n, x)
 

Sympy [F]

\[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\int \left (c \left (d \tan {\left (e + f x \right )}\right )^{p}\right )^{n} \left (a + b \tan {\left (e + f x \right )}\right )^{2}\, dx \] Input:

integrate((c*(d*tan(f*x+e))**p)**n*(a+b*tan(f*x+e))**2,x)
 

Output:

Integral((c*(d*tan(e + f*x))**p)**n*(a + b*tan(e + f*x))**2, x)
 

Maxima [F]

\[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\int { {\left (b \tan \left (f x + e\right ) + a\right )}^{2} \left (\left (d \tan \left (f x + e\right )\right )^{p} c\right )^{n} \,d x } \] Input:

integrate((c*(d*tan(f*x+e))^p)^n*(a+b*tan(f*x+e))^2,x, algorithm="maxima")
 

Output:

integrate((b*tan(f*x + e) + a)^2*((d*tan(f*x + e))^p*c)^n, x)
 

Giac [F]

\[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\int { {\left (b \tan \left (f x + e\right ) + a\right )}^{2} \left (\left (d \tan \left (f x + e\right )\right )^{p} c\right )^{n} \,d x } \] Input:

integrate((c*(d*tan(f*x+e))^p)^n*(a+b*tan(f*x+e))^2,x, algorithm="giac")
 

Output:

integrate((b*tan(f*x + e) + a)^2*((d*tan(f*x + e))^p*c)^n, x)
 

Mupad [F(-1)]

Timed out. \[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\int {\left (c\,{\left (d\,\mathrm {tan}\left (e+f\,x\right )\right )}^p\right )}^n\,{\left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )}^2 \,d x \] Input:

int((c*(d*tan(e + f*x))^p)^n*(a + b*tan(e + f*x))^2,x)
 

Output:

int((c*(d*tan(e + f*x))^p)^n*(a + b*tan(e + f*x))^2, x)
 

Reduce [F]

\[ \int \left (c (d \tan (e+f x))^p\right )^n (a+b \tan (e+f x))^2 \, dx=\frac {d^{n p} c^{n} \left (2 \tan \left (f x +e \right )^{n p} a b +\left (\int \tan \left (f x +e \right )^{n p}d x \right ) a^{2} f n p -2 \left (\int \frac {\tan \left (f x +e \right )^{n p}}{\tan \left (f x +e \right )}d x \right ) a b f n p +\left (\int \tan \left (f x +e \right )^{n p} \tan \left (f x +e \right )^{2}d x \right ) b^{2} f n p \right )}{f n p} \] Input:

int((c*(d*tan(f*x+e))^p)^n*(a+b*tan(f*x+e))^2,x)
 

Output:

(d**(n*p)*c**n*(2*tan(e + f*x)**(n*p)*a*b + int(tan(e + f*x)**(n*p),x)*a** 
2*f*n*p - 2*int(tan(e + f*x)**(n*p)/tan(e + f*x),x)*a*b*f*n*p + int(tan(e 
+ f*x)**(n*p)*tan(e + f*x)**2,x)*b**2*f*n*p))/(f*n*p)