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

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

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.760674, antiderivative size = 316, 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 (2 a^2 e^2 h-c \left (2 a \left (d^2 h-2 d e g+e^2 f\right )+b d (d g+2 e f)\right )-a b e (2 d h+e g)+b^2 \left (d^2 h+e^2 f\right )+2 c^2 d^2 f\right )}{\sqrt{b^2-4 a c} \left (a e^2-b d e+c d^2\right )^2}-\frac{\log \left (a+b x+c x^2\right ) \left (a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )+c d (2 e f-d g)\right )}{2 \left (a e^2-b d e+c d^2\right )^2}-\frac{d^2 h-d e g+e^2 f}{e (d+e x) \left (a e^2-b d e+c d^2\right )}+\frac{\log (d+e x) \left (a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )+c d (2 e f-d g)\right )}{\left (a e^2-b d e+c d^2\right )^2}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

-((e^2*f - d*e*g + d^2*h)/(e*(c*d^2 - b*d*e + a*e^2)*(d + e*x))) - ((2*c^2*d^2*f + 2*a^2*e^2*h - a*b*e*(e*g +
2*d*h) + b^2*(e^2*f + d^2*h) - c*(b*d*(2*e*f + d*g) + 2*a*(e^2*f - 2*d*e*g + d^2*h)))*ArcTanh[(b + 2*c*x)/Sqrt
[b^2 - 4*a*c]])/(Sqrt[b^2 - 4*a*c]*(c*d^2 - b*d*e + a*e^2)^2) + ((c*d*(2*e*f - d*g) + a*e*(e*g - 2*d*h) - b*(e
^2*f - d^2*h))*Log[d + e*x])/(c*d^2 - b*d*e + a*e^2)^2 - ((c*d*(2*e*f - d*g) + a*e*(e*g - 2*d*h) - b*(e^2*f -
d^2*h))*Log[a + b*x + c*x^2])/(2*(c*d^2 - b*d*e + a*e^2)^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)^2 \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)^2}+\frac{e \left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right )}{\left (c d^2-b d e+a e^2\right )^2 (d+e x)}+\frac{c^2 d^2 f+e^2 \left (b^2 f-a b g+a^2 h\right )-c \left (2 b d e f+a \left (e^2 f-2 d e g+d^2 h\right )\right )-c \left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) x}{\left (c d^2-b d e+a e^2\right )^2 \left (a+b x+c x^2\right )}\right ) \, dx\\ &=-\frac{e^2 f-d e g+d^2 h}{e \left (c d^2-b d e+a e^2\right ) (d+e x)}+\frac{\left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) \log (d+e x)}{\left (c d^2-b d e+a e^2\right )^2}+\frac{\int \frac{c^2 d^2 f+e^2 \left (b^2 f-a b g+a^2 h\right )-c \left (2 b d e f+a \left (e^2 f-2 d e g+d^2 h\right )\right )-c \left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) x}{a+b x+c x^2} \, dx}{\left (c d^2-b d e+a e^2\right )^2}\\ &=-\frac{e^2 f-d e g+d^2 h}{e \left (c d^2-b d e+a e^2\right ) (d+e x)}+\frac{\left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) \log (d+e x)}{\left (c d^2-b d e+a e^2\right )^2}-\frac{\left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) \int \frac{b+2 c x}{a+b x+c x^2} \, dx}{2 \left (c d^2-b d e+a e^2\right )^2}+\frac{\left (2 c^2 d^2 f+2 a^2 e^2 h-a b e (e g+2 d h)+b^2 \left (e^2 f+d^2 h\right )-c \left (b d (2 e f+d g)+2 a \left (e^2 f-2 d e g+d^2 h\right )\right )\right ) \int \frac{1}{a+b x+c x^2} \, dx}{2 \left (c d^2-b d e+a e^2\right )^2}\\ &=-\frac{e^2 f-d e g+d^2 h}{e \left (c d^2-b d e+a e^2\right ) (d+e x)}+\frac{\left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) \log (d+e x)}{\left (c d^2-b d e+a e^2\right )^2}-\frac{\left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) \log \left (a+b x+c x^2\right )}{2 \left (c d^2-b d e+a e^2\right )^2}-\frac{\left (2 c^2 d^2 f+2 a^2 e^2 h-a b e (e g+2 d h)+b^2 \left (e^2 f+d^2 h\right )-c \left (b d (2 e f+d g)+2 a \left (e^2 f-2 d e g+d^2 h\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{b^2-4 a c-x^2} \, dx,x,b+2 c x\right )}{\left (c d^2-b d e+a e^2\right )^2}\\ &=-\frac{e^2 f-d e g+d^2 h}{e \left (c d^2-b d e+a e^2\right ) (d+e x)}-\frac{\left (2 c^2 d^2 f+2 a^2 e^2 h-a b e (e g+2 d h)+b^2 \left (e^2 f+d^2 h\right )-c \left (b d (2 e f+d g)+2 a \left (e^2 f-2 d e g+d^2 h\right )\right )\right ) \tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right )}{\sqrt{b^2-4 a c} \left (c d^2-b d e+a e^2\right )^2}+\frac{\left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) \log (d+e x)}{\left (c d^2-b d e+a e^2\right )^2}-\frac{\left (c d (2 e f-d g)+a e (e g-2 d h)-b \left (e^2 f-d^2 h\right )\right ) \log \left (a+b x+c x^2\right )}{2 \left (c d^2-b d e+a e^2\right )^2}\\ \end{align*}

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

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [B]  time = 0.192, size = 1125, normalized size = 3.6 \begin{align*} \text{result too large to display} \end{align*}

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

[In]

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

[Out]

-1/(a*e^2-b*d*e+c*d^2)^2*ln(e*x+d)*b*e^2*f-1/(a*e^2-b*d*e+c*d^2)^2*ln(e*x+d)*c*d^2*g+4/(a*e^2-b*d*e+c*d^2)^2/(
4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*a*c*d*e*g-2/(a*e^2-b*d*e+c*d^2)^2/(4*a*c-b^2)^(1/2)*arcta
n((2*c*x+b)/(4*a*c-b^2)^(1/2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2)^2/(4*a*c-b^2)^(1/2)*arc
tan((2*c*x+b)/(4*a*c-b^2)^(1/2))*b^2*d^2*h+1/(a*e^2-b*d*e+c*d^2)^2/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b
^2)^(1/2))*b^2*e^2*f+2/(a*e^2-b*d*e+c*d^2)^2/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*c^2*d^2*f-2
/(a*e^2-b*d*e+c*d^2)^2*ln(e*x+d)*a*d*e*h+2/(a*e^2-b*d*e+c*d^2)^2*ln(e*x+d)*d*e*c*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)^2/(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)^2/(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)**2/(c*x**2+b*x+a),x)

[Out]

Timed out

________________________________________________________________________________________

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

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

[In]

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

[Out]

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