\(\int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx\) [947]

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

Optimal result

Integrand size = 31, antiderivative size = 19 \[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=-\frac {\log (\cos (a+b x)+\sin (a+b x))}{b} \]

[Out]

-ln(cos(b*x+a)+sin(b*x+a))/b

Rubi [A] (verified)

Time = 0.37 (sec) , antiderivative size = 19, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.065, Rules used = {815, 266} \[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=-\frac {\log (\sin (a+b x)+\cos (a+b x))}{b} \]

[In]

Int[(-Csc[a + b*x] + Sec[a + b*x])/(Csc[a + b*x] + Sec[a + b*x]),x]

[Out]

-(Log[Cos[a + b*x] + Sin[a + b*x]]/b)

Rule 266

Int[(x_)^(m_.)/((a_) + (b_.)*(x_)^(n_)), x_Symbol] :> Simp[Log[RemoveContent[a + b*x^n, x]]/(b*n), x] /; FreeQ
[{a, b, m, n}, x] && EqQ[m, n - 1]

Rule 815

Int[(((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_)))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Int[ExpandIntegrand[(
d + e*x)^m*((f + g*x)/(a + c*x^2)), x], x] /; FreeQ[{a, c, d, e, f, g}, x] && NeQ[c*d^2 + a*e^2, 0] && Integer
Q[m]

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {-1+x}{(1+x) \left (1+x^2\right )} \, dx,x,\tan (a+b x)\right )}{b} \\ & = \frac {\text {Subst}\left (\int \left (\frac {1}{-1-x}+\frac {x}{1+x^2}\right ) \, dx,x,\tan (a+b x)\right )}{b} \\ & = -\frac {\log (1+\tan (a+b x))}{b}+\frac {\text {Subst}\left (\int \frac {x}{1+x^2} \, dx,x,\tan (a+b x)\right )}{b} \\ & = -\frac {\log (\cos (a+b x))}{b}-\frac {\log (1+\tan (a+b x))}{b} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.41 (sec) , antiderivative size = 19, normalized size of antiderivative = 1.00 \[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=-\frac {\log (\cos (a+b x)+\sin (a+b x))}{b} \]

[In]

Integrate[(-Csc[a + b*x] + Sec[a + b*x])/(Csc[a + b*x] + Sec[a + b*x]),x]

[Out]

-(Log[Cos[a + b*x] + Sin[a + b*x]]/b)

Maple [A] (verified)

Time = 1.01 (sec) , antiderivative size = 30, normalized size of antiderivative = 1.58

method result size
derivativedivides \(\frac {-\ln \left (1+\tan \left (x b +a \right )\right )+\frac {\ln \left (1+\tan \left (x b +a \right )^{2}\right )}{2}}{b}\) \(30\)
default \(\frac {-\ln \left (1+\tan \left (x b +a \right )\right )+\frac {\ln \left (1+\tan \left (x b +a \right )^{2}\right )}{2}}{b}\) \(30\)
risch \(i x +\frac {2 i a}{b}-\frac {\ln \left ({\mathrm e}^{2 i \left (x b +a \right )}+i\right )}{b}\) \(31\)
parallelrisch \(\frac {\ln \left (\sec \left (\frac {a}{2}+\frac {x b}{2}\right )^{2}\right )-\ln \left (\tan \left (\frac {a}{2}+\frac {x b}{2}\right )^{2}-2 \tan \left (\frac {a}{2}+\frac {x b}{2}\right )-1\right )}{b}\) \(45\)
norman \(\frac {\ln \left (1+\tan \left (\frac {a}{2}+\frac {x b}{2}\right )^{2}\right )}{b}-\frac {\ln \left (\tan \left (\frac {a}{2}+\frac {x b}{2}\right )^{2}-2 \tan \left (\frac {a}{2}+\frac {x b}{2}\right )-1\right )}{b}\) \(50\)

[In]

int((-csc(b*x+a)+sec(b*x+a))/(csc(b*x+a)+sec(b*x+a)),x,method=_RETURNVERBOSE)

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 22, normalized size of antiderivative = 1.16 \[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=-\frac {\log \left (2 \, \cos \left (b x + a\right ) \sin \left (b x + a\right ) + 1\right )}{2 \, b} \]

[In]

integrate((-csc(b*x+a)+sec(b*x+a))/(csc(b*x+a)+sec(b*x+a)),x, algorithm="fricas")

[Out]

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

Sympy [F]

\[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=- \int \frac {\csc {\left (a + b x \right )}}{\csc {\left (a + b x \right )} + \sec {\left (a + b x \right )}}\, dx - \int \left (- \frac {\sec {\left (a + b x \right )}}{\csc {\left (a + b x \right )} + \sec {\left (a + b x \right )}}\right )\, dx \]

[In]

integrate((-csc(b*x+a)+sec(b*x+a))/(csc(b*x+a)+sec(b*x+a)),x)

[Out]

-Integral(csc(a + b*x)/(csc(a + b*x) + sec(a + b*x)), x) - Integral(-sec(a + b*x)/(csc(a + b*x) + sec(a + b*x)
), x)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 70 vs. \(2 (19) = 38\).

Time = 0.29 (sec) , antiderivative size = 70, normalized size of antiderivative = 3.68 \[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=-\frac {\log \left (-\frac {2 \, \sin \left (b x + a\right )}{\cos \left (b x + a\right ) + 1} + \frac {\sin \left (b x + a\right )^{2}}{{\left (\cos \left (b x + a\right ) + 1\right )}^{2}} - 1\right ) - \log \left (\frac {\sin \left (b x + a\right )^{2}}{{\left (\cos \left (b x + a\right ) + 1\right )}^{2}} + 1\right )}{b} \]

[In]

integrate((-csc(b*x+a)+sec(b*x+a))/(csc(b*x+a)+sec(b*x+a)),x, algorithm="maxima")

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.53 \[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=\frac {\log \left (\tan \left (b x + a\right )^{2} + 1\right ) - 2 \, \log \left ({\left | \tan \left (b x + a\right ) + 1 \right |}\right )}{2 \, b} \]

[In]

integrate((-csc(b*x+a)+sec(b*x+a))/(csc(b*x+a)+sec(b*x+a)),x, algorithm="giac")

[Out]

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

Mupad [B] (verification not implemented)

Time = 27.57 (sec) , antiderivative size = 50, normalized size of antiderivative = 2.63 \[ \int \frac {-\csc (a+b x)+\sec (a+b x)}{\csc (a+b x)+\sec (a+b x)} \, dx=-\frac {2\,\mathrm {atanh}\left (\frac {128\,\mathrm {tan}\left (\frac {a}{2}+\frac {b\,x}{2}\right )+128}{16\,{\mathrm {tan}\left (\frac {a}{2}+\frac {b\,x}{2}\right )}^2+32\,\mathrm {tan}\left (\frac {a}{2}+\frac {b\,x}{2}\right )+48}-3\right )}{b} \]

[In]

int((1/cos(a + b*x) - 1/sin(a + b*x))/(1/cos(a + b*x) + 1/sin(a + b*x)),x)

[Out]

-(2*atanh((128*tan(a/2 + (b*x)/2) + 128)/(32*tan(a/2 + (b*x)/2) + 16*tan(a/2 + (b*x)/2)^2 + 48) - 3))/b