\(\int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx\) [288]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [A] (verified)
Fricas [A] (verification not implemented)
Sympy [F]
Maxima [A] (verification not implemented)
Giac [B] (verification not implemented)
Mupad [B] (verification not implemented)
Reduce [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 86 \[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=a^2 A x+\frac {\left (4 a A b+2 a^2 B+b^2 B\right ) \text {arctanh}(\sin (c+d x))}{2 d}+\frac {b (2 A b+3 a B) \tan (c+d x)}{2 d}+\frac {b B (a+b \sec (c+d x)) \tan (c+d x)}{2 d} \] Output:

a^2*A*x+1/2*(4*A*a*b+2*B*a^2+B*b^2)*arctanh(sin(d*x+c))/d+1/2*b*(2*A*b+3*B 
*a)*tan(d*x+c)/d+1/2*b*B*(a+b*sec(d*x+c))*tan(d*x+c)/d
 

Mathematica [A] (verified)

Time = 0.16 (sec) , antiderivative size = 86, normalized size of antiderivative = 1.00 \[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {2 a^2 A d x+2 a (2 A b+a B) \coth ^{-1}(\sin (c+d x))+b^2 B \text {arctanh}(\sin (c+d x))+2 A b^2 \tan (c+d x)+4 a b B \tan (c+d x)+b^2 B \sec (c+d x) \tan (c+d x)}{2 d} \] Input:

Integrate[(a + b*Sec[c + d*x])^2*(A + B*Sec[c + d*x]),x]
 

Output:

(2*a^2*A*d*x + 2*a*(2*A*b + a*B)*ArcCoth[Sin[c + d*x]] + b^2*B*ArcTanh[Sin 
[c + d*x]] + 2*A*b^2*Tan[c + d*x] + 4*a*b*B*Tan[c + d*x] + b^2*B*Sec[c + d 
*x]*Tan[c + d*x])/(2*d)
 

Rubi [A] (verified)

Time = 0.29 (sec) , antiderivative size = 86, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.130, Rules used = {3042, 4406, 2009}

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 \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \left (a+b \csc \left (c+d x+\frac {\pi }{2}\right )\right )^2 \left (A+B \csc \left (c+d x+\frac {\pi }{2}\right )\right )dx\)

\(\Big \downarrow \) 4406

\(\displaystyle \frac {1}{2} \int \left (2 A a^2+b (2 A b+3 a B) \sec ^2(c+d x)+\left (2 B a^2+4 A b a+b^2 B\right ) \sec (c+d x)\right )dx+\frac {b B \tan (c+d x) (a+b \sec (c+d x))}{2 d}\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {1}{2} \left (\frac {\left (2 a^2 B+4 a A b+b^2 B\right ) \text {arctanh}(\sin (c+d x))}{d}+2 a^2 A x+\frac {b (3 a B+2 A b) \tan (c+d x)}{d}\right )+\frac {b B \tan (c+d x) (a+b \sec (c+d x))}{2 d}\)

Input:

Int[(a + b*Sec[c + d*x])^2*(A + B*Sec[c + d*x]),x]
 

Output:

(b*B*(a + b*Sec[c + d*x])*Tan[c + d*x])/(2*d) + (2*a^2*A*x + ((4*a*A*b + 2 
*a^2*B + b^2*B)*ArcTanh[Sin[c + d*x]])/d + (b*(2*A*b + 3*a*B)*Tan[c + d*x] 
)/d)/2
 

Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

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

rule 4406
Int[(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(m_)*(csc[(e_.) + (f_.)*(x_)]*(d 
_.) + (c_)), x_Symbol] :> Simp[(-b)*d*Cot[e + f*x]*((a + b*Csc[e + f*x])^(m 
 - 1)/(f*m)), x] + Simp[1/m   Int[(a + b*Csc[e + f*x])^(m - 2)*Simp[a^2*c*m 
 + (b^2*d*(m - 1) + 2*a*b*c*m + a^2*d*m)*Csc[e + f*x] + b*(b*c*m + a*d*(2*m 
 - 1))*Csc[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b* 
c - a*d, 0] && GtQ[m, 1] && NeQ[a^2 - b^2, 0] && IntegerQ[2*m]
 
Maple [A] (verified)

Time = 0.73 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.13

method result size
parts \(a^{2} A x +\frac {\left (A \,b^{2}+2 B a b \right ) \tan \left (d x +c \right )}{d}+\frac {\left (2 A a b +B \,a^{2}\right ) \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}+\frac {b^{2} B \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}\) \(97\)
derivativedivides \(\frac {A \,a^{2} \left (d x +c \right )+B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 A a b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 B a b \tan \left (d x +c \right )+A \,b^{2} \tan \left (d x +c \right )+b^{2} B \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}\) \(112\)
default \(\frac {A \,a^{2} \left (d x +c \right )+B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 A a b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 B a b \tan \left (d x +c \right )+A \,b^{2} \tan \left (d x +c \right )+b^{2} B \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}\) \(112\)
parallelrisch \(\frac {-2 \left (1+\cos \left (2 d x +2 c \right )\right ) \left (A a b +\frac {1}{2} B \,a^{2}+\frac {1}{4} b^{2} B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+2 \left (1+\cos \left (2 d x +2 c \right )\right ) \left (A a b +\frac {1}{2} B \,a^{2}+\frac {1}{4} b^{2} B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )+a^{2} A x d \cos \left (2 d x +2 c \right )+\left (A \,b^{2}+2 B a b \right ) \sin \left (2 d x +2 c \right )+a^{2} A x d +b^{2} B \sin \left (d x +c \right )}{d \left (1+\cos \left (2 d x +2 c \right )\right )}\) \(158\)
norman \(\frac {a^{2} A x +a^{2} A x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{4}+\frac {b \left (2 A b +4 B a +B b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}-2 a^{2} A x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-\frac {b \left (2 A b +4 B a -B b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{d}}{\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )^{2}}-\frac {\left (4 A a b +2 B \,a^{2}+b^{2} B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 d}+\frac {\left (4 A a b +2 B \,a^{2}+b^{2} B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 d}\) \(184\)
risch \(a^{2} A x -\frac {i b \left (B b \,{\mathrm e}^{3 i \left (d x +c \right )}-2 A b \,{\mathrm e}^{2 i \left (d x +c \right )}-4 B a \,{\mathrm e}^{2 i \left (d x +c \right )}-B b \,{\mathrm e}^{i \left (d x +c \right )}-2 A b -4 B a \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}-\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A a b}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B}{d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) b^{2} B}{2 d}+\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A a b}{d}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B}{d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) b^{2} B}{2 d}\) \(217\)

Input:

int((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)),x,method=_RETURNVERBOSE)
 

Output:

a^2*A*x+(A*b^2+2*B*a*b)/d*tan(d*x+c)+(2*A*a*b+B*a^2)/d*ln(sec(d*x+c)+tan(d 
*x+c))+b^2*B/d*(1/2*sec(d*x+c)*tan(d*x+c)+1/2*ln(sec(d*x+c)+tan(d*x+c)))
 

Fricas [A] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 136, normalized size of antiderivative = 1.58 \[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {4 \, A a^{2} d x \cos \left (d x + c\right )^{2} + {\left (2 \, B a^{2} + 4 \, A a b + B b^{2}\right )} \cos \left (d x + c\right )^{2} \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (2 \, B a^{2} + 4 \, A a b + B b^{2}\right )} \cos \left (d x + c\right )^{2} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (B b^{2} + 2 \, {\left (2 \, B a b + A b^{2}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{4 \, d \cos \left (d x + c\right )^{2}} \] Input:

integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)),x, algorithm="fricas")
 

Output:

1/4*(4*A*a^2*d*x*cos(d*x + c)^2 + (2*B*a^2 + 4*A*a*b + B*b^2)*cos(d*x + c) 
^2*log(sin(d*x + c) + 1) - (2*B*a^2 + 4*A*a*b + B*b^2)*cos(d*x + c)^2*log( 
-sin(d*x + c) + 1) + 2*(B*b^2 + 2*(2*B*a*b + A*b^2)*cos(d*x + c))*sin(d*x 
+ c))/(d*cos(d*x + c)^2)
 

Sympy [F]

\[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\int \left (A + B \sec {\left (c + d x \right )}\right ) \left (a + b \sec {\left (c + d x \right )}\right )^{2}\, dx \] Input:

integrate((a+b*sec(d*x+c))**2*(A+B*sec(d*x+c)),x)
 

Output:

Integral((A + B*sec(c + d*x))*(a + b*sec(c + d*x))**2, x)
 

Maxima [A] (verification not implemented)

Time = 0.04 (sec) , antiderivative size = 126, normalized size of antiderivative = 1.47 \[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {4 \, {\left (d x + c\right )} A a^{2} - B b^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 4 \, B a^{2} \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + 8 \, A a b \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + 8 \, B a b \tan \left (d x + c\right ) + 4 \, A b^{2} \tan \left (d x + c\right )}{4 \, d} \] Input:

integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)),x, algorithm="maxima")
 

Output:

1/4*(4*(d*x + c)*A*a^2 - B*b^2*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) - log( 
sin(d*x + c) + 1) + log(sin(d*x + c) - 1)) + 4*B*a^2*log(sec(d*x + c) + ta 
n(d*x + c)) + 8*A*a*b*log(sec(d*x + c) + tan(d*x + c)) + 8*B*a*b*tan(d*x + 
 c) + 4*A*b^2*tan(d*x + c))/d
 

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 192 vs. \(2 (80) = 160\).

Time = 0.15 (sec) , antiderivative size = 192, normalized size of antiderivative = 2.23 \[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {2 \, {\left (d x + c\right )} A a^{2} + {\left (2 \, B a^{2} + 4 \, A a b + B b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - {\left (2 \, B a^{2} + 4 \, A a b + B b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - \frac {2 \, {\left (4 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 2 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 4 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 2 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{2}}}{2 \, d} \] Input:

integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)),x, algorithm="giac")
 

Output:

1/2*(2*(d*x + c)*A*a^2 + (2*B*a^2 + 4*A*a*b + B*b^2)*log(abs(tan(1/2*d*x + 
 1/2*c) + 1)) - (2*B*a^2 + 4*A*a*b + B*b^2)*log(abs(tan(1/2*d*x + 1/2*c) - 
 1)) - 2*(4*B*a*b*tan(1/2*d*x + 1/2*c)^3 + 2*A*b^2*tan(1/2*d*x + 1/2*c)^3 
- B*b^2*tan(1/2*d*x + 1/2*c)^3 - 4*B*a*b*tan(1/2*d*x + 1/2*c) - 2*A*b^2*ta 
n(1/2*d*x + 1/2*c) - B*b^2*tan(1/2*d*x + 1/2*c))/(tan(1/2*d*x + 1/2*c)^2 - 
 1)^2)/d
 

Mupad [B] (verification not implemented)

Time = 11.75 (sec) , antiderivative size = 176, normalized size of antiderivative = 2.05 \[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {2\,\left (A\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )+B\,a^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )+\frac {B\,b^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+2\,A\,a\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\right )}{d}+\frac {\frac {A\,b^2\,\sin \left (2\,c+2\,d\,x\right )}{2}+\frac {B\,b^2\,\sin \left (c+d\,x\right )}{2}+B\,a\,b\,\sin \left (2\,c+2\,d\,x\right )}{d\,\left (\frac {\cos \left (2\,c+2\,d\,x\right )}{2}+\frac {1}{2}\right )} \] Input:

int((A + B/cos(c + d*x))*(a + b/cos(c + d*x))^2,x)
 

Output:

(2*(A*a^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)) + B*a^2*atanh(sin(c/ 
2 + (d*x)/2)/cos(c/2 + (d*x)/2)) + (B*b^2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 
 + (d*x)/2)))/2 + 2*A*a*b*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2))))/d 
 + ((A*b^2*sin(2*c + 2*d*x))/2 + (B*b^2*sin(c + d*x))/2 + B*a*b*sin(2*c + 
2*d*x))/(d*(cos(2*c + 2*d*x)/2 + 1/2))
 

Reduce [B] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 239, normalized size of antiderivative = 2.78 \[ \int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {-6 \cos \left (d x +c \right ) \sin \left (d x +c \right ) a \,b^{2}-6 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) \sin \left (d x +c \right )^{2} a^{2} b -\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) \sin \left (d x +c \right )^{2} b^{3}+6 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) a^{2} b +\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) b^{3}+6 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) \sin \left (d x +c \right )^{2} a^{2} b +\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) \sin \left (d x +c \right )^{2} b^{3}-6 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) a^{2} b -\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) b^{3}+2 \sin \left (d x +c \right )^{2} a^{3} d x -\sin \left (d x +c \right ) b^{3}-2 a^{3} d x}{2 d \left (\sin \left (d x +c \right )^{2}-1\right )} \] Input:

int((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)),x)
 

Output:

( - 6*cos(c + d*x)*sin(c + d*x)*a*b**2 - 6*log(tan((c + d*x)/2) - 1)*sin(c 
 + d*x)**2*a**2*b - log(tan((c + d*x)/2) - 1)*sin(c + d*x)**2*b**3 + 6*log 
(tan((c + d*x)/2) - 1)*a**2*b + log(tan((c + d*x)/2) - 1)*b**3 + 6*log(tan 
((c + d*x)/2) + 1)*sin(c + d*x)**2*a**2*b + log(tan((c + d*x)/2) + 1)*sin( 
c + d*x)**2*b**3 - 6*log(tan((c + d*x)/2) + 1)*a**2*b - log(tan((c + d*x)/ 
2) + 1)*b**3 + 2*sin(c + d*x)**2*a**3*d*x - sin(c + d*x)*b**3 - 2*a**3*d*x 
)/(2*d*(sin(c + d*x)**2 - 1))