\(\int \frac {(B \cos (c+d x)+C \cos ^2(c+d x)) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx\) [798]

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

Optimal result

Integrand size = 40, antiderivative size = 76 \[ \int \frac {\left (B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx=-\frac {2 (b B-a C) \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a \sqrt {a-b} \sqrt {a+b} d}+\frac {B \text {arctanh}(\sin (c+d x))}{a d} \] Output:

-2*(B*b-C*a)*arctan((a-b)^(1/2)*tan(1/2*d*x+1/2*c)/(a+b)^(1/2))/a/(a-b)^(1 
/2)/(a+b)^(1/2)/d+B*arctanh(sin(d*x+c))/a/d
 

Mathematica [A] (verified)

Time = 0.53 (sec) , antiderivative size = 112, normalized size of antiderivative = 1.47 \[ \int \frac {\left (B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx=\frac {\frac {2 (b B-a C) \text {arctanh}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}+B \left (-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+\log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )}{a d} \] Input:

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

Output:

((2*(b*B - a*C)*ArcTanh[((a - b)*Tan[(c + d*x)/2])/Sqrt[-a^2 + b^2]])/Sqrt 
[-a^2 + b^2] + B*(-Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + Log[Cos[(c + 
 d*x)/2] + Sin[(c + d*x)/2]]))/(a*d)
 

Rubi [A] (verified)

Time = 0.52 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {3042, 3508, 3042, 3480, 3042, 3138, 218, 4257}

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 \frac {\sec ^2(c+d x) \left (B \cos (c+d x)+C \cos ^2(c+d x)\right )}{a+b \cos (c+d x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3508

\(\displaystyle \int \frac {\sec (c+d x) (B+C \cos (c+d x))}{a+b \cos (c+d x)}dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3480

\(\displaystyle \frac {B \int \sec (c+d x)dx}{a}-\frac {(b B-a C) \int \frac {1}{a+b \cos (c+d x)}dx}{a}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {B \int \csc \left (c+d x+\frac {\pi }{2}\right )dx}{a}-\frac {(b B-a C) \int \frac {1}{a+b \sin \left (c+d x+\frac {\pi }{2}\right )}dx}{a}\)

\(\Big \downarrow \) 3138

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

\(\Big \downarrow \) 218

\(\displaystyle \frac {B \int \csc \left (c+d x+\frac {\pi }{2}\right )dx}{a}-\frac {2 (b B-a C) \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a d \sqrt {a-b} \sqrt {a+b}}\)

\(\Big \downarrow \) 4257

\(\displaystyle \frac {B \text {arctanh}(\sin (c+d x))}{a d}-\frac {2 (b B-a C) \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a d \sqrt {a-b} \sqrt {a+b}}\)

Input:

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

Output:

(-2*(b*B - a*C)*ArcTan[(Sqrt[a - b]*Tan[(c + d*x)/2])/Sqrt[a + b]])/(a*Sqr 
t[a - b]*Sqrt[a + b]*d) + (B*ArcTanh[Sin[c + d*x]])/(a*d)
 

Defintions of rubi rules used

rule 218
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/R 
t[a/b, 2]], x] /; FreeQ[{a, b}, x] && PosQ[a/b]
 

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

rule 3138
Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{ 
e = FreeFactors[Tan[(c + d*x)/2], x]}, Simp[2*(e/d)   Subst[Int[1/(a + b + 
(a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] 
 && NeQ[a^2 - b^2, 0]
 

rule 3480
Int[((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)])/(((a_.) + (b_.)*sin[(e_.) + (f_ 
.)*(x_)])*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])), x_Symbol] :> Simp[(A*b 
- a*B)/(b*c - a*d)   Int[1/(a + b*Sin[e + f*x]), x], x] + Simp[(B*c - A*d)/ 
(b*c - a*d)   Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f 
, A, B}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0]
 

rule 3508
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*sin[(e_.) 
+ (f_.)*(x_)])^(n_.)*((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)] + (C_.)*sin[(e_ 
.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[1/b^2   Int[(a + b*Sin[e + f*x])^(m 
+ 1)*(c + d*Sin[e + f*x])^n*(b*B - a*C + b*C*Sin[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*b^2 - 
a*b*B + a^2*C, 0]
 

rule 4257
Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] 
 /; FreeQ[{c, d}, x]
 
Maple [A] (verified)

Time = 0.40 (sec) , antiderivative size = 92, normalized size of antiderivative = 1.21

method result size
derivativedivides \(\frac {-\frac {B \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{a}+\frac {2 \left (-B b +C a \right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {B \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a}}{d}\) \(92\)
default \(\frac {-\frac {B \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{a}+\frac {2 \left (-B b +C a \right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {B \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a}}{d}\) \(92\)
risch \(-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-\sqrt {-a^{2}+b^{2}}\, a}{b \sqrt {-a^{2}+b^{2}}}\right ) B b}{\sqrt {-a^{2}+b^{2}}\, d a}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-\sqrt {-a^{2}+b^{2}}\, a}{b \sqrt {-a^{2}+b^{2}}}\right ) C}{\sqrt {-a^{2}+b^{2}}\, d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {-a^{2}+b^{2}}\, a}{b \sqrt {-a^{2}+b^{2}}}\right ) B b}{\sqrt {-a^{2}+b^{2}}\, d a}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {-a^{2}+b^{2}}\, a}{b \sqrt {-a^{2}+b^{2}}}\right ) C}{\sqrt {-a^{2}+b^{2}}\, d}-\frac {B \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{a d}+\frac {B \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{a d}\) \(331\)

Input:

int((B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)^2/(a+b*cos(d*x+c)),x,method=_ 
RETURNVERBOSE)
 

Output:

1/d*(-B/a*ln(tan(1/2*d*x+1/2*c)-1)+2/a*(-B*b+C*a)/((a-b)*(a+b))^(1/2)*arct 
an((a-b)*tan(1/2*d*x+1/2*c)/((a-b)*(a+b))^(1/2))+B/a*ln(tan(1/2*d*x+1/2*c) 
+1))
 

Fricas [A] (verification not implemented)

Time = 0.44 (sec) , antiderivative size = 304, normalized size of antiderivative = 4.00 \[ \int \frac {\left (B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx=\left [\frac {{\left (C a - B b\right )} \sqrt {-a^{2} + b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right ) + {\left (B a^{2} - B b^{2}\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (B a^{2} - B b^{2}\right )} \log \left (-\sin \left (d x + c\right ) + 1\right )}{2 \, {\left (a^{3} - a b^{2}\right )} d}, \frac {2 \, {\left (C a - B b\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right ) + {\left (B a^{2} - B b^{2}\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (B a^{2} - B b^{2}\right )} \log \left (-\sin \left (d x + c\right ) + 1\right )}{2 \, {\left (a^{3} - a b^{2}\right )} d}\right ] \] Input:

integrate((B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)^2/(a+b*cos(d*x+c)),x, a 
lgorithm="fricas")
 

Output:

[1/2*((C*a - B*b)*sqrt(-a^2 + b^2)*log((2*a*b*cos(d*x + c) + (2*a^2 - b^2) 
*cos(d*x + c)^2 - 2*sqrt(-a^2 + b^2)*(a*cos(d*x + c) + b)*sin(d*x + c) - a 
^2 + 2*b^2)/(b^2*cos(d*x + c)^2 + 2*a*b*cos(d*x + c) + a^2)) + (B*a^2 - B* 
b^2)*log(sin(d*x + c) + 1) - (B*a^2 - B*b^2)*log(-sin(d*x + c) + 1))/((a^3 
 - a*b^2)*d), 1/2*(2*(C*a - B*b)*sqrt(a^2 - b^2)*arctan(-(a*cos(d*x + c) + 
 b)/(sqrt(a^2 - b^2)*sin(d*x + c))) + (B*a^2 - B*b^2)*log(sin(d*x + c) + 1 
) - (B*a^2 - B*b^2)*log(-sin(d*x + c) + 1))/((a^3 - a*b^2)*d)]
 

Sympy [F]

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

integrate((B*cos(d*x+c)+C*cos(d*x+c)**2)*sec(d*x+c)**2/(a+b*cos(d*x+c)),x)
 

Output:

Integral((B + C*cos(c + d*x))*cos(c + d*x)*sec(c + d*x)**2/(a + b*cos(c + 
d*x)), x)
 

Maxima [F(-2)]

Exception generated. \[ \int \frac {\left (B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx=\text {Exception raised: ValueError} \] Input:

integrate((B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)^2/(a+b*cos(d*x+c)),x, a 
lgorithm="maxima")
 

Output:

Exception raised: ValueError >> Computation failed since Maxima requested 
additional constraints; using the 'assume' command before evaluation *may* 
 help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?` f 
or more de
 

Giac [A] (verification not implemented)

Time = 0.15 (sec) , antiderivative size = 128, normalized size of antiderivative = 1.68 \[ \int \frac {\left (B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx=\frac {\frac {B \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{a} - \frac {B \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{a} - \frac {2 \, {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )} {\left (C a - B b\right )}}{\sqrt {a^{2} - b^{2}} a}}{d} \] Input:

integrate((B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)^2/(a+b*cos(d*x+c)),x, a 
lgorithm="giac")
 

Output:

(B*log(abs(tan(1/2*d*x + 1/2*c) + 1))/a - B*log(abs(tan(1/2*d*x + 1/2*c) - 
 1))/a - 2*(pi*floor(1/2*(d*x + c)/pi + 1/2)*sgn(-2*a + 2*b) + arctan(-(a* 
tan(1/2*d*x + 1/2*c) - b*tan(1/2*d*x + 1/2*c))/sqrt(a^2 - b^2)))*(C*a - B* 
b)/(sqrt(a^2 - b^2)*a))/d
 

Mupad [B] (verification not implemented)

Time = 1.30 (sec) , antiderivative size = 342, normalized size of antiderivative = 4.50 \[ \int \frac {\left (B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx=\frac {2\,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 )}{a\,d}+\frac {b\,\left (B\,\ln \left (\frac {a\,\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )+b\,\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {-\left (a+b\right )\,\left (a-b\right )}-B\,\ln \left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {b^2-a^2}\right )-C\,a\,\ln \left (\frac {a\,\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )+b\,\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {-\left (a+b\right )\,\left (a-b\right )}+C\,a\,\ln \left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {b^2-a^2}}{a\,d\,\left (a^2-b^2\right )} \] Input:

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

Output:

(2*B*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/(a*d) + (b*(B*log((a*co 
s(c/2 + (d*x)/2) + b*cos(c/2 + (d*x)/2) + sin(c/2 + (d*x)/2)*(b^2 - a^2)^( 
1/2))/cos(c/2 + (d*x)/2))*(-(a + b)*(a - b))^(1/2) - B*log((a*sin(c/2 + (d 
*x)/2) - b*sin(c/2 + (d*x)/2) + cos(c/2 + (d*x)/2)*(b^2 - a^2)^(1/2))/cos( 
c/2 + (d*x)/2))*(b^2 - a^2)^(1/2)) - C*a*log((a*cos(c/2 + (d*x)/2) + b*cos 
(c/2 + (d*x)/2) + sin(c/2 + (d*x)/2)*(b^2 - a^2)^(1/2))/cos(c/2 + (d*x)/2) 
)*(-(a + b)*(a - b))^(1/2) + C*a*log((a*sin(c/2 + (d*x)/2) - b*sin(c/2 + ( 
d*x)/2) + cos(c/2 + (d*x)/2)*(b^2 - a^2)^(1/2))/cos(c/2 + (d*x)/2))*(b^2 - 
 a^2)^(1/2))/(a*d*(a^2 - b^2))
                                                                                    
                                                                                    
 

Reduce [B] (verification not implemented)

Time = 0.17 (sec) , antiderivative size = 192, normalized size of antiderivative = 2.53 \[ \int \frac {\left (B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx=\frac {2 \sqrt {a^{2}-b^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) a -\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) b}{\sqrt {a^{2}-b^{2}}}\right ) a c -2 \sqrt {a^{2}-b^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) a -\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) b}{\sqrt {a^{2}-b^{2}}}\right ) b^{2}-\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}+\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}}{a d \left (a^{2}-b^{2}\right )} \] Input:

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

Output:

(2*sqrt(a**2 - b**2)*atan((tan((c + d*x)/2)*a - tan((c + d*x)/2)*b)/sqrt(a 
**2 - b**2))*a*c - 2*sqrt(a**2 - b**2)*atan((tan((c + d*x)/2)*a - tan((c + 
 d*x)/2)*b)/sqrt(a**2 - b**2))*b**2 - log(tan((c + d*x)/2) - 1)*a**2*b + l 
og(tan((c + d*x)/2) - 1)*b**3 + log(tan((c + d*x)/2) + 1)*a**2*b - log(tan 
((c + d*x)/2) + 1)*b**3)/(a*d*(a**2 - b**2))