Integrand size = 13, antiderivative size = 63 \[ \int \frac {\tanh ^2(x)}{a+b \tanh (x)} \, dx=-\frac {a x}{b^2}+\frac {a^3 x}{b^2 \left (a^2-b^2\right )}+\frac {\log (\cosh (x))}{b}-\frac {a^2 \log (a \cosh (x)+b \sinh (x))}{b \left (a^2-b^2\right )} \]
Time = 0.15 (sec) , antiderivative size = 59, normalized size of antiderivative = 0.94 \[ \int \frac {\tanh ^2(x)}{a+b \tanh (x)} \, dx=-\frac {\log (1-\tanh (x))}{2 (a+b)}+\frac {\log (1+\tanh (x))}{2 (a-b)}-\frac {a^2 \log (a+b \tanh (x))}{b \left (a^2-b^2\right )} \]
-1/2*Log[1 - Tanh[x]]/(a + b) + Log[1 + Tanh[x]]/(2*(a - b)) - (a^2*Log[a + b*Tanh[x]])/(b*(a^2 - b^2))
Time = 0.46 (sec) , antiderivative size = 61, normalized size of antiderivative = 0.97, number of steps used = 11, number of rules used = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.846, Rules used = {3042, 25, 4024, 26, 3042, 26, 3956, 3965, 26, 3042, 4013}
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 {\tanh ^2(x)}{a+b \tanh (x)} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int -\frac {\tan (i x)^2}{a-i b \tan (i x)}dx\) |
\(\Big \downarrow \) 25 |
\(\displaystyle -\int \frac {\tan (i x)^2}{a-i b \tan (i x)}dx\) |
\(\Big \downarrow \) 4024 |
\(\displaystyle \frac {a^2 \int \frac {1}{a+b \tanh (x)}dx}{b^2}-\frac {i \int i \tanh (x)dx}{b}-\frac {a x}{b^2}\) |
\(\Big \downarrow \) 26 |
\(\displaystyle \frac {a^2 \int \frac {1}{a+b \tanh (x)}dx}{b^2}+\frac {\int \tanh (x)dx}{b}-\frac {a x}{b^2}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {a^2 \int \frac {1}{a-i b \tan (i x)}dx}{b^2}+\frac {\int -i \tan (i x)dx}{b}-\frac {a x}{b^2}\) |
\(\Big \downarrow \) 26 |
\(\displaystyle \frac {a^2 \int \frac {1}{a-i b \tan (i x)}dx}{b^2}-\frac {i \int \tan (i x)dx}{b}-\frac {a x}{b^2}\) |
\(\Big \downarrow \) 3956 |
\(\displaystyle \frac {a^2 \int \frac {1}{a-i b \tan (i x)}dx}{b^2}-\frac {a x}{b^2}+\frac {\log (\cosh (x))}{b}\) |
\(\Big \downarrow \) 3965 |
\(\displaystyle \frac {a^2 \left (\frac {a x}{a^2-b^2}-\frac {i b \int -\frac {i (b+a \tanh (x))}{a+b \tanh (x)}dx}{a^2-b^2}\right )}{b^2}-\frac {a x}{b^2}+\frac {\log (\cosh (x))}{b}\) |
\(\Big \downarrow \) 26 |
\(\displaystyle \frac {a^2 \left (\frac {a x}{a^2-b^2}-\frac {b \int \frac {b+a \tanh (x)}{a+b \tanh (x)}dx}{a^2-b^2}\right )}{b^2}-\frac {a x}{b^2}+\frac {\log (\cosh (x))}{b}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {a^2 \left (\frac {a x}{a^2-b^2}-\frac {b \int \frac {b-i a \tan (i x)}{a-i b \tan (i x)}dx}{a^2-b^2}\right )}{b^2}-\frac {a x}{b^2}+\frac {\log (\cosh (x))}{b}\) |
\(\Big \downarrow \) 4013 |
\(\displaystyle \frac {a^2 \left (\frac {a x}{a^2-b^2}-\frac {b \log (a \cosh (x)+b \sinh (x))}{a^2-b^2}\right )}{b^2}-\frac {a x}{b^2}+\frac {\log (\cosh (x))}{b}\) |
-((a*x)/b^2) + Log[Cosh[x]]/b + (a^2*((a*x)/(a^2 - b^2) - (b*Log[a*Cosh[x] + b*Sinh[x]])/(a^2 - b^2)))/b^2
3.2.36.3.1 Defintions of rubi rules used
Int[(Complex[0, a_])*(Fx_), x_Symbol] :> Simp[(Complex[Identity[0], a]) I nt[Fx, x], x] /; FreeQ[a, x] && EqQ[a^2, 1]
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d *x], x]]/d, x] /; FreeQ[{c, d}, x]
Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Simp[a*(x/(a^ 2 + b^2)), x] + Simp[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]
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*Si n[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]
Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2/((a_.) + (b_.)*tan[(e_.) + (f _.)*(x_)]), x_Symbol] :> Simp[d*(2*b*c - a*d)*(x/b^2), x] + (Simp[d^2/b I nt[Tan[e + f*x], x], x] + Simp[(b*c - a*d)^2/b^2 Int[1/(a + b*Tan[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]
Time = 0.05 (sec) , antiderivative size = 52, normalized size of antiderivative = 0.83
method | result | size |
parallelrisch | \(-\frac {-\ln \left (1-\tanh \left (x \right )\right ) b^{2}+a^{2} \ln \left (a +b \tanh \left (x \right )\right )-a b x -b^{2} x}{b \left (a^{2}-b^{2}\right )}\) | \(52\) |
derivativedivides | \(-\frac {a^{2} \ln \left (a +b \tanh \left (x \right )\right )}{\left (a +b \right ) \left (a -b \right ) b}+\frac {\ln \left (1+\tanh \left (x \right )\right )}{2 a -2 b}-\frac {\ln \left (\tanh \left (x \right )-1\right )}{2 a +2 b}\) | \(60\) |
default | \(-\frac {a^{2} \ln \left (a +b \tanh \left (x \right )\right )}{\left (a +b \right ) \left (a -b \right ) b}+\frac {\ln \left (1+\tanh \left (x \right )\right )}{2 a -2 b}-\frac {\ln \left (\tanh \left (x \right )-1\right )}{2 a +2 b}\) | \(60\) |
risch | \(\frac {x}{a +b}+\frac {2 x \,a^{2}}{b \left (a^{2}-b^{2}\right )}-\frac {2 x}{b}-\frac {a^{2} \ln \left ({\mathrm e}^{2 x}+\frac {a -b}{a +b}\right )}{b \left (a^{2}-b^{2}\right )}+\frac {\ln \left (1+{\mathrm e}^{2 x}\right )}{b}\) | \(82\) |
Time = 0.26 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.21 \[ \int \frac {\tanh ^2(x)}{a+b \tanh (x)} \, dx=-\frac {a^{2} \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 ) - {\left (a b + b^{2}\right )} x - {\left (a^{2} - b^{2}\right )} \log \left (\frac {2 \, \cosh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}\right )}{a^{2} b - b^{3}} \]
-(a^2*log(2*(a*cosh(x) + b*sinh(x))/(cosh(x) - sinh(x))) - (a*b + b^2)*x - (a^2 - b^2)*log(2*cosh(x)/(cosh(x) - sinh(x))))/(a^2*b - b^3)
Leaf count of result is larger than twice the leaf count of optimal. 243 vs. \(2 (51) = 102\).
Time = 0.26 (sec) , antiderivative size = 243, normalized size of antiderivative = 3.86 \[ \int \frac {\tanh ^2(x)}{a+b \tanh (x)} \, dx=\begin {cases} \tilde {\infty } \left (x - \log {\left (\tanh {\left (x \right )} + 1 \right )}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {x - \tanh {\left (x \right )}}{a} & \text {for}\: b = 0 \\\frac {3 x \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} - \frac {3 x}{2 b \tanh {\left (x \right )} - 2 b} - \frac {2 \log {\left (\tanh {\left (x \right )} + 1 \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} + \frac {2 \log {\left (\tanh {\left (x \right )} + 1 \right )}}{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 {2 \log {\left (\tanh {\left (x \right )} + 1 \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} - \frac {2 \log {\left (\tanh {\left (x \right )} + 1 \right )}}{2 b \tanh {\left (x \right )} + 2 b} - \frac {1}{2 b \tanh {\left (x \right )} + 2 b} & \text {for}\: a = b \\- \frac {a^{2} \log {\left (\frac {a}{b} + \tanh {\left (x \right )} \right )}}{a^{2} b - b^{3}} + \frac {a b x}{a^{2} b - b^{3}} - \frac {b^{2} x}{a^{2} b - b^{3}} + \frac {b^{2} \log {\left (\tanh {\left (x \right )} + 1 \right )}}{a^{2} b - b^{3}} & \text {otherwise} \end {cases} \]
Piecewise((zoo*(x - log(tanh(x) + 1)), Eq(a, 0) & Eq(b, 0)), ((x - tanh(x) )/a, Eq(b, 0)), (3*x*tanh(x)/(2*b*tanh(x) - 2*b) - 3*x/(2*b*tanh(x) - 2*b) - 2*log(tanh(x) + 1)*tanh(x)/(2*b*tanh(x) - 2*b) + 2*log(tanh(x) + 1)/(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) - 2*log(tanh(x) + 1)*tanh(x)/(2*b*tanh( x) + 2*b) - 2*log(tanh(x) + 1)/(2*b*tanh(x) + 2*b) - 1/(2*b*tanh(x) + 2*b) , Eq(a, b)), (-a**2*log(a/b + tanh(x))/(a**2*b - b**3) + a*b*x/(a**2*b - b **3) - b**2*x/(a**2*b - b**3) + b**2*log(tanh(x) + 1)/(a**2*b - b**3), Tru e))
Time = 0.26 (sec) , antiderivative size = 56, normalized size of antiderivative = 0.89 \[ \int \frac {\tanh ^2(x)}{a+b \tanh (x)} \, dx=-\frac {a^{2} \log \left (-{\left (a - b\right )} e^{\left (-2 \, x\right )} - a - b\right )}{a^{2} b - b^{3}} + \frac {x}{a + b} + \frac {\log \left (e^{\left (-2 \, x\right )} + 1\right )}{b} \]
Time = 0.26 (sec) , antiderivative size = 58, normalized size of antiderivative = 0.92 \[ \int \frac {\tanh ^2(x)}{a+b \tanh (x)} \, dx=-\frac {a^{2} \log \left ({\left | a e^{\left (2 \, x\right )} + b e^{\left (2 \, x\right )} + a - b \right |}\right )}{a^{2} b - b^{3}} + \frac {x}{a - b} + \frac {\log \left (e^{\left (2 \, x\right )} + 1\right )}{b} \]
Time = 1.74 (sec) , antiderivative size = 46, normalized size of antiderivative = 0.73 \[ \int \frac {\tanh ^2(x)}{a+b \tanh (x)} \, dx=-\frac {b^2\,\left (x-\ln \left (\mathrm {tanh}\left (x\right )+1\right )\right )+a^2\,\ln \left (a+b\,\mathrm {tanh}\left (x\right )\right )-a\,b\,x}{b\,\left (a^2-b^2\right )} \]