\(\int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx\) [212]

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

Optimal result

Integrand size = 15, antiderivative size = 44 \[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=\sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a+b \tanh ^2(x)}}{\sqrt {a+b}}\right )-\sqrt {a+b \tanh ^2(x)} \] Output:

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

Mathematica [A] (verified)

Time = 0.02 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.00 \[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=\sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a+b \tanh ^2(x)}}{\sqrt {a+b}}\right )-\sqrt {a+b \tanh ^2(x)} \] Input:

Integrate[Tanh[x]*Sqrt[a + b*Tanh[x]^2],x]
 

Output:

Sqrt[a + b]*ArcTanh[Sqrt[a + b*Tanh[x]^2]/Sqrt[a + b]] - Sqrt[a + b*Tanh[x 
]^2]
 

Rubi [A] (verified)

Time = 0.26 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.11, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.533, Rules used = {3042, 26, 4153, 26, 353, 60, 73, 221}

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 \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int -i \tan (i x) \sqrt {a-b \tan (i x)^2}dx\)

\(\Big \downarrow \) 26

\(\displaystyle -i \int \tan (i x) \sqrt {a-b \tan (i x)^2}dx\)

\(\Big \downarrow \) 4153

\(\displaystyle -i \int \frac {i \tanh (x) \sqrt {b \tanh ^2(x)+a}}{1-\tanh ^2(x)}d\tanh (x)\)

\(\Big \downarrow \) 26

\(\displaystyle \int \frac {\tanh (x) \sqrt {a+b \tanh ^2(x)}}{1-\tanh ^2(x)}d\tanh (x)\)

\(\Big \downarrow \) 353

\(\displaystyle \frac {1}{2} \int \frac {\sqrt {b \tanh ^2(x)+a}}{1-\tanh ^2(x)}d\tanh ^2(x)\)

\(\Big \downarrow \) 60

\(\displaystyle \frac {1}{2} \left ((a+b) \int \frac {1}{\left (1-\tanh ^2(x)\right ) \sqrt {b \tanh ^2(x)+a}}d\tanh ^2(x)-2 \sqrt {a+b \tanh ^2(x)}\right )\)

\(\Big \downarrow \) 73

\(\displaystyle \frac {1}{2} \left (\frac {2 (a+b) \int \frac {1}{\frac {a+b}{b}-\frac {\tanh ^4(x)}{b}}d\sqrt {b \tanh ^2(x)+a}}{b}-2 \sqrt {a+b \tanh ^2(x)}\right )\)

\(\Big \downarrow \) 221

\(\displaystyle \frac {1}{2} \left (2 \sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a+b \tanh ^2(x)}}{\sqrt {a+b}}\right )-2 \sqrt {a+b \tanh ^2(x)}\right )\)

Input:

Int[Tanh[x]*Sqrt[a + b*Tanh[x]^2],x]
 

Output:

(2*Sqrt[a + b]*ArcTanh[Sqrt[a + b*Tanh[x]^2]/Sqrt[a + b]] - 2*Sqrt[a + b*T 
anh[x]^2])/2
 

Defintions of rubi rules used

rule 26
Int[(Complex[0, a_])*(Fx_), x_Symbol] :> Simp[(Complex[Identity[0], a])   I 
nt[Fx, x], x] /; FreeQ[a, x] && EqQ[a^2, 1]
 

rule 60
Int[((a_.) + (b_.)*(x_))^(m_)*((c_.) + (d_.)*(x_))^(n_), x_Symbol] :> Simp[ 
(a + b*x)^(m + 1)*((c + d*x)^n/(b*(m + n + 1))), x] + Simp[n*((b*c - a*d)/( 
b*(m + n + 1)))   Int[(a + b*x)^m*(c + d*x)^(n - 1), x], x] /; FreeQ[{a, b, 
 c, d}, x] && GtQ[n, 0] && NeQ[m + n + 1, 0] &&  !(IGtQ[m, 0] && ( !Integer 
Q[n] || (GtQ[m, 0] && LtQ[m - n, 0]))) &&  !ILtQ[m + n + 2, 0] && IntLinear 
Q[a, b, c, d, m, n, x]
 

rule 73
Int[((a_.) + (b_.)*(x_))^(m_)*((c_.) + (d_.)*(x_))^(n_), x_Symbol] :> With[ 
{p = Denominator[m]}, Simp[p/b   Subst[Int[x^(p*(m + 1) - 1)*(c - a*(d/b) + 
 d*(x^p/b))^n, x], x, (a + b*x)^(1/p)], x]] /; FreeQ[{a, b, c, d}, x] && Lt 
Q[-1, m, 0] && LeQ[-1, n, 0] && LeQ[Denominator[n], Denominator[m]] && IntL 
inearQ[a, b, c, d, m, n, x]
 

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

rule 353
Int[(x_)*((a_) + (b_.)*(x_)^2)^(p_.)*((c_) + (d_.)*(x_)^2)^(q_.), x_Symbol] 
 :> Simp[1/2   Subst[Int[(a + b*x)^p*(c + d*x)^q, x], x, x^2], x] /; FreeQ[ 
{a, b, c, d, p, q}, x] && NeQ[b*c - a*d, 0]
 

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

rule 4153
Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + 
(f_.)*(x_)])^(n_))^(p_.), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], 
 x]}, Simp[c*(ff/f)   Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2 + f 
f^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, 
n, p}, x] && (IGtQ[p, 0] || EqQ[n, 2] || EqQ[n, 4] || (IntegerQ[p] && Ratio 
nalQ[n]))
 
Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(237\) vs. \(2(36)=72\).

Time = 0.05 (sec) , antiderivative size = 238, normalized size of antiderivative = 5.41

method result size
derivativedivides \(-\frac {\sqrt {b \left (\tanh \left (x \right )-1\right )^{2}+2 b \left (\tanh \left (x \right )-1\right )+a +b}}{2}-\frac {\sqrt {b}\, \ln \left (\frac {b \left (\tanh \left (x \right )-1\right )+b}{\sqrt {b}}+\sqrt {b \left (\tanh \left (x \right )-1\right )^{2}+2 b \left (\tanh \left (x \right )-1\right )+a +b}\right )}{2}+\frac {\sqrt {a +b}\, \ln \left (\frac {2 a +2 b +2 b \left (\tanh \left (x \right )-1\right )+2 \sqrt {a +b}\, \sqrt {b \left (\tanh \left (x \right )-1\right )^{2}+2 b \left (\tanh \left (x \right )-1\right )+a +b}}{\tanh \left (x \right )-1}\right )}{2}-\frac {\sqrt {b \left (\tanh \left (x \right )+1\right )^{2}-2 b \left (\tanh \left (x \right )+1\right )+a +b}}{2}+\frac {\sqrt {b}\, \ln \left (\frac {b \left (\tanh \left (x \right )+1\right )-b}{\sqrt {b}}+\sqrt {b \left (\tanh \left (x \right )+1\right )^{2}-2 b \left (\tanh \left (x \right )+1\right )+a +b}\right )}{2}+\frac {\sqrt {a +b}\, \ln \left (\frac {2 a +2 b -2 b \left (\tanh \left (x \right )+1\right )+2 \sqrt {a +b}\, \sqrt {b \left (\tanh \left (x \right )+1\right )^{2}-2 b \left (\tanh \left (x \right )+1\right )+a +b}}{\tanh \left (x \right )+1}\right )}{2}\) \(238\)
default \(-\frac {\sqrt {b \left (\tanh \left (x \right )-1\right )^{2}+2 b \left (\tanh \left (x \right )-1\right )+a +b}}{2}-\frac {\sqrt {b}\, \ln \left (\frac {b \left (\tanh \left (x \right )-1\right )+b}{\sqrt {b}}+\sqrt {b \left (\tanh \left (x \right )-1\right )^{2}+2 b \left (\tanh \left (x \right )-1\right )+a +b}\right )}{2}+\frac {\sqrt {a +b}\, \ln \left (\frac {2 a +2 b +2 b \left (\tanh \left (x \right )-1\right )+2 \sqrt {a +b}\, \sqrt {b \left (\tanh \left (x \right )-1\right )^{2}+2 b \left (\tanh \left (x \right )-1\right )+a +b}}{\tanh \left (x \right )-1}\right )}{2}-\frac {\sqrt {b \left (\tanh \left (x \right )+1\right )^{2}-2 b \left (\tanh \left (x \right )+1\right )+a +b}}{2}+\frac {\sqrt {b}\, \ln \left (\frac {b \left (\tanh \left (x \right )+1\right )-b}{\sqrt {b}}+\sqrt {b \left (\tanh \left (x \right )+1\right )^{2}-2 b \left (\tanh \left (x \right )+1\right )+a +b}\right )}{2}+\frac {\sqrt {a +b}\, \ln \left (\frac {2 a +2 b -2 b \left (\tanh \left (x \right )+1\right )+2 \sqrt {a +b}\, \sqrt {b \left (\tanh \left (x \right )+1\right )^{2}-2 b \left (\tanh \left (x \right )+1\right )+a +b}}{\tanh \left (x \right )+1}\right )}{2}\) \(238\)

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 489 vs. \(2 (36) = 72\).

Time = 0.13 (sec) , antiderivative size = 1543, normalized size of antiderivative = 35.07 \[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=\text {Too large to display} \] Input:

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

Output:

[1/4*((cosh(x)^2 + 2*cosh(x)*sinh(x) + sinh(x)^2 + 1)*sqrt(a + b)*log(((a^ 
3 + a^2*b)*cosh(x)^8 + 8*(a^3 + a^2*b)*cosh(x)*sinh(x)^7 + (a^3 + a^2*b)*s 
inh(x)^8 + 2*(2*a^3 + a^2*b)*cosh(x)^6 + 2*(2*a^3 + a^2*b + 14*(a^3 + a^2* 
b)*cosh(x)^2)*sinh(x)^6 + 4*(14*(a^3 + a^2*b)*cosh(x)^3 + 3*(2*a^3 + a^2*b 
)*cosh(x))*sinh(x)^5 + (6*a^3 + 4*a^2*b - a*b^2 + b^3)*cosh(x)^4 + (70*(a^ 
3 + a^2*b)*cosh(x)^4 + 6*a^3 + 4*a^2*b - a*b^2 + b^3 + 30*(2*a^3 + a^2*b)* 
cosh(x)^2)*sinh(x)^4 + 4*(14*(a^3 + a^2*b)*cosh(x)^5 + 10*(2*a^3 + a^2*b)* 
cosh(x)^3 + (6*a^3 + 4*a^2*b - a*b^2 + b^3)*cosh(x))*sinh(x)^3 + a^3 + 3*a 
^2*b + 3*a*b^2 + b^3 + 2*(2*a^3 + 3*a^2*b - b^3)*cosh(x)^2 + 2*(14*(a^3 + 
a^2*b)*cosh(x)^6 + 15*(2*a^3 + a^2*b)*cosh(x)^4 + 2*a^3 + 3*a^2*b - b^3 + 
3*(6*a^3 + 4*a^2*b - a*b^2 + b^3)*cosh(x)^2)*sinh(x)^2 + sqrt(2)*(a^2*cosh 
(x)^6 + 6*a^2*cosh(x)*sinh(x)^5 + a^2*sinh(x)^6 + 3*a^2*cosh(x)^4 + 3*(5*a 
^2*cosh(x)^2 + a^2)*sinh(x)^4 + 4*(5*a^2*cosh(x)^3 + 3*a^2*cosh(x))*sinh(x 
)^3 + (3*a^2 + 2*a*b - b^2)*cosh(x)^2 + (15*a^2*cosh(x)^4 + 18*a^2*cosh(x) 
^2 + 3*a^2 + 2*a*b - b^2)*sinh(x)^2 + a^2 + 2*a*b + b^2 + 2*(3*a^2*cosh(x) 
^5 + 6*a^2*cosh(x)^3 + (3*a^2 + 2*a*b - b^2)*cosh(x))*sinh(x))*sqrt(a + b) 
*sqrt(((a + b)*cosh(x)^2 + (a + b)*sinh(x)^2 + a - b)/(cosh(x)^2 - 2*cosh( 
x)*sinh(x) + sinh(x)^2)) + 4*(2*(a^3 + a^2*b)*cosh(x)^7 + 3*(2*a^3 + a^2*b 
)*cosh(x)^5 + (6*a^3 + 4*a^2*b - a*b^2 + b^3)*cosh(x)^3 + (2*a^3 + 3*a^2*b 
 - b^3)*cosh(x))*sinh(x))/(cosh(x)^6 + 6*cosh(x)^5*sinh(x) + 15*cosh(x)...
 

Sympy [A] (verification not implemented)

Time = 0.90 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.55 \[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=- \begin {cases} \frac {2 \left (\frac {b \sqrt {a + b \tanh ^{2}{\left (x \right )}}}{2} + \frac {b \left (a + b\right ) \operatorname {atan}{\left (\frac {\sqrt {a + b \tanh ^{2}{\left (x \right )}}}{\sqrt {- a - b}} \right )}}{2 \sqrt {- a - b}}\right )}{b} & \text {for}\: b \neq 0 \\\frac {\sqrt {a} \log {\left (2 \tanh ^{2}{\left (x \right )} - 2 \right )}}{2} & \text {otherwise} \end {cases} \] Input:

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

Output:

-Piecewise((2*(b*sqrt(a + b*tanh(x)**2)/2 + b*(a + b)*atan(sqrt(a + b*tanh 
(x)**2)/sqrt(-a - b))/(2*sqrt(-a - b)))/b, Ne(b, 0)), (sqrt(a)*log(2*tanh( 
x)**2 - 2)/2, True))
 

Maxima [F]

\[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=\int { \sqrt {b \tanh \left (x\right )^{2} + a} \tanh \left (x\right ) \,d x } \] Input:

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

Output:

integrate(sqrt(b*tanh(x)^2 + a)*tanh(x), x)
 

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 349 vs. \(2 (36) = 72\).

Time = 0.35 (sec) , antiderivative size = 349, normalized size of antiderivative = 7.93 \[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=-\frac {1}{2} \, \sqrt {a + b} \log \left ({\left | -{\left (\sqrt {a + b} e^{\left (2 \, x\right )} - \sqrt {a e^{\left (4 \, x\right )} + b e^{\left (4 \, x\right )} + 2 \, a e^{\left (2 \, x\right )} - 2 \, b e^{\left (2 \, x\right )} + a + b}\right )} {\left (a + b\right )} - \sqrt {a + b} {\left (a - b\right )} \right |}\right ) + \frac {1}{2} \, \sqrt {a + b} \log \left ({\left | -\sqrt {a + b} e^{\left (2 \, x\right )} + \sqrt {a e^{\left (4 \, x\right )} + b e^{\left (4 \, x\right )} + 2 \, a e^{\left (2 \, x\right )} - 2 \, b e^{\left (2 \, x\right )} + a + b} + \sqrt {a + b} \right |}\right ) - \frac {1}{2} \, \sqrt {a + b} \log \left ({\left | -\sqrt {a + b} e^{\left (2 \, x\right )} + \sqrt {a e^{\left (4 \, x\right )} + b e^{\left (4 \, x\right )} + 2 \, a e^{\left (2 \, x\right )} - 2 \, b e^{\left (2 \, x\right )} + a + b} - \sqrt {a + b} \right |}\right ) - \frac {4 \, {\left ({\left (\sqrt {a + b} e^{\left (2 \, x\right )} - \sqrt {a e^{\left (4 \, x\right )} + b e^{\left (4 \, x\right )} + 2 \, a e^{\left (2 \, x\right )} - 2 \, b e^{\left (2 \, x\right )} + a + b}\right )} b - \sqrt {a + b} b\right )}}{{\left (\sqrt {a + b} e^{\left (2 \, x\right )} - \sqrt {a e^{\left (4 \, x\right )} + b e^{\left (4 \, x\right )} + 2 \, a e^{\left (2 \, x\right )} - 2 \, b e^{\left (2 \, x\right )} + a + b}\right )}^{2} + 2 \, {\left (\sqrt {a + b} e^{\left (2 \, x\right )} - \sqrt {a e^{\left (4 \, x\right )} + b e^{\left (4 \, x\right )} + 2 \, a e^{\left (2 \, x\right )} - 2 \, b e^{\left (2 \, x\right )} + a + b}\right )} \sqrt {a + b} + a - 3 \, b} \] Input:

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

Output:

-1/2*sqrt(a + b)*log(abs(-(sqrt(a + b)*e^(2*x) - sqrt(a*e^(4*x) + b*e^(4*x 
) + 2*a*e^(2*x) - 2*b*e^(2*x) + a + b))*(a + b) - sqrt(a + b)*(a - b))) + 
1/2*sqrt(a + b)*log(abs(-sqrt(a + b)*e^(2*x) + sqrt(a*e^(4*x) + b*e^(4*x) 
+ 2*a*e^(2*x) - 2*b*e^(2*x) + a + b) + sqrt(a + b))) - 1/2*sqrt(a + b)*log 
(abs(-sqrt(a + b)*e^(2*x) + sqrt(a*e^(4*x) + b*e^(4*x) + 2*a*e^(2*x) - 2*b 
*e^(2*x) + a + b) - sqrt(a + b))) - 4*((sqrt(a + b)*e^(2*x) - sqrt(a*e^(4* 
x) + b*e^(4*x) + 2*a*e^(2*x) - 2*b*e^(2*x) + a + b))*b - sqrt(a + b)*b)/(( 
sqrt(a + b)*e^(2*x) - sqrt(a*e^(4*x) + b*e^(4*x) + 2*a*e^(2*x) - 2*b*e^(2* 
x) + a + b))^2 + 2*(sqrt(a + b)*e^(2*x) - sqrt(a*e^(4*x) + b*e^(4*x) + 2*a 
*e^(2*x) - 2*b*e^(2*x) + a + b))*sqrt(a + b) + a - 3*b)
 

Mupad [B] (verification not implemented)

Time = 2.76 (sec) , antiderivative size = 51, normalized size of antiderivative = 1.16 \[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=-\sqrt {b\,{\mathrm {tanh}\left (x\right )}^2+a}-2\,\mathrm {atan}\left (\frac {2\,\sqrt {b\,{\mathrm {tanh}\left (x\right )}^2+a}\,\sqrt {-\frac {a}{4}-\frac {b}{4}}}{a+b}\right )\,\sqrt {-\frac {a}{4}-\frac {b}{4}} \] Input:

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

Output:

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

Reduce [F]

\[ \int \tanh (x) \sqrt {a+b \tanh ^2(x)} \, dx=\frac {\sqrt {\tanh \left (x \right )^{2} b +a}\, a +\left (\int \frac {\sqrt {\tanh \left (x \right )^{2} b +a}\, \tanh \left (x \right )^{3}}{\tanh \left (x \right )^{2} b +a}d x \right ) a b +\left (\int \frac {\sqrt {\tanh \left (x \right )^{2} b +a}\, \tanh \left (x \right )^{3}}{\tanh \left (x \right )^{2} b +a}d x \right ) b^{2}}{b} \] Input:

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

Output:

(sqrt(tanh(x)**2*b + a)*a + int((sqrt(tanh(x)**2*b + a)*tanh(x)**3)/(tanh( 
x)**2*b + a),x)*a*b + int((sqrt(tanh(x)**2*b + a)*tanh(x)**3)/(tanh(x)**2* 
b + a),x)*b**2)/b