\(\int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx\) [585]

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

Optimal result

Integrand size = 11, antiderivative size = 38 \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\frac {\arctan \left (\frac {b \cosh (x)+a \sinh (x)}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}} \]

[Out]

arctan((b*cosh(x)+a*sinh(x))/(a^2-b^2)^(1/2))/(a^2-b^2)^(1/2)

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 38, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.182, Rules used = {3153, 212} \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\frac {\arctan \left (\frac {a \sinh (x)+b \cosh (x)}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}} \]

[In]

Int[(a*Cosh[x] + b*Sinh[x])^(-1),x]

[Out]

ArcTan[(b*Cosh[x] + a*Sinh[x])/Sqrt[a^2 - b^2]]/Sqrt[a^2 - b^2]

Rule 212

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

Rule 3153

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

Rubi steps \begin{align*} \text {integral}& = i \text {Subst}\left (\int \frac {1}{a^2-b^2-x^2} \, dx,x,-i b \cosh (x)-i a \sinh (x)\right ) \\ & = \frac {\arctan \left (\frac {b \cosh (x)+a \sinh (x)}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.21 \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\frac {2 \arctan \left (\frac {b+a \tanh \left (\frac {x}{2}\right )}{\sqrt {a-b} \sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}} \]

[In]

Integrate[(a*Cosh[x] + b*Sinh[x])^(-1),x]

[Out]

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

Maple [A] (verified)

Time = 0.66 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.03

method result size
default \(\frac {2 \arctan \left (\frac {2 a \tanh \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{\sqrt {a^{2}-b^{2}}}\) \(39\)
risch \(-\frac {\ln \left ({\mathrm e}^{x}-\frac {a -b}{\sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}}+\frac {\ln \left ({\mathrm e}^{x}+\frac {a -b}{\sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}}\) \(70\)

[In]

int(1/(a*cosh(x)+b*sinh(x)),x,method=_RETURNVERBOSE)

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 148, normalized size of antiderivative = 3.89 \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\left [-\frac {\sqrt {-a^{2} + b^{2}} \log \left (\frac {{\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} - 2 \, \sqrt {-a^{2} + b^{2}} {\left (\cosh \left (x\right ) + \sinh \left (x\right )\right )} - a + b}{{\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 )}{a^{2} - b^{2}}, -\frac {2 \, \arctan \left (\frac {\sqrt {a^{2} - b^{2}}}{{\left (a + b\right )} \cosh \left (x\right ) + {\left (a + b\right )} \sinh \left (x\right )}\right )}{\sqrt {a^{2} - b^{2}}}\right ] \]

[In]

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

[Out]

[-sqrt(-a^2 + b^2)*log(((a + b)*cosh(x)^2 + 2*(a + b)*cosh(x)*sinh(x) + (a + b)*sinh(x)^2 - 2*sqrt(-a^2 + b^2)
*(cosh(x) + sinh(x)) - a + b)/((a + b)*cosh(x)^2 + 2*(a + b)*cosh(x)*sinh(x) + (a + b)*sinh(x)^2 + a - b))/(a^
2 - b^2), -2*arctan(sqrt(a^2 - b^2)/((a + b)*cosh(x) + (a + b)*sinh(x)))/sqrt(a^2 - b^2)]

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 105 vs. \(2 (31) = 62\).

Time = 2.11 (sec) , antiderivative size = 105, normalized size of antiderivative = 2.76 \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\begin {cases} \tilde {\infty } \log {\left (\tanh {\left (\frac {x}{2} \right )} \right )} & \text {for}\: a = 0 \wedge b = 0 \\\frac {\log {\left (\tanh {\left (\frac {x}{2} \right )} \right )}}{b} & \text {for}\: a = 0 \\- \frac {1}{- b \sinh {\left (x \right )} + b \cosh {\left (x \right )}} & \text {for}\: a = - b \\- \frac {1}{b \sinh {\left (x \right )} + b \cosh {\left (x \right )}} & \text {for}\: a = b \\\frac {\log {\left (\tanh {\left (\frac {x}{2} \right )} + \frac {b}{a} - \frac {\sqrt {- a^{2} + b^{2}}}{a} \right )}}{\sqrt {- a^{2} + b^{2}}} - \frac {\log {\left (\tanh {\left (\frac {x}{2} \right )} + \frac {b}{a} + \frac {\sqrt {- a^{2} + b^{2}}}{a} \right )}}{\sqrt {- a^{2} + b^{2}}} & \text {otherwise} \end {cases} \]

[In]

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

[Out]

Piecewise((zoo*log(tanh(x/2)), Eq(a, 0) & Eq(b, 0)), (log(tanh(x/2))/b, Eq(a, 0)), (-1/(-b*sinh(x) + b*cosh(x)
), Eq(a, -b)), (-1/(b*sinh(x) + b*cosh(x)), Eq(a, b)), (log(tanh(x/2) + b/a - sqrt(-a**2 + b**2)/a)/sqrt(-a**2
 + b**2) - log(tanh(x/2) + b/a + sqrt(-a**2 + b**2)/a)/sqrt(-a**2 + b**2), True))

Maxima [F(-2)]

Exception generated. \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\text {Exception raised: ValueError} \]

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 35, normalized size of antiderivative = 0.92 \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\frac {2 \, \arctan \left (\frac {a e^{x} + b e^{x}}{\sqrt {a^{2} - b^{2}}}\right )}{\sqrt {a^{2} - b^{2}}} \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 35, normalized size of antiderivative = 0.92 \[ \int \frac {1}{a \cosh (x)+b \sinh (x)} \, dx=\frac {2\,\mathrm {atan}\left (\frac {{\mathrm {e}}^x\,\sqrt {a^2-b^2}}{a-b}\right )}{\sqrt {a^2-b^2}} \]

[In]

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

[Out]

(2*atan((exp(x)*(a^2 - b^2)^(1/2))/(a - b)))/(a^2 - b^2)^(1/2)