3.266 \(\int (a \sec (x)+b \tan (x))^2 \, dx\)

Optimal. Leaf size=27 \[ a b \cos (x)+\sec (x) (a \sin (x)+b) (a+b \sin (x))+b^2 (-x) \]

[Out]

-(b^2*x) + a*b*Cos[x] + Sec[x]*(b + a*Sin[x])*(a + b*Sin[x])

________________________________________________________________________________________

Rubi [A]  time = 0.0538816, antiderivative size = 27, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 11, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.273, Rules used = {4391, 2691, 2638} \[ a b \cos (x)+\sec (x) (a \sin (x)+b) (a+b \sin (x))+b^2 (-x) \]

Antiderivative was successfully verified.

[In]

Int[(a*Sec[x] + b*Tan[x])^2,x]

[Out]

-(b^2*x) + a*b*Cos[x] + Sec[x]*(b + a*Sin[x])*(a + b*Sin[x])

Rule 4391

Int[(u_.)*((b_.)*sec[(c_.) + (d_.)*(x_)]^(n_.) + (a_.)*tan[(c_.) + (d_.)*(x_)]^(n_.))^(p_), x_Symbol] :> Int[A
ctivateTrig[u]*Sec[c + d*x]^(n*p)*(b + a*Sin[c + d*x]^n)^p, x] /; FreeQ[{a, b, c, d}, x] && IntegersQ[n, p]

Rule 2691

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> -Simp[((g*C
os[e + f*x])^(p + 1)*(a + b*Sin[e + f*x])^(m - 1)*(b + a*Sin[e + f*x]))/(f*g*(p + 1)), x] + Dist[1/(g^2*(p + 1
)), Int[(g*Cos[e + f*x])^(p + 2)*(a + b*Sin[e + f*x])^(m - 2)*(b^2*(m - 1) + a^2*(p + 2) + a*b*(m + p + 1)*Sin
[e + f*x]), x], x] /; FreeQ[{a, b, e, f, g}, x] && NeQ[a^2 - b^2, 0] && GtQ[m, 1] && LtQ[p, -1] && (IntegersQ[
2*m, 2*p] || IntegerQ[m])

Rule 2638

Int[sin[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Cos[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a \sec (x)+b \tan (x))^2 \, dx &=\int \sec ^2(x) (a+b \sin (x))^2 \, dx\\ &=\sec (x) (b+a \sin (x)) (a+b \sin (x))-\int \left (b^2+a b \sin (x)\right ) \, dx\\ &=-b^2 x+\sec (x) (b+a \sin (x)) (a+b \sin (x))-(a b) \int \sin (x) \, dx\\ &=-b^2 x+a b \cos (x)+\sec (x) (b+a \sin (x)) (a+b \sin (x))\\ \end{align*}

Mathematica [A]  time = 0.0425597, size = 25, normalized size = 0.93 \[ \left (a^2+b^2\right ) \tan (x)+2 a b \sec (x)+b^2 \left (-\tan ^{-1}(\tan (x))\right ) \]

Antiderivative was successfully verified.

[In]

Integrate[(a*Sec[x] + b*Tan[x])^2,x]

[Out]

-(b^2*ArcTan[Tan[x]]) + 2*a*b*Sec[x] + (a^2 + b^2)*Tan[x]

________________________________________________________________________________________

Maple [A]  time = 0.044, size = 26, normalized size = 1. \begin{align*}{a}^{2}\tan \left ( x \right ) +2\,{\frac{ab}{\cos \left ( x \right ) }}+{b}^{2} \left ( \tan \left ( x \right ) -x \right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a*sec(x)+b*tan(x))^2,x)

[Out]

a^2*tan(x)+2*a*b/cos(x)+b^2*(tan(x)-x)

________________________________________________________________________________________

Maxima [A]  time = 1.56571, size = 35, normalized size = 1.3 \begin{align*} -b^{2}{\left (x - \tan \left (x\right )\right )} + a^{2} \tan \left (x\right ) + \frac{2 \, a b}{\cos \left (x\right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*sec(x)+b*tan(x))^2,x, algorithm="maxima")

[Out]

-b^2*(x - tan(x)) + a^2*tan(x) + 2*a*b/cos(x)

________________________________________________________________________________________

Fricas [A]  time = 2.08211, size = 72, normalized size = 2.67 \begin{align*} -\frac{b^{2} x \cos \left (x\right ) - 2 \, a b -{\left (a^{2} + b^{2}\right )} \sin \left (x\right )}{\cos \left (x\right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*sec(x)+b*tan(x))^2,x, algorithm="fricas")

[Out]

-(b^2*x*cos(x) - 2*a*b - (a^2 + b^2)*sin(x))/cos(x)

________________________________________________________________________________________

Sympy [A]  time = 1.48019, size = 22, normalized size = 0.81 \begin{align*} a^{2} \tan{\left (x \right )} + 2 a b \sec{\left (x \right )} + b^{2} \left (- x + \tan{\left (x \right )}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*sec(x)+b*tan(x))**2,x)

[Out]

a**2*tan(x) + 2*a*b*sec(x) + b**2*(-x + tan(x))

________________________________________________________________________________________

Giac [A]  time = 1.14645, size = 54, normalized size = 2. \begin{align*} -b^{2} x - \frac{2 \,{\left (a^{2} \tan \left (\frac{1}{2} \, x\right ) + b^{2} \tan \left (\frac{1}{2} \, x\right ) + 2 \, a b\right )}}{\tan \left (\frac{1}{2} \, x\right )^{2} - 1} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*sec(x)+b*tan(x))^2,x, algorithm="giac")

[Out]

-b^2*x - 2*(a^2*tan(1/2*x) + b^2*tan(1/2*x) + 2*a*b)/(tan(1/2*x)^2 - 1)