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

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

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.0979572, antiderivative size = 118, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 4, integrand size = 23, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.174, Rules used = {1660, 12, 618, 206} $\frac{c \left (2 a g-b \left (\frac{a h}{c}+f\right )\right )-x \left (-2 a c h+b^2 h-b c g+2 c^2 f\right )}{c \left (b^2-4 a c\right ) \left (a+b x+c x^2\right )}+\frac{2 \tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right ) (2 a h-b g+2 c f)}{\left (b^2-4 a c\right )^{3/2}}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

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

Rule 1660

Int[(Pq_)*((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_), x_Symbol] :> With[{Q = PolynomialQuotient[Pq, a + b*x + c*
x^2, x], f = Coeff[PolynomialRemainder[Pq, a + b*x + c*x^2, x], x, 0], g = Coeff[PolynomialRemainder[Pq, a + b
*x + c*x^2, x], x, 1]}, Simp[((b*f - 2*a*g + (2*c*f - b*g)*x)*(a + b*x + c*x^2)^(p + 1))/((p + 1)*(b^2 - 4*a*c
)), x] + Dist[1/((p + 1)*(b^2 - 4*a*c)), Int[(a + b*x + c*x^2)^(p + 1)*ExpandToSum[(p + 1)*(b^2 - 4*a*c)*Q - (
2*p + 3)*(2*c*f - b*g), x], x], x]] /; FreeQ[{a, b, c}, x] && PolyQ[Pq, x] && NeQ[b^2 - 4*a*c, 0] && LtQ[p, -1
]

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

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])

Rubi steps

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

Mathematica [A]  time = 0.114411, size = 114, normalized size = 0.97 $\frac{a b h-2 a c (g+h x)+b^2 h x+b c (f-g x)+2 c^2 f x}{c \left (4 a c-b^2\right ) (a+x (b+c x))}-\frac{2 \tan ^{-1}\left (\frac{b+2 c x}{\sqrt{4 a c-b^2}}\right ) (-2 a h+b g-2 c f)}{\left (4 a c-b^2\right )^{3/2}}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [A]  time = 0.187, size = 194, normalized size = 1.6 \begin{align*}{\frac{1}{c{x}^{2}+bx+a} \left ( -{\frac{ \left ( 2\,ach-{b}^{2}h+bcg-2\,{c}^{2}f \right ) x}{c \left ( 4\,ac-{b}^{2} \right ) }}+{\frac{abh-2\,acg+bcf}{c \left ( 4\,ac-{b}^{2} \right ) }} \right ) }+4\,{\frac{ah}{ \left ( 4\,ac-{b}^{2} \right ) ^{3/2}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) }-2\,{\frac{bg}{ \left ( 4\,ac-{b}^{2} \right ) ^{3/2}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) }+4\,{\frac{cf}{ \left ( 4\,ac-{b}^{2} \right ) ^{3/2}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) } \end{align*}

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

[In]

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

[Out]

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

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [B]  time = 1.5575, size = 1335, normalized size = 11.31 \begin{align*} \left [-\frac{{\left (2 \, a c^{2} f - a b c g + 2 \, a^{2} c h +{\left (2 \, c^{3} f - b c^{2} g + 2 \, a c^{2} h\right )} x^{2} +{\left (2 \, b c^{2} f - b^{2} c g + 2 \, a b c h\right )} x\right )} \sqrt{b^{2} - 4 \, a c} \log \left (\frac{2 \, c^{2} x^{2} + 2 \, b c x + b^{2} - 2 \, a c - \sqrt{b^{2} - 4 \, a c}{\left (2 \, c x + b\right )}}{c x^{2} + b x + a}\right ) +{\left (b^{3} c - 4 \, a b c^{2}\right )} f - 2 \,{\left (a b^{2} c - 4 \, a^{2} c^{2}\right )} g +{\left (a b^{3} - 4 \, a^{2} b c\right )} h +{\left (2 \,{\left (b^{2} c^{2} - 4 \, a c^{3}\right )} f -{\left (b^{3} c - 4 \, a b c^{2}\right )} g +{\left (b^{4} - 6 \, a b^{2} c + 8 \, a^{2} c^{2}\right )} h\right )} x}{a b^{4} c - 8 \, a^{2} b^{2} c^{2} + 16 \, a^{3} c^{3} +{\left (b^{4} c^{2} - 8 \, a b^{2} c^{3} + 16 \, a^{2} c^{4}\right )} x^{2} +{\left (b^{5} c - 8 \, a b^{3} c^{2} + 16 \, a^{2} b c^{3}\right )} x}, \frac{2 \,{\left (2 \, a c^{2} f - a b c g + 2 \, a^{2} c h +{\left (2 \, c^{3} f - b c^{2} g + 2 \, a c^{2} h\right )} x^{2} +{\left (2 \, b c^{2} f - b^{2} c g + 2 \, a b c h\right )} x\right )} \sqrt{-b^{2} + 4 \, a c} \arctan \left (-\frac{\sqrt{-b^{2} + 4 \, a c}{\left (2 \, c x + b\right )}}{b^{2} - 4 \, a c}\right ) -{\left (b^{3} c - 4 \, a b c^{2}\right )} f + 2 \,{\left (a b^{2} c - 4 \, a^{2} c^{2}\right )} g -{\left (a b^{3} - 4 \, a^{2} b c\right )} h -{\left (2 \,{\left (b^{2} c^{2} - 4 \, a c^{3}\right )} f -{\left (b^{3} c - 4 \, a b c^{2}\right )} g +{\left (b^{4} - 6 \, a b^{2} c + 8 \, a^{2} c^{2}\right )} h\right )} x}{a b^{4} c - 8 \, a^{2} b^{2} c^{2} + 16 \, a^{3} c^{3} +{\left (b^{4} c^{2} - 8 \, a b^{2} c^{3} + 16 \, a^{2} c^{4}\right )} x^{2} +{\left (b^{5} c - 8 \, a b^{3} c^{2} + 16 \, a^{2} b c^{3}\right )} x}\right ] \end{align*}

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

[In]

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

[Out]

[-((2*a*c^2*f - a*b*c*g + 2*a^2*c*h + (2*c^3*f - b*c^2*g + 2*a*c^2*h)*x^2 + (2*b*c^2*f - b^2*c*g + 2*a*b*c*h)*
x)*sqrt(b^2 - 4*a*c)*log((2*c^2*x^2 + 2*b*c*x + b^2 - 2*a*c - sqrt(b^2 - 4*a*c)*(2*c*x + b))/(c*x^2 + b*x + a)
) + (b^3*c - 4*a*b*c^2)*f - 2*(a*b^2*c - 4*a^2*c^2)*g + (a*b^3 - 4*a^2*b*c)*h + (2*(b^2*c^2 - 4*a*c^3)*f - (b^
3*c - 4*a*b*c^2)*g + (b^4 - 6*a*b^2*c + 8*a^2*c^2)*h)*x)/(a*b^4*c - 8*a^2*b^2*c^2 + 16*a^3*c^3 + (b^4*c^2 - 8*
a*b^2*c^3 + 16*a^2*c^4)*x^2 + (b^5*c - 8*a*b^3*c^2 + 16*a^2*b*c^3)*x), (2*(2*a*c^2*f - a*b*c*g + 2*a^2*c*h + (
2*c^3*f - b*c^2*g + 2*a*c^2*h)*x^2 + (2*b*c^2*f - b^2*c*g + 2*a*b*c*h)*x)*sqrt(-b^2 + 4*a*c)*arctan(-sqrt(-b^2
+ 4*a*c)*(2*c*x + b)/(b^2 - 4*a*c)) - (b^3*c - 4*a*b*c^2)*f + 2*(a*b^2*c - 4*a^2*c^2)*g - (a*b^3 - 4*a^2*b*c)
*h - (2*(b^2*c^2 - 4*a*c^3)*f - (b^3*c - 4*a*b*c^2)*g + (b^4 - 6*a*b^2*c + 8*a^2*c^2)*h)*x)/(a*b^4*c - 8*a^2*b
^2*c^2 + 16*a^3*c^3 + (b^4*c^2 - 8*a*b^2*c^3 + 16*a^2*c^4)*x^2 + (b^5*c - 8*a*b^3*c^2 + 16*a^2*b*c^3)*x)]

________________________________________________________________________________________

Sympy [B]  time = 2.31425, size = 459, normalized size = 3.89 \begin{align*} - \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) \log{\left (x + \frac{- 16 a^{2} c^{2} \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) + 8 a b^{2} c \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) + 2 a b h - b^{4} \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) - b^{2} g + 2 b c f}{4 a c h - 2 b c g + 4 c^{2} f} \right )} + \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) \log{\left (x + \frac{16 a^{2} c^{2} \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) - 8 a b^{2} c \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) + 2 a b h + b^{4} \sqrt{- \frac{1}{\left (4 a c - b^{2}\right )^{3}}} \left (2 a h - b g + 2 c f\right ) - b^{2} g + 2 b c f}{4 a c h - 2 b c g + 4 c^{2} f} \right )} - \frac{- a b h + 2 a c g - b c f + x \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{4 a^{2} c^{2} - a b^{2} c + x^{2} \left (4 a c^{3} - b^{2} c^{2}\right ) + x \left (4 a b c^{2} - b^{3} c\right )} \end{align*}

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

[In]

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

[Out]

-sqrt(-1/(4*a*c - b**2)**3)*(2*a*h - b*g + 2*c*f)*log(x + (-16*a**2*c**2*sqrt(-1/(4*a*c - b**2)**3)*(2*a*h - b
*g + 2*c*f) + 8*a*b**2*c*sqrt(-1/(4*a*c - b**2)**3)*(2*a*h - b*g + 2*c*f) + 2*a*b*h - b**4*sqrt(-1/(4*a*c - b*
*2)**3)*(2*a*h - b*g + 2*c*f) - b**2*g + 2*b*c*f)/(4*a*c*h - 2*b*c*g + 4*c**2*f)) + sqrt(-1/(4*a*c - b**2)**3)
*(2*a*h - b*g + 2*c*f)*log(x + (16*a**2*c**2*sqrt(-1/(4*a*c - b**2)**3)*(2*a*h - b*g + 2*c*f) - 8*a*b**2*c*sqr
t(-1/(4*a*c - b**2)**3)*(2*a*h - b*g + 2*c*f) + 2*a*b*h + b**4*sqrt(-1/(4*a*c - b**2)**3)*(2*a*h - b*g + 2*c*f
) - b**2*g + 2*b*c*f)/(4*a*c*h - 2*b*c*g + 4*c**2*f)) - (-a*b*h + 2*a*c*g - b*c*f + x*(2*a*c*h - b**2*h + b*c*
g - 2*c**2*f))/(4*a**2*c**2 - a*b**2*c + x**2*(4*a*c**3 - b**2*c**2) + x*(4*a*b*c**2 - b**3*c))

________________________________________________________________________________________

Giac [A]  time = 1.16536, size = 169, normalized size = 1.43 \begin{align*} -\frac{2 \,{\left (2 \, c f - b g + 2 \, a h\right )} \arctan \left (\frac{2 \, c x + b}{\sqrt{-b^{2} + 4 \, a c}}\right )}{{\left (b^{2} - 4 \, a c\right )} \sqrt{-b^{2} + 4 \, a c}} - \frac{2 \, c^{2} f x - b c g x + b^{2} h x - 2 \, a c h x + b c f - 2 \, a c g + a b h}{{\left (b^{2} c - 4 \, a c^{2}\right )}{\left (c x^{2} + b x + a\right )}} \end{align*}

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

[In]

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

[Out]

-2*(2*c*f - b*g + 2*a*h)*arctan((2*c*x + b)/sqrt(-b^2 + 4*a*c))/((b^2 - 4*a*c)*sqrt(-b^2 + 4*a*c)) - (2*c^2*f*
x - b*c*g*x + b^2*h*x - 2*a*c*h*x + b*c*f - 2*a*c*g + a*b*h)/((b^2*c - 4*a*c^2)*(c*x^2 + b*x + a))