### 3.839 $$\int \frac{\cosh ^2(x)}{a \cosh ^2(x)+b \sinh ^2(x)} \, dx$$

Optimal. Leaf size=38 $\frac{x}{a+b}+\frac{\sqrt{b} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (x)}{\sqrt{a}}\right )}{\sqrt{a} (a+b)}$

[Out]

x/(a + b) + (Sqrt[b]*ArcTan[(Sqrt[b]*Tanh[x])/Sqrt[a]])/(Sqrt[a]*(a + b))

________________________________________________________________________________________

Rubi [A]  time = 0.1121, antiderivative size = 38, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 20, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.15, Rules used = {391, 206, 205} $\frac{x}{a+b}+\frac{\sqrt{b} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (x)}{\sqrt{a}}\right )}{\sqrt{a} (a+b)}$

Antiderivative was successfully veriﬁed.

[In]

Int[Cosh[x]^2/(a*Cosh[x]^2 + b*Sinh[x]^2),x]

[Out]

x/(a + b) + (Sqrt[b]*ArcTan[(Sqrt[b]*Tanh[x])/Sqrt[a]])/(Sqrt[a]*(a + b))

Rule 391

Int[1/(((a_) + (b_.)*(x_)^(n_))*((c_) + (d_.)*(x_)^(n_))), x_Symbol] :> Dist[b/(b*c - a*d), Int[1/(a + b*x^n),
x], x] - Dist[d/(b*c - a*d), Int[1/(c + d*x^n), x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0]

Rule 206

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTanh[(Rt[-b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[-b, 2]), x]
/; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 205

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

Rubi steps

\begin{align*} \int \frac{\cosh ^2(x)}{a \cosh ^2(x)+b \sinh ^2(x)} \, dx &=\operatorname{Subst}\left (\int \frac{1}{\left (1-x^2\right ) \left (a+b x^2\right )} \, dx,x,\tanh (x)\right )\\ &=\frac{\operatorname{Subst}\left (\int \frac{1}{1-x^2} \, dx,x,\tanh (x)\right )}{a+b}+\frac{b \operatorname{Subst}\left (\int \frac{1}{a+b x^2} \, dx,x,\tanh (x)\right )}{a+b}\\ &=\frac{x}{a+b}+\frac{\sqrt{b} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (x)}{\sqrt{a}}\right )}{\sqrt{a} (a+b)}\\ \end{align*}

Mathematica [A]  time = 0.0539545, size = 33, normalized size = 0.87 $\frac{\frac{\sqrt{b} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (x)}{\sqrt{a}}\right )}{\sqrt{a}}+x}{a+b}$

Antiderivative was successfully veriﬁed.

[In]

Integrate[Cosh[x]^2/(a*Cosh[x]^2 + b*Sinh[x]^2),x]

[Out]

(x + (Sqrt[b]*ArcTan[(Sqrt[b]*Tanh[x])/Sqrt[a]])/Sqrt[a])/(a + b)

________________________________________________________________________________________

Maple [B]  time = 0.036, size = 389, normalized size = 10.2 \begin{align*} 2\,{\frac{\ln \left ( \tanh \left ( x/2 \right ) +1 \right ) }{2\,b+2\,a}}-2\,{\frac{\ln \left ( \tanh \left ( x/2 \right ) -1 \right ) }{2\,b+2\,a}}-{\frac{ab}{a+b}\arctan \left ({a\tanh \left ({\frac{x}{2}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }+a+2\,b \right ) a}}}} \right ){\frac{1}{\sqrt{b \left ( a+b \right ) }}}{\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }+a+2\,b \right ) a}}}}-{\frac{b}{a+b}\arctan \left ({a\tanh \left ({\frac{x}{2}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }+a+2\,b \right ) a}}}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }+a+2\,b \right ) a}}}}-{\frac{{b}^{2}}{a+b}\arctan \left ({a\tanh \left ({\frac{x}{2}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }+a+2\,b \right ) a}}}} \right ){\frac{1}{\sqrt{b \left ( a+b \right ) }}}{\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }+a+2\,b \right ) a}}}}-{\frac{ab}{a+b}{\it Artanh} \left ({a\tanh \left ({\frac{x}{2}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }-a-2\,b \right ) a}}}} \right ){\frac{1}{\sqrt{b \left ( a+b \right ) }}}{\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }-a-2\,b \right ) a}}}}+{\frac{b}{a+b}{\it Artanh} \left ({a\tanh \left ({\frac{x}{2}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }-a-2\,b \right ) a}}}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }-a-2\,b \right ) a}}}}-{\frac{{b}^{2}}{a+b}{\it Artanh} \left ({a\tanh \left ({\frac{x}{2}} \right ){\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }-a-2\,b \right ) a}}}} \right ){\frac{1}{\sqrt{b \left ( a+b \right ) }}}{\frac{1}{\sqrt{ \left ( 2\,\sqrt{b \left ( a+b \right ) }-a-2\,b \right ) a}}}} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

int(cosh(x)^2/(a*cosh(x)^2+b*sinh(x)^2),x)

[Out]

2/(2*b+2*a)*ln(tanh(1/2*x)+1)-2/(2*b+2*a)*ln(tanh(1/2*x)-1)-b/(a+b)*a/(b*(a+b))^(1/2)/((2*(b*(a+b))^(1/2)+a+2*
b)*a)^(1/2)*arctan(a*tanh(1/2*x)/((2*(b*(a+b))^(1/2)+a+2*b)*a)^(1/2))-b/(a+b)/((2*(b*(a+b))^(1/2)+a+2*b)*a)^(1
/2)*arctan(a*tanh(1/2*x)/((2*(b*(a+b))^(1/2)+a+2*b)*a)^(1/2))-b^2/(a+b)/(b*(a+b))^(1/2)/((2*(b*(a+b))^(1/2)+a+
2*b)*a)^(1/2)*arctan(a*tanh(1/2*x)/((2*(b*(a+b))^(1/2)+a+2*b)*a)^(1/2))-b/(a+b)*a/(b*(a+b))^(1/2)/((2*(b*(a+b)
)^(1/2)-a-2*b)*a)^(1/2)*arctanh(a*tanh(1/2*x)/((2*(b*(a+b))^(1/2)-a-2*b)*a)^(1/2))+b/(a+b)/((2*(b*(a+b))^(1/2)
-a-2*b)*a)^(1/2)*arctanh(a*tanh(1/2*x)/((2*(b*(a+b))^(1/2)-a-2*b)*a)^(1/2))-b^2/(a+b)/(b*(a+b))^(1/2)/((2*(b*(
a+b))^(1/2)-a-2*b)*a)^(1/2)*arctanh(a*tanh(1/2*x)/((2*(b*(a+b))^(1/2)-a-2*b)*a)^(1/2))

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

integrate(cosh(x)^2/(a*cosh(x)^2+b*sinh(x)^2),x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [A]  time = 1.88787, size = 1006, normalized size = 26.47 \begin{align*} \left [\frac{\sqrt{-\frac{b}{a}} \log \left (\frac{{\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (x\right )^{4} + 4 \,{\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (x\right ) \sinh \left (x\right )^{3} +{\left (a^{2} + 2 \, a b + b^{2}\right )} \sinh \left (x\right )^{4} + 2 \,{\left (a^{2} - b^{2}\right )} \cosh \left (x\right )^{2} + 2 \,{\left (3 \,{\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (x\right )^{2} + a^{2} - b^{2}\right )} \sinh \left (x\right )^{2} + a^{2} - 6 \, a b + b^{2} + 4 \,{\left ({\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (x\right )^{3} +{\left (a^{2} - b^{2}\right )} \cosh \left (x\right )\right )} \sinh \left (x\right ) + 4 \,{\left ({\left (a^{2} + a b\right )} \cosh \left (x\right )^{2} + 2 \,{\left (a^{2} + a b\right )} \cosh \left (x\right ) \sinh \left (x\right ) +{\left (a^{2} + a b\right )} \sinh \left (x\right )^{2} + a^{2} - a b\right )} \sqrt{-\frac{b}{a}}}{{\left (a + b\right )} \cosh \left (x\right )^{4} + 4 \,{\left (a + b\right )} \cosh \left (x\right ) \sinh \left (x\right )^{3} +{\left (a + b\right )} \sinh \left (x\right )^{4} + 2 \,{\left (a - b\right )} \cosh \left (x\right )^{2} + 2 \,{\left (3 \,{\left (a + b\right )} \cosh \left (x\right )^{2} + a - b\right )} \sinh \left (x\right )^{2} + 4 \,{\left ({\left (a + b\right )} \cosh \left (x\right )^{3} +{\left (a - b\right )} \cosh \left (x\right )\right )} \sinh \left (x\right ) + a + b}\right ) + 2 \, x}{2 \,{\left (a + b\right )}}, \frac{\sqrt{\frac{b}{a}} \arctan \left (\frac{{\left ({\left (a + b\right )} \cosh \left (x\right )^{2} + 2 \,{\left (a + b\right )} \cosh \left (x\right ) \sinh \left (x\right ) +{\left (a + b\right )} \sinh \left (x\right )^{2} + a - b\right )} \sqrt{\frac{b}{a}}}{2 \, b}\right ) + x}{a + b}\right ] \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

integrate(cosh(x)^2/(a*cosh(x)^2+b*sinh(x)^2),x, algorithm="fricas")

[Out]

[1/2*(sqrt(-b/a)*log(((a^2 + 2*a*b + b^2)*cosh(x)^4 + 4*(a^2 + 2*a*b + b^2)*cosh(x)*sinh(x)^3 + (a^2 + 2*a*b +
b^2)*sinh(x)^4 + 2*(a^2 - b^2)*cosh(x)^2 + 2*(3*(a^2 + 2*a*b + b^2)*cosh(x)^2 + a^2 - b^2)*sinh(x)^2 + a^2 -
6*a*b + b^2 + 4*((a^2 + 2*a*b + b^2)*cosh(x)^3 + (a^2 - b^2)*cosh(x))*sinh(x) + 4*((a^2 + a*b)*cosh(x)^2 + 2*(
a^2 + a*b)*cosh(x)*sinh(x) + (a^2 + a*b)*sinh(x)^2 + a^2 - a*b)*sqrt(-b/a))/((a + b)*cosh(x)^4 + 4*(a + b)*cos
h(x)*sinh(x)^3 + (a + b)*sinh(x)^4 + 2*(a - b)*cosh(x)^2 + 2*(3*(a + b)*cosh(x)^2 + a - b)*sinh(x)^2 + 4*((a +
b)*cosh(x)^3 + (a - b)*cosh(x))*sinh(x) + a + b)) + 2*x)/(a + b), (sqrt(b/a)*arctan(1/2*((a + b)*cosh(x)^2 +
2*(a + b)*cosh(x)*sinh(x) + (a + b)*sinh(x)^2 + a - b)*sqrt(b/a)/b) + x)/(a + b)]

________________________________________________________________________________________

Sympy [A]  time = 2.63476, size = 250, normalized size = 6.58 \begin{align*} \begin{cases} \tilde{\infty } \left (x - \frac{\cosh{\left (x \right )}}{\sinh{\left (x \right )}}\right ) & \text{for}\: a = 0 \wedge b = 0 \\\frac{x - \frac{\cosh{\left (x \right )}}{\sinh{\left (x \right )}}}{b} & \text{for}\: a = 0 \\\frac{x \sinh ^{2}{\left (x \right )}}{- 2 b \sinh ^{2}{\left (x \right )} + 2 b \cosh ^{2}{\left (x \right )}} - \frac{x \cosh ^{2}{\left (x \right )}}{- 2 b \sinh ^{2}{\left (x \right )} + 2 b \cosh ^{2}{\left (x \right )}} - \frac{\sinh{\left (x \right )} \cosh{\left (x \right )}}{- 2 b \sinh ^{2}{\left (x \right )} + 2 b \cosh ^{2}{\left (x \right )}} & \text{for}\: a = - b \\\frac{x}{a} & \text{for}\: b = 0 \\\frac{2 i \sqrt{a} x \sqrt{\frac{1}{b}}}{2 i a^{\frac{3}{2}} \sqrt{\frac{1}{b}} + 2 i \sqrt{a} b \sqrt{\frac{1}{b}}} + \frac{\log{\left (- i \sqrt{a} \sqrt{\frac{1}{b}} \cosh{\left (x \right )} + \sinh{\left (x \right )} \right )}}{2 i a^{\frac{3}{2}} \sqrt{\frac{1}{b}} + 2 i \sqrt{a} b \sqrt{\frac{1}{b}}} - \frac{\log{\left (i \sqrt{a} \sqrt{\frac{1}{b}} \cosh{\left (x \right )} + \sinh{\left (x \right )} \right )}}{2 i a^{\frac{3}{2}} \sqrt{\frac{1}{b}} + 2 i \sqrt{a} b \sqrt{\frac{1}{b}}} & \text{otherwise} \end{cases} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

integrate(cosh(x)**2/(a*cosh(x)**2+b*sinh(x)**2),x)

[Out]

Piecewise((zoo*(x - cosh(x)/sinh(x)), Eq(a, 0) & Eq(b, 0)), ((x - cosh(x)/sinh(x))/b, Eq(a, 0)), (x*sinh(x)**2
/(-2*b*sinh(x)**2 + 2*b*cosh(x)**2) - x*cosh(x)**2/(-2*b*sinh(x)**2 + 2*b*cosh(x)**2) - sinh(x)*cosh(x)/(-2*b*
sinh(x)**2 + 2*b*cosh(x)**2), Eq(a, -b)), (x/a, Eq(b, 0)), (2*I*sqrt(a)*x*sqrt(1/b)/(2*I*a**(3/2)*sqrt(1/b) +
2*I*sqrt(a)*b*sqrt(1/b)) + log(-I*sqrt(a)*sqrt(1/b)*cosh(x) + sinh(x))/(2*I*a**(3/2)*sqrt(1/b) + 2*I*sqrt(a)*b
*sqrt(1/b)) - log(I*sqrt(a)*sqrt(1/b)*cosh(x) + sinh(x))/(2*I*a**(3/2)*sqrt(1/b) + 2*I*sqrt(a)*b*sqrt(1/b)), T
rue))

________________________________________________________________________________________

Giac [A]  time = 1.1596, size = 61, normalized size = 1.61 \begin{align*} \frac{b \arctan \left (\frac{a e^{\left (2 \, x\right )} + b e^{\left (2 \, x\right )} + a - b}{2 \, \sqrt{a b}}\right )}{\sqrt{a b}{\left (a + b\right )}} + \frac{x}{a + b} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

integrate(cosh(x)^2/(a*cosh(x)^2+b*sinh(x)^2),x, algorithm="giac")

[Out]

b*arctan(1/2*(a*e^(2*x) + b*e^(2*x) + a - b)/sqrt(a*b))/(sqrt(a*b)*(a + b)) + x/(a + b)