### 3.152 $$\int \frac{f+g x+h x^2}{(d+e x) (a+b x+c x^2)} \, dx$$

Optimal. Leaf size=196 $-\frac{\tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right ) \left (-c (2 a d h-2 a e g+b d g+b e f)+b h (b d-a e)+2 c^2 d f\right )}{c \sqrt{b^2-4 a c} \left (a e^2-b d e+c d^2\right )}-\frac{\log \left (a+b x+c x^2\right ) (-a e h+b d h-c d g+c e f)}{2 c \left (a e^2-b d e+c d^2\right )}+\frac{\log (d+e x) \left (d^2 h-d e g+e^2 f\right )}{e \left (a e^2-b d e+c d^2\right )}$

[Out]

-(((2*c^2*d*f + b*(b*d - a*e)*h - c*(b*e*f + b*d*g - 2*a*e*g + 2*a*d*h))*ArcTanh[(b + 2*c*x)/Sqrt[b^2 - 4*a*c]
])/(c*Sqrt[b^2 - 4*a*c]*(c*d^2 - b*d*e + a*e^2))) + ((e^2*f - d*e*g + d^2*h)*Log[d + e*x])/(e*(c*d^2 - b*d*e +
a*e^2)) - ((c*e*f - c*d*g + b*d*h - a*e*h)*Log[a + b*x + c*x^2])/(2*c*(c*d^2 - b*d*e + a*e^2))

________________________________________________________________________________________

Rubi [A]  time = 0.348852, antiderivative size = 196, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 5, integrand size = 30, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.167, Rules used = {1628, 634, 618, 206, 628} $-\frac{\tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right ) \left (-c (2 a d h-2 a e g+b d g+b e f)+b h (b d-a e)+2 c^2 d f\right )}{c \sqrt{b^2-4 a c} \left (a e^2-b d e+c d^2\right )}-\frac{\log \left (a+b x+c x^2\right ) (-a e h+b d h-c d g+c e f)}{2 c \left (a e^2-b d e+c d^2\right )}+\frac{\log (d+e x) \left (d^2 h-d e g+e^2 f\right )}{e \left (a e^2-b d e+c d^2\right )}$

Antiderivative was successfully veriﬁed.

[In]

Int[(f + g*x + h*x^2)/((d + e*x)*(a + b*x + c*x^2)),x]

[Out]

-(((2*c^2*d*f + b*(b*d - a*e)*h - c*(b*e*f + b*d*g - 2*a*e*g + 2*a*d*h))*ArcTanh[(b + 2*c*x)/Sqrt[b^2 - 4*a*c]
])/(c*Sqrt[b^2 - 4*a*c]*(c*d^2 - b*d*e + a*e^2))) + ((e^2*f - d*e*g + d^2*h)*Log[d + e*x])/(e*(c*d^2 - b*d*e +
a*e^2)) - ((c*e*f - c*d*g + b*d*h - a*e*h)*Log[a + b*x + c*x^2])/(2*c*(c*d^2 - b*d*e + a*e^2))

Rule 1628

Int[(Pq_)*((d_.) + (e_.)*(x_))^(m_.)*((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegra
nd[(d + e*x)^m*Pq*(a + b*x + c*x^2)^p, x], x] /; FreeQ[{a, b, c, d, e, m}, x] && PolyQ[Pq, x] && IGtQ[p, -2]

Rule 634

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

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 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 628

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

Rubi steps

\begin{align*} \int \frac{f+g x+h x^2}{(d+e x) \left (a+b x+c x^2\right )} \, dx &=\int \left (\frac{e^2 f-d e g+d^2 h}{\left (c d^2-b d e+a e^2\right ) (d+e x)}+\frac{c d f-b e f+a e g-a d h-(c e f-c d g+b d h-a e h) x}{\left (c d^2-b d e+a e^2\right ) \left (a+b x+c x^2\right )}\right ) \, dx\\ &=\frac{\left (e^2 f-d e g+d^2 h\right ) \log (d+e x)}{e \left (c d^2-b d e+a e^2\right )}+\frac{\int \frac{c d f-b e f+a e g-a d h-(c e f-c d g+b d h-a e h) x}{a+b x+c x^2} \, dx}{c d^2-b d e+a e^2}\\ &=\frac{\left (e^2 f-d e g+d^2 h\right ) \log (d+e x)}{e \left (c d^2-b d e+a e^2\right )}-\frac{(c e f-c d g+b d h-a e h) \int \frac{b+2 c x}{a+b x+c x^2} \, dx}{2 c \left (c d^2-b d e+a e^2\right )}+\frac{\left (2 c^2 d f+b (b d-a e) h-c (b e f+b d g-2 a e g+2 a d h)\right ) \int \frac{1}{a+b x+c x^2} \, dx}{2 c \left (c d^2-b d e+a e^2\right )}\\ &=\frac{\left (e^2 f-d e g+d^2 h\right ) \log (d+e x)}{e \left (c d^2-b d e+a e^2\right )}-\frac{(c e f-c d g+b d h-a e h) \log \left (a+b x+c x^2\right )}{2 c \left (c d^2-b d e+a e^2\right )}-\frac{\left (2 c^2 d f+b (b d-a e) h-c (b e f+b d g-2 a e g+2 a d h)\right ) \operatorname{Subst}\left (\int \frac{1}{b^2-4 a c-x^2} \, dx,x,b+2 c x\right )}{c \left (c d^2-b d e+a e^2\right )}\\ &=-\frac{\left (2 c^2 d f+b (b d-a e) h-c (b e f+b d g-2 a e g+2 a d h)\right ) \tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right )}{c \sqrt{b^2-4 a c} \left (c d^2-b d e+a e^2\right )}+\frac{\left (e^2 f-d e g+d^2 h\right ) \log (d+e x)}{e \left (c d^2-b d e+a e^2\right )}-\frac{(c e f-c d g+b d h-a e h) \log \left (a+b x+c x^2\right )}{2 c \left (c d^2-b d e+a e^2\right )}\\ \end{align*}

Mathematica [A]  time = 0.24331, size = 193, normalized size = 0.98 $\frac{-2 e \tan ^{-1}\left (\frac{b+2 c x}{\sqrt{4 a c-b^2}}\right ) \left (c (2 a d h-2 a e g+b d g+b e f)+b h (a e-b d)-2 c^2 d f\right )+2 c \sqrt{4 a c-b^2} \log (d+e x) \left (d^2 h-d e g+e^2 f\right )-e \sqrt{4 a c-b^2} \log (a+x (b+c x)) (-a e h+b d h-c d g+c e f)}{2 c e \sqrt{4 a c-b^2} \left (e (a e-b d)+c d^2\right )}$

Antiderivative was successfully veriﬁed.

[In]

Integrate[(f + g*x + h*x^2)/((d + e*x)*(a + b*x + c*x^2)),x]

[Out]

(-2*e*(-2*c^2*d*f + b*(-(b*d) + a*e)*h + c*(b*e*f + b*d*g - 2*a*e*g + 2*a*d*h))*ArcTan[(b + 2*c*x)/Sqrt[-b^2 +
4*a*c]] + 2*c*Sqrt[-b^2 + 4*a*c]*(e^2*f - d*e*g + d^2*h)*Log[d + e*x] - Sqrt[-b^2 + 4*a*c]*e*(c*e*f - c*d*g +
b*d*h - a*e*h)*Log[a + x*(b + c*x)])/(2*c*Sqrt[-b^2 + 4*a*c]*e*(c*d^2 + e*(-(b*d) + a*e)))

________________________________________________________________________________________

Maple [B]  time = 0.183, size = 622, normalized size = 3.2 \begin{align*}{\frac{\ln \left ( c{x}^{2}+bx+a \right ) aeh}{ \left ( 2\,a{e}^{2}-2\,bde+2\,c{d}^{2} \right ) c}}-{\frac{\ln \left ( c{x}^{2}+bx+a \right ) bdh}{ \left ( 2\,a{e}^{2}-2\,bde+2\,c{d}^{2} \right ) c}}+{\frac{\ln \left ( c{x}^{2}+bx+a \right ) dg}{2\,a{e}^{2}-2\,bde+2\,c{d}^{2}}}-{\frac{\ln \left ( c{x}^{2}+bx+a \right ) ef}{2\,a{e}^{2}-2\,bde+2\,c{d}^{2}}}-2\,{\frac{adh}{ \left ( a{e}^{2}-bde+c{d}^{2} \right ) \sqrt{4\,ac-{b}^{2}}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) }+2\,{\frac{aeg}{ \left ( a{e}^{2}-bde+c{d}^{2} \right ) \sqrt{4\,ac-{b}^{2}}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) }-{\frac{bef}{a{e}^{2}-bde+c{d}^{2}}\arctan \left ({(2\,cx+b){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}} \right ){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}}+2\,{\frac{cdf}{ \left ( a{e}^{2}-bde+c{d}^{2} \right ) \sqrt{4\,ac-{b}^{2}}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) }-{\frac{abeh}{ \left ( a{e}^{2}-bde+c{d}^{2} \right ) c}\arctan \left ({(2\,cx+b){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}} \right ){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}}+{\frac{{b}^{2}dh}{ \left ( a{e}^{2}-bde+c{d}^{2} \right ) c}\arctan \left ({(2\,cx+b){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}} \right ){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}}-{\frac{bdg}{a{e}^{2}-bde+c{d}^{2}}\arctan \left ({(2\,cx+b){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}} \right ){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}}+{\frac{\ln \left ( ex+d \right ){d}^{2}h}{ \left ( a{e}^{2}-bde+c{d}^{2} \right ) e}}-{\frac{\ln \left ( ex+d \right ) dg}{a{e}^{2}-bde+c{d}^{2}}}+{\frac{e\ln \left ( ex+d \right ) f}{a{e}^{2}-bde+c{d}^{2}}} \end{align*}

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

[In]

int((h*x^2+g*x+f)/(e*x+d)/(c*x^2+b*x+a),x)

[Out]

1/2/(a*e^2-b*d*e+c*d^2)/c*ln(c*x^2+b*x+a)*a*e*h-1/2/(a*e^2-b*d*e+c*d^2)/c*ln(c*x^2+b*x+a)*b*d*h+1/2/(a*e^2-b*d
*e+c*d^2)*ln(c*x^2+b*x+a)*d*g-1/2/(a*e^2-b*d*e+c*d^2)*ln(c*x^2+b*x+a)*e*f-2/(a*e^2-b*d*e+c*d^2)/(4*a*c-b^2)^(1
/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*a*d*h+2/(a*e^2-b*d*e+c*d^2)/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-
b^2)^(1/2))*a*e*g-1/(a*e^2-b*d*e+c*d^2)/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*b*e*f+2/(a*e^2-b
*d*e+c*d^2)/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*c*d*f-1/(a*e^2-b*d*e+c*d^2)/(4*a*c-b^2)^(1/2
)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*b/c*a*e*h+1/(a*e^2-b*d*e+c*d^2)/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*
c-b^2)^(1/2))*b^2/c*d*h-1/(a*e^2-b*d*e+c*d^2)/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*b*d*g+1/(a
*e^2-b*d*e+c*d^2)/e*ln(e*x+d)*d^2*h-1/(a*e^2-b*d*e+c*d^2)*ln(e*x+d)*d*g+1/(a*e^2-b*d*e+c*d^2)*e*ln(e*x+d)*f

________________________________________________________________________________________

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((h*x^2+g*x+f)/(e*x+d)/(c*x^2+b*x+a),x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

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

[In]

integrate((h*x^2+g*x+f)/(e*x+d)/(c*x^2+b*x+a),x, algorithm="fricas")

[Out]

Timed out

________________________________________________________________________________________

Sympy [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

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

[In]

integrate((h*x**2+g*x+f)/(e*x+d)/(c*x**2+b*x+a),x)

[Out]

Timed out

________________________________________________________________________________________

Giac [A]  time = 1.27565, size = 275, normalized size = 1.4 \begin{align*} \frac{{\left (c d g - b d h - c f e + a h e\right )} \log \left (c x^{2} + b x + a\right )}{2 \,{\left (c^{2} d^{2} - b c d e + a c e^{2}\right )}} + \frac{{\left (d^{2} h - d g e + f e^{2}\right )} \log \left ({\left | x e + d \right |}\right )}{c d^{2} e - b d e^{2} + a e^{3}} + \frac{{\left (2 \, c^{2} d f - b c d g + b^{2} d h - 2 \, a c d h - b c f e + 2 \, a c g e - a b h e\right )} \arctan \left (\frac{2 \, c x + b}{\sqrt{-b^{2} + 4 \, a c}}\right )}{{\left (c^{2} d^{2} - b c d e + a c e^{2}\right )} \sqrt{-b^{2} + 4 \, a c}} \end{align*}

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

[In]

integrate((h*x^2+g*x+f)/(e*x+d)/(c*x^2+b*x+a),x, algorithm="giac")

[Out]

1/2*(c*d*g - b*d*h - c*f*e + a*h*e)*log(c*x^2 + b*x + a)/(c^2*d^2 - b*c*d*e + a*c*e^2) + (d^2*h - d*g*e + f*e^
2)*log(abs(x*e + d))/(c*d^2*e - b*d*e^2 + a*e^3) + (2*c^2*d*f - b*c*d*g + b^2*d*h - 2*a*c*d*h - b*c*f*e + 2*a*
c*g*e - a*b*h*e)*arctan((2*c*x + b)/sqrt(-b^2 + 4*a*c))/((c^2*d^2 - b*c*d*e + a*c*e^2)*sqrt(-b^2 + 4*a*c))