\(\int \cos ^2(a+b x) \cos (c+d x) \, dx\) [335]

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

Optimal result

Integrand size = 15, antiderivative size = 68 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\frac {\sin (2 a-c+(2 b-d) x)}{4 (2 b-d)}+\frac {\sin (c+d x)}{2 d}+\frac {\sin (2 a+c+(2 b+d) x)}{4 (2 b+d)} \] Output:

sin(2*a-c+(2*b-d)*x)/(8*b-4*d)+1/2*sin(d*x+c)/d+sin(2*a+c+(2*b+d)*x)/(8*b+ 
4*d)
 

Mathematica [A] (verified)

Time = 0.51 (sec) , antiderivative size = 74, normalized size of antiderivative = 1.09 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\frac {1}{4} \left (\frac {2 \cos (d x) \sin (c)}{d}+\frac {2 \cos (c) \sin (d x)}{d}+\frac {\sin (2 a-c+2 b x-d x)}{2 b-d}+\frac {\sin (2 a+c+2 b x+d x)}{2 b+d}\right ) \] Input:

Integrate[Cos[a + b*x]^2*Cos[c + d*x],x]
 

Output:

((2*Cos[d*x]*Sin[c])/d + (2*Cos[c]*Sin[d*x])/d + Sin[2*a - c + 2*b*x - d*x 
]/(2*b - d) + Sin[2*a + c + 2*b*x + d*x]/(2*b + d))/4
 

Rubi [A] (verified)

Time = 0.24 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.133, Rules used = {5081, 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 \cos ^2(a+b x) \cos (c+d x) \, dx\)

\(\Big \downarrow \) 5081

\(\displaystyle \int \left (\frac {1}{4} \cos (2 a+x (2 b-d)-c)+\frac {1}{4} \cos (2 a+x (2 b+d)+c)+\frac {1}{2} \cos (c+d x)\right )dx\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {\sin (2 a+x (2 b-d)-c)}{4 (2 b-d)}+\frac {\sin (2 a+x (2 b+d)+c)}{4 (2 b+d)}+\frac {\sin (c+d x)}{2 d}\)

Input:

Int[Cos[a + b*x]^2*Cos[c + d*x],x]
 

Output:

Sin[2*a - c + (2*b - d)*x]/(4*(2*b - d)) + Sin[c + d*x]/(2*d) + Sin[2*a + 
c + (2*b + d)*x]/(4*(2*b + d))
 

Defintions of rubi rules used

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

rule 5081
Int[Cos[v_]^(p_.)*Cos[w_]^(q_.), x_Symbol] :> Int[ExpandTrigReduce[Cos[v]^p 
*Cos[w]^q, x], x] /; ((PolynomialQ[v, x] && PolynomialQ[w, x]) || (Binomial 
Q[{v, w}, x] && IndependentQ[Cancel[v/w], x])) && IGtQ[p, 0] && IGtQ[q, 0]
 
Maple [A] (verified)

Time = 1.69 (sec) , antiderivative size = 63, normalized size of antiderivative = 0.93

method result size
default \(\frac {\sin \left (2 a -c +\left (2 b -d \right ) x \right )}{8 b -4 d}+\frac {\sin \left (d x +c \right )}{2 d}+\frac {\sin \left (2 a +c +\left (2 b +d \right ) x \right )}{8 b +4 d}\) \(63\)
parallelrisch \(\frac {\left (2 b d +d^{2}\right ) \sin \left (2 a -c +\left (2 b -d \right ) x \right )+\left (2 b d -d^{2}\right ) \sin \left (2 a +c +\left (2 b +d \right ) x \right )+\left (8 b^{2}-2 d^{2}\right ) \sin \left (d x +c \right )}{16 b^{2} d -4 d^{3}}\) \(85\)
risch \(\frac {2 \sin \left (d x +c \right ) b^{2}}{d \left (2 b -d \right ) \left (2 b +d \right )}-\frac {d \sin \left (d x +c \right )}{2 \left (2 b -d \right ) \left (2 b +d \right )}+\frac {\sin \left (2 b x -d x +2 a -c \right ) b}{2 \left (2 b -d \right ) \left (2 b +d \right )}+\frac {d \sin \left (2 b x -d x +2 a -c \right )}{4 \left (2 b -d \right ) \left (2 b +d \right )}+\frac {\sin \left (2 b x +d x +2 a +c \right ) b}{2 \left (2 b -d \right ) \left (2 b +d \right )}-\frac {d \sin \left (2 b x +d x +2 a +c \right )}{4 \left (2 b -d \right ) \left (2 b +d \right )}\) \(191\)
norman \(\frac {\frac {4 b \tan \left (\frac {a}{2}+\frac {b x}{2}\right )}{4 b^{2}-d^{2}}-\frac {4 b \tan \left (\frac {a}{2}+\frac {b x}{2}\right )^{3}}{4 b^{2}-d^{2}}-\frac {4 b \tan \left (\frac {a}{2}+\frac {b x}{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}}{4 b^{2}-d^{2}}+\frac {4 b \tan \left (\frac {a}{2}+\frac {b x}{2}\right )^{3} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}}{4 b^{2}-d^{2}}+\frac {2 \left (2 b^{2}-d^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d \left (4 b^{2}-d^{2}\right )}+\frac {2 \left (2 b^{2}-d^{2}\right ) \tan \left (\frac {a}{2}+\frac {b x}{2}\right )^{4} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d \left (4 b^{2}-d^{2}\right )}+\frac {4 \left (2 b^{2}+d^{2}\right ) \tan \left (\frac {a}{2}+\frac {b x}{2}\right )^{2} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (4 b^{2}-d^{2}\right ) d}}{\left (1+\tan \left (\frac {a}{2}+\frac {b x}{2}\right )^{2}\right )^{2} \left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right )}\) \(293\)
orering \(-\frac {\left (16 b^{4}+3 d^{4}\right ) \left (-2 \cos \left (b x +a \right ) \cos \left (d x +c \right ) b \sin \left (b x +a \right )-\cos \left (b x +a \right )^{2} d \sin \left (d x +c \right )\right )}{d^{2} \left (16 b^{4}-8 b^{2} d^{2}+d^{4}\right )}-\frac {\left (8 b^{2}+3 d^{2}\right ) \left (8 b^{3} \sin \left (b x +a \right ) \cos \left (d x +c \right ) \cos \left (b x +a \right )-6 b^{2} \sin \left (b x +a \right )^{2} d \sin \left (d x +c \right )+6 \cos \left (b x +a \right ) d^{2} \cos \left (d x +c \right ) b \sin \left (b x +a \right )+6 \cos \left (b x +a \right )^{2} d \sin \left (d x +c \right ) b^{2}+\cos \left (b x +a \right )^{2} d^{3} \sin \left (d x +c \right )\right )}{d^{2} \left (16 b^{4}-8 b^{2} d^{2}+d^{4}\right )}-\frac {-32 b^{5} \cos \left (b x +a \right ) \cos \left (d x +c \right ) \sin \left (b x +a \right )-40 b^{4} \cos \left (b x +a \right )^{2} d \sin \left (d x +c \right )-80 b^{3} \sin \left (b x +a \right ) d^{2} \cos \left (d x +c \right ) \cos \left (b x +a \right )+40 b^{4} \sin \left (b x +a \right )^{2} d \sin \left (d x +c \right )+20 b^{2} \sin \left (b x +a \right )^{2} d^{3} \sin \left (d x +c \right )-10 \cos \left (b x +a \right ) d^{4} \cos \left (d x +c \right ) b \sin \left (b x +a \right )-20 \cos \left (b x +a \right )^{2} d^{3} \sin \left (d x +c \right ) b^{2}-\cos \left (b x +a \right )^{2} d^{5} \sin \left (d x +c \right )}{d^{2} \left (16 b^{4}-8 b^{2} d^{2}+d^{4}\right )}\) \(418\)

Input:

int(cos(b*x+a)^2*cos(d*x+c),x,method=_RETURNVERBOSE)
 

Output:

1/2*sin(d*x+c)/d+1/4*sin(2*a-c+(2*b-d)*x)/(2*b-d)+1/4/(2*b+d)*sin(2*a+c+(2 
*b+d)*x)
 

Fricas [A] (verification not implemented)

Time = 0.07 (sec) , antiderivative size = 64, normalized size of antiderivative = 0.94 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\frac {2 \, b d \cos \left (b x + a\right ) \cos \left (d x + c\right ) \sin \left (b x + a\right ) - {\left (d^{2} \cos \left (b x + a\right )^{2} - 2 \, b^{2}\right )} \sin \left (d x + c\right )}{4 \, b^{2} d - d^{3}} \] Input:

integrate(cos(b*x+a)^2*cos(d*x+c),x, algorithm="fricas")
 

Output:

(2*b*d*cos(b*x + a)*cos(d*x + c)*sin(b*x + a) - (d^2*cos(b*x + a)^2 - 2*b^ 
2)*sin(d*x + c))/(4*b^2*d - d^3)
 

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 410 vs. \(2 (49) = 98\).

Time = 0.75 (sec) , antiderivative size = 410, normalized size of antiderivative = 6.03 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\begin {cases} x \cos ^{2}{\left (a \right )} \cos {\left (c \right )} & \text {for}\: b = 0 \wedge d = 0 \\- \frac {x \sin ^{2}{\left (a - \frac {d x}{2} \right )} \cos {\left (c + d x \right )}}{4} - \frac {x \sin {\left (a - \frac {d x}{2} \right )} \sin {\left (c + d x \right )} \cos {\left (a - \frac {d x}{2} \right )}}{2} + \frac {x \cos ^{2}{\left (a - \frac {d x}{2} \right )} \cos {\left (c + d x \right )}}{4} + \frac {\sin ^{2}{\left (a - \frac {d x}{2} \right )} \sin {\left (c + d x \right )}}{d} - \frac {3 \sin {\left (a - \frac {d x}{2} \right )} \cos {\left (a - \frac {d x}{2} \right )} \cos {\left (c + d x \right )}}{2 d} & \text {for}\: b = - \frac {d}{2} \\- \frac {x \sin ^{2}{\left (a + \frac {d x}{2} \right )} \cos {\left (c + d x \right )}}{4} + \frac {x \sin {\left (a + \frac {d x}{2} \right )} \sin {\left (c + d x \right )} \cos {\left (a + \frac {d x}{2} \right )}}{2} + \frac {x \cos ^{2}{\left (a + \frac {d x}{2} \right )} \cos {\left (c + d x \right )}}{4} - \frac {\sin {\left (a + \frac {d x}{2} \right )} \cos {\left (a + \frac {d x}{2} \right )} \cos {\left (c + d x \right )}}{2 d} + \frac {\sin {\left (c + d x \right )} \cos ^{2}{\left (a + \frac {d x}{2} \right )}}{d} & \text {for}\: b = \frac {d}{2} \\\left (\frac {x \sin ^{2}{\left (a + b x \right )}}{2} + \frac {x \cos ^{2}{\left (a + b x \right )}}{2} + \frac {\sin {\left (a + b x \right )} \cos {\left (a + b x \right )}}{2 b}\right ) \cos {\left (c \right )} & \text {for}\: d = 0 \\\frac {2 b^{2} \sin ^{2}{\left (a + b x \right )} \sin {\left (c + d x \right )}}{4 b^{2} d - d^{3}} + \frac {2 b^{2} \sin {\left (c + d x \right )} \cos ^{2}{\left (a + b x \right )}}{4 b^{2} d - d^{3}} + \frac {2 b d \sin {\left (a + b x \right )} \cos {\left (a + b x \right )} \cos {\left (c + d x \right )}}{4 b^{2} d - d^{3}} - \frac {d^{2} \sin {\left (c + d x \right )} \cos ^{2}{\left (a + b x \right )}}{4 b^{2} d - d^{3}} & \text {otherwise} \end {cases} \] Input:

integrate(cos(b*x+a)**2*cos(d*x+c),x)
 

Output:

Piecewise((x*cos(a)**2*cos(c), Eq(b, 0) & Eq(d, 0)), (-x*sin(a - d*x/2)**2 
*cos(c + d*x)/4 - x*sin(a - d*x/2)*sin(c + d*x)*cos(a - d*x/2)/2 + x*cos(a 
 - d*x/2)**2*cos(c + d*x)/4 + sin(a - d*x/2)**2*sin(c + d*x)/d - 3*sin(a - 
 d*x/2)*cos(a - d*x/2)*cos(c + d*x)/(2*d), Eq(b, -d/2)), (-x*sin(a + d*x/2 
)**2*cos(c + d*x)/4 + x*sin(a + d*x/2)*sin(c + d*x)*cos(a + d*x/2)/2 + x*c 
os(a + d*x/2)**2*cos(c + d*x)/4 - sin(a + d*x/2)*cos(a + d*x/2)*cos(c + d* 
x)/(2*d) + sin(c + d*x)*cos(a + d*x/2)**2/d, Eq(b, d/2)), ((x*sin(a + b*x) 
**2/2 + x*cos(a + b*x)**2/2 + sin(a + b*x)*cos(a + b*x)/(2*b))*cos(c), Eq( 
d, 0)), (2*b**2*sin(a + b*x)**2*sin(c + d*x)/(4*b**2*d - d**3) + 2*b**2*si 
n(c + d*x)*cos(a + b*x)**2/(4*b**2*d - d**3) + 2*b*d*sin(a + b*x)*cos(a + 
b*x)*cos(c + d*x)/(4*b**2*d - d**3) - d**2*sin(c + d*x)*cos(a + b*x)**2/(4 
*b**2*d - d**3), True))
 

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 371 vs. \(2 (62) = 124\).

Time = 0.06 (sec) , antiderivative size = 371, normalized size of antiderivative = 5.46 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\frac {{\left (2 \, b d \sin \left (c\right ) - d^{2} \sin \left (c\right )\right )} \cos \left ({\left (2 \, b + d\right )} x + 2 \, a + 2 \, c\right ) - {\left (2 \, b d \sin \left (c\right ) - d^{2} \sin \left (c\right )\right )} \cos \left ({\left (2 \, b + d\right )} x + 2 \, a\right ) - {\left (2 \, b d \sin \left (c\right ) + d^{2} \sin \left (c\right )\right )} \cos \left (-{\left (2 \, b - d\right )} x - 2 \, a + 2 \, c\right ) + {\left (2 \, b d \sin \left (c\right ) + d^{2} \sin \left (c\right )\right )} \cos \left (-{\left (2 \, b - d\right )} x - 2 \, a\right ) + 2 \, {\left (4 \, b^{2} \sin \left (c\right ) - d^{2} \sin \left (c\right )\right )} \cos \left (d x + 2 \, c\right ) - 2 \, {\left (4 \, b^{2} \sin \left (c\right ) - d^{2} \sin \left (c\right )\right )} \cos \left (d x\right ) - {\left (2 \, b d \cos \left (c\right ) - d^{2} \cos \left (c\right )\right )} \sin \left ({\left (2 \, b + d\right )} x + 2 \, a + 2 \, c\right ) - {\left (2 \, b d \cos \left (c\right ) - d^{2} \cos \left (c\right )\right )} \sin \left ({\left (2 \, b + d\right )} x + 2 \, a\right ) + {\left (2 \, b d \cos \left (c\right ) + d^{2} \cos \left (c\right )\right )} \sin \left (-{\left (2 \, b - d\right )} x - 2 \, a + 2 \, c\right ) + {\left (2 \, b d \cos \left (c\right ) + d^{2} \cos \left (c\right )\right )} \sin \left (-{\left (2 \, b - d\right )} x - 2 \, a\right ) - 2 \, {\left (4 \, b^{2} \cos \left (c\right ) - d^{2} \cos \left (c\right )\right )} \sin \left (d x + 2 \, c\right ) - 2 \, {\left (4 \, b^{2} \cos \left (c\right ) - d^{2} \cos \left (c\right )\right )} \sin \left (d x\right )}{8 \, {\left ({\left (\cos \left (c\right )^{2} + \sin \left (c\right )^{2}\right )} d^{3} - 4 \, {\left (b^{2} \cos \left (c\right )^{2} + b^{2} \sin \left (c\right )^{2}\right )} d\right )}} \] Input:

integrate(cos(b*x+a)^2*cos(d*x+c),x, algorithm="maxima")
 

Output:

1/8*((2*b*d*sin(c) - d^2*sin(c))*cos((2*b + d)*x + 2*a + 2*c) - (2*b*d*sin 
(c) - d^2*sin(c))*cos((2*b + d)*x + 2*a) - (2*b*d*sin(c) + d^2*sin(c))*cos 
(-(2*b - d)*x - 2*a + 2*c) + (2*b*d*sin(c) + d^2*sin(c))*cos(-(2*b - d)*x 
- 2*a) + 2*(4*b^2*sin(c) - d^2*sin(c))*cos(d*x + 2*c) - 2*(4*b^2*sin(c) - 
d^2*sin(c))*cos(d*x) - (2*b*d*cos(c) - d^2*cos(c))*sin((2*b + d)*x + 2*a + 
 2*c) - (2*b*d*cos(c) - d^2*cos(c))*sin((2*b + d)*x + 2*a) + (2*b*d*cos(c) 
 + d^2*cos(c))*sin(-(2*b - d)*x - 2*a + 2*c) + (2*b*d*cos(c) + d^2*cos(c)) 
*sin(-(2*b - d)*x - 2*a) - 2*(4*b^2*cos(c) - d^2*cos(c))*sin(d*x + 2*c) - 
2*(4*b^2*cos(c) - d^2*cos(c))*sin(d*x))/((cos(c)^2 + sin(c)^2)*d^3 - 4*(b^ 
2*cos(c)^2 + b^2*sin(c)^2)*d)
 

Giac [A] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 61, normalized size of antiderivative = 0.90 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\frac {\sin \left (2 \, b x + d x + 2 \, a + c\right )}{4 \, {\left (2 \, b + d\right )}} + \frac {\sin \left (2 \, b x - d x + 2 \, a - c\right )}{4 \, {\left (2 \, b - d\right )}} + \frac {\sin \left (d x + c\right )}{2 \, d} \] Input:

integrate(cos(b*x+a)^2*cos(d*x+c),x, algorithm="giac")
                                                                                    
                                                                                    
 

Output:

1/4*sin(2*b*x + d*x + 2*a + c)/(2*b + d) + 1/4*sin(2*b*x - d*x + 2*a - c)/ 
(2*b - d) + 1/2*sin(d*x + c)/d
 

Mupad [B] (verification not implemented)

Time = 19.61 (sec) , antiderivative size = 104, normalized size of antiderivative = 1.53 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\frac {b\,\left (2\,d\,\sin \left (2\,a+c+2\,b\,x+d\,x\right )+2\,d\,\sin \left (2\,a-c+2\,b\,x-d\,x\right )\right )-d^2\,\sin \left (2\,a+c+2\,b\,x+d\,x\right )+d^2\,\sin \left (2\,a-c+2\,b\,x-d\,x\right )}{16\,b^2\,d-4\,d^3}+\frac {\sin \left (c+d\,x\right )}{2\,d} \] Input:

int(cos(a + b*x)^2*cos(c + d*x),x)
 

Output:

(b*(2*d*sin(2*a + c + 2*b*x + d*x) + 2*d*sin(2*a - c + 2*b*x - d*x)) - d^2 
*sin(2*a + c + 2*b*x + d*x) + d^2*sin(2*a - c + 2*b*x - d*x))/(16*b^2*d - 
4*d^3) + sin(c + d*x)/(2*d)
 

Reduce [B] (verification not implemented)

Time = 0.18 (sec) , antiderivative size = 80, normalized size of antiderivative = 1.18 \[ \int \cos ^2(a+b x) \cos (c+d x) \, dx=\frac {2 \cos \left (b x +a \right ) \cos \left (d x +c \right ) \sin \left (b x +a \right ) b d +\sin \left (b x +a \right )^{2} \sin \left (d x +c \right ) d^{2}+2 \sin \left (d x +c \right ) b^{2}-\sin \left (d x +c \right ) d^{2}}{d \left (4 b^{2}-d^{2}\right )} \] Input:

int(cos(b*x+a)^2*cos(d*x+c),x)
 

Output:

(2*cos(a + b*x)*cos(c + d*x)*sin(a + b*x)*b*d + sin(a + b*x)**2*sin(c + d* 
x)*d**2 + 2*sin(c + d*x)*b**2 - sin(c + d*x)*d**2)/(d*(4*b**2 - d**2))