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

Optimal. Leaf size=39 \[ \frac {a x}{a^2-b^2}-\frac {b \log (a \cosh (x)+b \sinh (x))}{a^2-b^2} \]

[Out]

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

________________________________________________________________________________________

Rubi [A]
time = 0.03, antiderivative size = 39, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3565, 3611} \begin {gather*} \frac {a x}{a^2-b^2}-\frac {b \log (a \cosh (x)+b \sinh (x))}{a^2-b^2} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 3565

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

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rubi steps

\begin {align*} \int \frac {1}{a+b \tanh (x)} \, dx &=\frac {a x}{a^2-b^2}-\frac {(i b) \int \frac {-i b-i a \tanh (x)}{a+b \tanh (x)} \, dx}{a^2-b^2}\\ &=\frac {a x}{a^2-b^2}-\frac {b \log (a \cosh (x)+b \sinh (x))}{a^2-b^2}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.05, size = 29, normalized size = 0.74 \begin {gather*} \frac {a x-b \log (a \cosh (x)+b \sinh (x))}{a^2-b^2} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [A]
time = 0.03, size = 55, normalized size = 1.41

method result size
derivativedivides \(-\frac {b \ln \left (a +b \tanh \left (x \right )\right )}{\left (a +b \right ) \left (a -b \right )}+\frac {\ln \left (\tanh \left (x \right )+1\right )}{2 a -2 b}-\frac {\ln \left (\tanh \left (x \right )-1\right )}{2 a +2 b}\) \(55\)
default \(-\frac {b \ln \left (a +b \tanh \left (x \right )\right )}{\left (a +b \right ) \left (a -b \right )}+\frac {\ln \left (\tanh \left (x \right )+1\right )}{2 a -2 b}-\frac {\ln \left (\tanh \left (x \right )-1\right )}{2 a +2 b}\) \(55\)
risch \(\frac {x}{a +b}+\frac {2 b x}{a^{2}-b^{2}}-\frac {b \ln \left ({\mathrm e}^{2 x}+\frac {a -b}{a +b}\right )}{a^{2}-b^{2}}\) \(55\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [A]
time = 1.70, size = 41, normalized size = 1.05 \begin {gather*} -\frac {b \log \left (-{\left (a - b\right )} e^{\left (-2 \, x\right )} - a - b\right )}{a^{2} - b^{2}} + \frac {x}{a + b} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Fricas [A]
time = 0.55, size = 42, normalized size = 1.08 \begin {gather*} \frac {{\left (a + b\right )} x - b \log \left (\frac {2 \, {\left (a \cosh \left (x\right ) + b \sinh \left (x\right )\right )}}{\cosh \left (x\right ) - \sinh \left (x\right )}\right )}{a^{2} - b^{2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 146 vs. \(2 (29) = 58\).
time = 0.26, size = 146, normalized size = 3.74 \begin {gather*} \begin {cases} \tilde {\infty } \left (x - \log {\left (\tanh {\left (x \right )} + 1 \right )} + \log {\left (\tanh {\left (x \right )} \right )}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {x}{a} & \text {for}\: b = 0 \\- \frac {x \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} + \frac {x}{2 b \tanh {\left (x \right )} - 2 b} + \frac {1}{2 b \tanh {\left (x \right )} - 2 b} & \text {for}\: a = - b \\\frac {x \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} + \frac {x}{2 b \tanh {\left (x \right )} + 2 b} - \frac {1}{2 b \tanh {\left (x \right )} + 2 b} & \text {for}\: a = b \\\frac {a x}{a^{2} - b^{2}} - \frac {b x}{a^{2} - b^{2}} - \frac {b \log {\left (\frac {a}{b} + \tanh {\left (x \right )} \right )}}{a^{2} - b^{2}} + \frac {b \log {\left (\tanh {\left (x \right )} + 1 \right )}}{a^{2} - b^{2}} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*tanh(x)),x)

[Out]

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

________________________________________________________________________________________

Giac [A]
time = 1.13, size = 43, normalized size = 1.10 \begin {gather*} -\frac {b \log \left ({\left | a e^{\left (2 \, x\right )} + b e^{\left (2 \, x\right )} + a - b \right |}\right )}{a^{2} - b^{2}} + \frac {x}{a - b} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Mupad [B]
time = 0.13, size = 35, normalized size = 0.90 \begin {gather*} \frac {a\,x-b\,\left (x-\ln \left (\mathrm {tanh}\left (x\right )+1\right )+\ln \left (a+b\,\mathrm {tanh}\left (x\right )\right )\right )}{a^2-b^2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1/(a + b*tanh(x)),x)

[Out]

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

________________________________________________________________________________________