\(\int (a+b \log (c x^n))^2 \log (d (e+f x)^m) \, dx\) [86]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [C] (warning: unable to verify)
Fricas [F]
Sympy [F(-1)]
Maxima [F]
Giac [F]
Mupad [F(-1)]
Reduce [F]

Optimal result

Integrand size = 23, antiderivative size = 288 \[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=2 a b m n x-4 b^2 m n^2 x+2 b m n (a-b n) x+4 b^2 m n x \log \left (c x^n\right )-m x \left (a+b \log \left (c x^n\right )\right )^2-\frac {2 b e m n (a-b n) \log (e+f x)}{f}-2 a b n x \log \left (d (e+f x)^m\right )+2 b^2 n^2 x \log \left (d (e+f x)^m\right )-2 b^2 n x \log \left (c x^n\right ) \log \left (d (e+f x)^m\right )+x \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right )-\frac {2 b^2 e m n \log \left (c x^n\right ) \log \left (1+\frac {f x}{e}\right )}{f}+\frac {e m \left (a+b \log \left (c x^n\right )\right )^2 \log \left (1+\frac {f x}{e}\right )}{f}-\frac {2 b^2 e m n^2 \operatorname {PolyLog}\left (2,-\frac {f x}{e}\right )}{f}+\frac {2 b e m n \left (a+b \log \left (c x^n\right )\right ) \operatorname {PolyLog}\left (2,-\frac {f x}{e}\right )}{f}-\frac {2 b^2 e m n^2 \operatorname {PolyLog}\left (3,-\frac {f x}{e}\right )}{f} \] Output:

2*a*b*m*n*x-4*b^2*m*n^2*x+2*b*m*n*(-b*n+a)*x+4*b^2*m*n*x*ln(c*x^n)-m*x*(a+ 
b*ln(c*x^n))^2-2*b*e*m*n*(-b*n+a)*ln(f*x+e)/f-2*a*b*n*x*ln(d*(f*x+e)^m)+2* 
b^2*n^2*x*ln(d*(f*x+e)^m)-2*b^2*n*x*ln(c*x^n)*ln(d*(f*x+e)^m)+x*(a+b*ln(c* 
x^n))^2*ln(d*(f*x+e)^m)-2*b^2*e*m*n*ln(c*x^n)*ln(1+f*x/e)/f+e*m*(a+b*ln(c* 
x^n))^2*ln(1+f*x/e)/f-2*b^2*e*m*n^2*polylog(2,-f*x/e)/f+2*b*e*m*n*(a+b*ln( 
c*x^n))*polylog(2,-f*x/e)/f-2*b^2*e*m*n^2*polylog(3,-f*x/e)/f
 

Mathematica [A] (verified)

Time = 0.22 (sec) , antiderivative size = 507, normalized size of antiderivative = 1.76 \[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=\frac {-a^2 f m x+4 a b f m n x-6 b^2 f m n^2 x-2 a b f m x \log \left (c x^n\right )+4 b^2 f m n x \log \left (c x^n\right )-b^2 f m x \log ^2\left (c x^n\right )+a^2 e m \log (e+f x)-2 a b e m n \log (e+f x)+2 b^2 e m n^2 \log (e+f x)-2 a b e m n \log (x) \log (e+f x)+2 b^2 e m n^2 \log (x) \log (e+f x)+b^2 e m n^2 \log ^2(x) \log (e+f x)+2 a b e m \log \left (c x^n\right ) \log (e+f x)-2 b^2 e m n \log \left (c x^n\right ) \log (e+f x)-2 b^2 e m n \log (x) \log \left (c x^n\right ) \log (e+f x)+b^2 e m \log ^2\left (c x^n\right ) \log (e+f x)+a^2 f x \log \left (d (e+f x)^m\right )-2 a b f n x \log \left (d (e+f x)^m\right )+2 b^2 f n^2 x \log \left (d (e+f x)^m\right )+2 a b f x \log \left (c x^n\right ) \log \left (d (e+f x)^m\right )-2 b^2 f n x \log \left (c x^n\right ) \log \left (d (e+f x)^m\right )+b^2 f x \log ^2\left (c x^n\right ) \log \left (d (e+f x)^m\right )+2 a b e m n \log (x) \log \left (1+\frac {f x}{e}\right )-2 b^2 e m n^2 \log (x) \log \left (1+\frac {f x}{e}\right )-b^2 e m n^2 \log ^2(x) \log \left (1+\frac {f x}{e}\right )+2 b^2 e m n \log (x) \log \left (c x^n\right ) \log \left (1+\frac {f x}{e}\right )+2 b e m n \left (a-b n+b \log \left (c x^n\right )\right ) \operatorname {PolyLog}\left (2,-\frac {f x}{e}\right )-2 b^2 e m n^2 \operatorname {PolyLog}\left (3,-\frac {f x}{e}\right )}{f} \] Input:

Integrate[(a + b*Log[c*x^n])^2*Log[d*(e + f*x)^m],x]
 

Output:

(-(a^2*f*m*x) + 4*a*b*f*m*n*x - 6*b^2*f*m*n^2*x - 2*a*b*f*m*x*Log[c*x^n] + 
 4*b^2*f*m*n*x*Log[c*x^n] - b^2*f*m*x*Log[c*x^n]^2 + a^2*e*m*Log[e + f*x] 
- 2*a*b*e*m*n*Log[e + f*x] + 2*b^2*e*m*n^2*Log[e + f*x] - 2*a*b*e*m*n*Log[ 
x]*Log[e + f*x] + 2*b^2*e*m*n^2*Log[x]*Log[e + f*x] + b^2*e*m*n^2*Log[x]^2 
*Log[e + f*x] + 2*a*b*e*m*Log[c*x^n]*Log[e + f*x] - 2*b^2*e*m*n*Log[c*x^n] 
*Log[e + f*x] - 2*b^2*e*m*n*Log[x]*Log[c*x^n]*Log[e + f*x] + b^2*e*m*Log[c 
*x^n]^2*Log[e + f*x] + a^2*f*x*Log[d*(e + f*x)^m] - 2*a*b*f*n*x*Log[d*(e + 
 f*x)^m] + 2*b^2*f*n^2*x*Log[d*(e + f*x)^m] + 2*a*b*f*x*Log[c*x^n]*Log[d*( 
e + f*x)^m] - 2*b^2*f*n*x*Log[c*x^n]*Log[d*(e + f*x)^m] + b^2*f*x*Log[c*x^ 
n]^2*Log[d*(e + f*x)^m] + 2*a*b*e*m*n*Log[x]*Log[1 + (f*x)/e] - 2*b^2*e*m* 
n^2*Log[x]*Log[1 + (f*x)/e] - b^2*e*m*n^2*Log[x]^2*Log[1 + (f*x)/e] + 2*b^ 
2*e*m*n*Log[x]*Log[c*x^n]*Log[1 + (f*x)/e] + 2*b*e*m*n*(a - b*n + b*Log[c* 
x^n])*PolyLog[2, -((f*x)/e)] - 2*b^2*e*m*n^2*PolyLog[3, -((f*x)/e)])/f
 

Rubi [A] (verified)

Time = 0.65 (sec) , antiderivative size = 297, normalized size of antiderivative = 1.03, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.130, Rules used = {2818, 6, 2009}

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 \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx\)

\(\Big \downarrow \) 2818

\(\displaystyle -f m \int \left (-\frac {2 n x \log \left (c x^n\right ) b^2}{e+f x}+\frac {2 n^2 x b^2}{e+f x}-\frac {2 a n x b}{e+f x}+\frac {x \left (a+b \log \left (c x^n\right )\right )^2}{e+f x}\right )dx+x \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right )-2 a b n x \log \left (d (e+f x)^m\right )-2 b^2 n x \log \left (c x^n\right ) \log \left (d (e+f x)^m\right )+2 b^2 n^2 x \log \left (d (e+f x)^m\right )\)

\(\Big \downarrow \) 6

\(\displaystyle -f m \int \left (-\frac {2 n x \log \left (c x^n\right ) b^2}{e+f x}+\frac {x \left (a+b \log \left (c x^n\right )\right )^2}{e+f x}+\frac {\left (2 b^2 n^2-2 a b n\right ) x}{e+f x}\right )dx+x \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right )-2 a b n x \log \left (d (e+f x)^m\right )-2 b^2 n x \log \left (c x^n\right ) \log \left (d (e+f x)^m\right )+2 b^2 n^2 x \log \left (d (e+f x)^m\right )\)

\(\Big \downarrow \) 2009

\(\displaystyle -f m \left (-\frac {2 b e n \operatorname {PolyLog}\left (2,-\frac {f x}{e}\right ) \left (a+b \log \left (c x^n\right )\right )}{f^2}-\frac {e \log \left (\frac {f x}{e}+1\right ) \left (a+b \log \left (c x^n\right )\right )^2}{f^2}+\frac {x \left (a+b \log \left (c x^n\right )\right )^2}{f}+\frac {2 b e n (a-b n) \log (e+f x)}{f^2}-\frac {2 a b n x}{f}-\frac {2 b n x (a-b n)}{f}+\frac {2 b^2 e n \log \left (c x^n\right ) \log \left (\frac {f x}{e}+1\right )}{f^2}-\frac {4 b^2 n x \log \left (c x^n\right )}{f}+\frac {2 b^2 e n^2 \operatorname {PolyLog}\left (2,-\frac {f x}{e}\right )}{f^2}+\frac {2 b^2 e n^2 \operatorname {PolyLog}\left (3,-\frac {f x}{e}\right )}{f^2}+\frac {4 b^2 n^2 x}{f}\right )+x \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right )-2 a b n x \log \left (d (e+f x)^m\right )-2 b^2 n x \log \left (c x^n\right ) \log \left (d (e+f x)^m\right )+2 b^2 n^2 x \log \left (d (e+f x)^m\right )\)

Input:

Int[(a + b*Log[c*x^n])^2*Log[d*(e + f*x)^m],x]
 

Output:

-2*a*b*n*x*Log[d*(e + f*x)^m] + 2*b^2*n^2*x*Log[d*(e + f*x)^m] - 2*b^2*n*x 
*Log[c*x^n]*Log[d*(e + f*x)^m] + x*(a + b*Log[c*x^n])^2*Log[d*(e + f*x)^m] 
 - f*m*((-2*a*b*n*x)/f + (4*b^2*n^2*x)/f - (2*b*n*(a - b*n)*x)/f - (4*b^2* 
n*x*Log[c*x^n])/f + (x*(a + b*Log[c*x^n])^2)/f + (2*b*e*n*(a - b*n)*Log[e 
+ f*x])/f^2 + (2*b^2*e*n*Log[c*x^n]*Log[1 + (f*x)/e])/f^2 - (e*(a + b*Log[ 
c*x^n])^2*Log[1 + (f*x)/e])/f^2 + (2*b^2*e*n^2*PolyLog[2, -((f*x)/e)])/f^2 
 - (2*b*e*n*(a + b*Log[c*x^n])*PolyLog[2, -((f*x)/e)])/f^2 + (2*b^2*e*n^2* 
PolyLog[3, -((f*x)/e)])/f^2)
 

Defintions of rubi rules used

rule 6
Int[(u_.)*((v_.) + (a_.)*(Fx_) + (b_.)*(Fx_))^(p_.), x_Symbol] :> Int[u*(v 
+ (a + b)*Fx)^p, x] /; FreeQ[{a, b}, x] &&  !FreeQ[Fx, x]
 

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 2818
Int[Log[(d_.)*((e_) + (f_.)*(x_)^(m_.))^(r_.)]*((a_.) + Log[(c_.)*(x_)^(n_. 
)]*(b_.))^(p_.), x_Symbol] :> With[{u = IntHide[(a + b*Log[c*x^n])^p, x]}, 
Simp[Log[d*(e + f*x^m)^r]   u, x] - Simp[f*m*r   Int[x^(m - 1)/(e + f*x^m) 
  u, x], x]] /; FreeQ[{a, b, c, d, e, f, r, m, n}, x] && IGtQ[p, 0] && Inte 
gerQ[m]
 
Maple [C] (warning: unable to verify)

Result contains higher order function than in optimal. Order 9 vs. order 4.

Time = 72.06 (sec) , antiderivative size = 3710, normalized size of antiderivative = 12.88

method result size
risch \(\text {Expression too large to display}\) \(3710\)

Input:

int((a+b*ln(c*x^n))^2*ln(d*(f*x+e)^m),x,method=_RETURNVERBOSE)
 

Output:

-2*m*b*ln(x^n)*x*a+(-1/8*I*Pi*csgn(I*d)*csgn(I*(f*x+e)^m)*csgn(I*d*(f*x+e) 
^m)+1/8*I*Pi*csgn(I*d)*csgn(I*d*(f*x+e)^m)^2+1/8*I*Pi*csgn(I*(f*x+e)^m)*cs 
gn(I*d*(f*x+e)^m)^2-1/8*I*Pi*csgn(I*d*(f*x+e)^m)^3+1/4*ln(d))*((I*Pi*b*csg 
n(I*x^n)*csgn(I*c*x^n)^2-I*Pi*b*csgn(I*x^n)*csgn(I*c*x^n)*csgn(I*c)-I*Pi*b 
*csgn(I*c*x^n)^3+I*Pi*b*csgn(I*c*x^n)^2*csgn(I*c)+2*b*ln(c)+2*a)^2*x+4*b^2 
*x*ln(x^n)^2-8*b^2*x*ln(x^n)*n+8*b^2*n^2*x+4*(I*Pi*b*csgn(I*x^n)*csgn(I*c* 
x^n)^2-I*Pi*b*csgn(I*x^n)*csgn(I*c*x^n)*csgn(I*c)-I*Pi*b*csgn(I*c*x^n)^3+I 
*Pi*b*csgn(I*c*x^n)^2*csgn(I*c)+2*b*ln(c)+2*a)*b*(x*ln(x^n)-x*n))+a^2*m/f* 
e*ln(f*x+e)+1/4*m*x*Pi^2*b^2*csgn(I*c*x^n)^6-2*m*ln(x^n)*x*b^2*ln(c)+4*m*n 
*x*b^2*ln(c)+4*m*b^2*n*ln(x^n)*x-m*b^2*ln(x^n)^2*x-2*m*x*ln(c)*a*b+(b^2*x* 
ln(x^n)^2+x*b*(I*Pi*b*csgn(I*x^n)*csgn(I*c*x^n)^2-I*Pi*b*csgn(I*x^n)*csgn( 
I*c*x^n)*csgn(I*c)-I*Pi*b*csgn(I*c*x^n)^3+I*Pi*b*csgn(I*c*x^n)^2*csgn(I*c) 
+2*b*ln(c)-2*n*b+2*a)*ln(x^n)+1/4*x*(2*Pi^2*b^2*csgn(I*x^n)^2*csgn(I*c*x^n 
)^3*csgn(I*c)-Pi^2*b^2*csgn(I*x^n)^2*csgn(I*c*x^n)^2*csgn(I*c)^2-4*Pi^2*b^ 
2*csgn(I*x^n)*csgn(I*c*x^n)^4*csgn(I*c)+4*I*Pi*a*b*csgn(I*x^n)*csgn(I*c*x^ 
n)^2+4*I*Pi*ln(c)*b^2*csgn(I*c*x^n)^2*csgn(I*c)-8*b^2*ln(c)*n+8*a*b*ln(c)+ 
4*a^2+4*I*Pi*a*b*csgn(I*c*x^n)^2*csgn(I*c)+4*b^2*ln(c)^2+8*b^2*n^2-4*I*Pi* 
ln(c)*b^2*csgn(I*c*x^n)^3+2*Pi^2*b^2*csgn(I*c*x^n)^5*csgn(I*c)-Pi^2*b^2*cs 
gn(I*c*x^n)^4*csgn(I*c)^2-Pi^2*b^2*csgn(I*x^n)^2*csgn(I*c*x^n)^4+2*Pi^2*b^ 
2*csgn(I*x^n)*csgn(I*c*x^n)^5-4*I*Pi*a*b*csgn(I*x^n)*csgn(I*c*x^n)*csgn...
 

Fricas [F]

\[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=\int { {\left (b \log \left (c x^{n}\right ) + a\right )}^{2} \log \left ({\left (f x + e\right )}^{m} d\right ) \,d x } \] Input:

integrate((a+b*log(c*x^n))^2*log(d*(f*x+e)^m),x, algorithm="fricas")
 

Output:

integral((b^2*log(c*x^n)^2 + 2*a*b*log(c*x^n) + a^2)*log((f*x + e)^m*d), x 
)
 

Sympy [F(-1)]

Timed out. \[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=\text {Timed out} \] Input:

integrate((a+b*ln(c*x**n))**2*ln(d*(f*x+e)**m),x)
 

Output:

Timed out
 

Maxima [F]

\[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=\int { {\left (b \log \left (c x^{n}\right ) + a\right )}^{2} \log \left ({\left (f x + e\right )}^{m} d\right ) \,d x } \] Input:

integrate((a+b*log(c*x^n))^2*log(d*(f*x+e)^m),x, algorithm="maxima")
 

Output:

((b^2*e*m*log(f*x + e) - (f*m - f*log(d))*b^2*x)*log(x^n)^2 + (b^2*f*x*log 
(x^n)^2 - 2*((f*n - f*log(c))*b^2 - a*b*f)*x*log(x^n) - (2*(f*n - f*log(c) 
)*a*b - (2*f*n^2 - 2*f*n*log(c) + f*log(c)^2)*b^2 - a^2*f)*x)*log((f*x + e 
)^m))/f - integrate((((f^2*m - f^2*log(d))*a^2 - 2*(f^2*m*n - (f^2*m - f^2 
*log(d))*log(c))*a*b + (2*f^2*m*n^2 - 2*f^2*m*n*log(c) + (f^2*m - f^2*log( 
d))*log(c)^2)*b^2)*x^2 - (b^2*e*f*log(c)^2*log(d) + 2*a*b*e*f*log(c)*log(d 
) + a^2*e*f*log(d))*x + 2*(((f^2*m - f^2*log(d))*a*b - (2*f^2*m*n - f^2*n* 
log(d) - (f^2*m - f^2*log(d))*log(c))*b^2)*x^2 - (a*b*e*f*log(d) + (e*f*m* 
n - e*f*n*log(d) + e*f*log(c)*log(d))*b^2)*x + (b^2*e*f*m*n*x + b^2*e^2*m* 
n)*log(f*x + e))*log(x^n))/(f^2*x^2 + e*f*x), x)
 

Giac [F]

\[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=\int { {\left (b \log \left (c x^{n}\right ) + a\right )}^{2} \log \left ({\left (f x + e\right )}^{m} d\right ) \,d x } \] Input:

integrate((a+b*log(c*x^n))^2*log(d*(f*x+e)^m),x, algorithm="giac")
 

Output:

integrate((b*log(c*x^n) + a)^2*log((f*x + e)^m*d), x)
 

Mupad [F(-1)]

Timed out. \[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=\int \ln \left (d\,{\left (e+f\,x\right )}^m\right )\,{\left (a+b\,\ln \left (c\,x^n\right )\right )}^2 \,d x \] Input:

int(log(d*(e + f*x)^m)*(a + b*log(c*x^n))^2,x)
 

Output:

int(log(d*(e + f*x)^m)*(a + b*log(c*x^n))^2, x)
 

Reduce [F]

\[ \int \left (a+b \log \left (c x^n\right )\right )^2 \log \left (d (e+f x)^m\right ) \, dx=\frac {-3 \left (\int \frac {\mathrm {log}\left (x^{n} c \right )^{2}}{f \,x^{2}+e x}d x \right ) b^{2} e^{2} m n -6 \left (\int \frac {\mathrm {log}\left (x^{n} c \right )}{f \,x^{2}+e x}d x \right ) a b \,e^{2} m n +6 \left (\int \frac {\mathrm {log}\left (x^{n} c \right )}{f \,x^{2}+e x}d x \right ) b^{2} e^{2} m \,n^{2}+3 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) \mathrm {log}\left (x^{n} c \right )^{2} b^{2} f n x +6 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) \mathrm {log}\left (x^{n} c \right ) a b f n x -6 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) \mathrm {log}\left (x^{n} c \right ) b^{2} f \,n^{2} x +3 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) a^{2} e n +3 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) a^{2} f n x -6 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) a b e \,n^{2}-6 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) a b f \,n^{2} x +6 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) b^{2} e \,n^{3}+6 \,\mathrm {log}\left (\left (f x +e \right )^{m} d \right ) b^{2} f \,n^{3} x +\mathrm {log}\left (x^{n} c \right )^{3} b^{2} e m +3 \mathrm {log}\left (x^{n} c \right )^{2} a b e m -3 \mathrm {log}\left (x^{n} c \right )^{2} b^{2} e m n -3 \mathrm {log}\left (x^{n} c \right )^{2} b^{2} f m n x -6 \,\mathrm {log}\left (x^{n} c \right ) a b f m n x +12 \,\mathrm {log}\left (x^{n} c \right ) b^{2} f m \,n^{2} x -3 a^{2} f m n x +12 a b f m \,n^{2} x -18 b^{2} f m \,n^{3} x}{3 f n} \] Input:

int((a+b*log(c*x^n))^2*log(d*(f*x+e)^m),x)
 

Output:

( - 3*int(log(x**n*c)**2/(e*x + f*x**2),x)*b**2*e**2*m*n - 6*int(log(x**n* 
c)/(e*x + f*x**2),x)*a*b*e**2*m*n + 6*int(log(x**n*c)/(e*x + f*x**2),x)*b* 
*2*e**2*m*n**2 + 3*log((e + f*x)**m*d)*log(x**n*c)**2*b**2*f*n*x + 6*log(( 
e + f*x)**m*d)*log(x**n*c)*a*b*f*n*x - 6*log((e + f*x)**m*d)*log(x**n*c)*b 
**2*f*n**2*x + 3*log((e + f*x)**m*d)*a**2*e*n + 3*log((e + f*x)**m*d)*a**2 
*f*n*x - 6*log((e + f*x)**m*d)*a*b*e*n**2 - 6*log((e + f*x)**m*d)*a*b*f*n* 
*2*x + 6*log((e + f*x)**m*d)*b**2*e*n**3 + 6*log((e + f*x)**m*d)*b**2*f*n* 
*3*x + log(x**n*c)**3*b**2*e*m + 3*log(x**n*c)**2*a*b*e*m - 3*log(x**n*c)* 
*2*b**2*e*m*n - 3*log(x**n*c)**2*b**2*f*m*n*x - 6*log(x**n*c)*a*b*f*m*n*x 
+ 12*log(x**n*c)*b**2*f*m*n**2*x - 3*a**2*f*m*n*x + 12*a*b*f*m*n**2*x - 18 
*b**2*f*m*n**3*x)/(3*f*n)