We can IBP this both ways
First approach
#I = int e^(3x)cosx \ dx#
# = int d/dx( 1/3e^(3x)) cosx \ dx#
which by IBP
#= 1/3e^(3x) cosx - int 1/3e^(3x) d/dx( cosx )\ dx#
#= 1/3e^(3x) cosx + int 1/3e^(3x) sin x \ dx#
preparing for second IBP
#= 1/3e^(3x) cosx + int d/dx( 1/9e^(3x)) sin x \ dx#
by IBP
#= 1/3e^(3x) cosx + 1/9e^(3x) sin x - int 1/9e^(3x) d/dx (sin x) \ dx#
#= 1/3e^(3x) cosx + 1/9e^(3x) sin x - int 1/9e^(3x) cos \ dx#
#implies I = 1/3e^(3x) cosx + 1/9e^(3x) sin x -I/9 + C#
# I = 9/10 (1/3e^(3x) cosx + 1/9e^(3x) sin x ) + C#
# I = e^(3x)/10( 3 cosx + sin x) + C#
Second Approach
#I = int e^(3x)cosx \ dx#
# = int e^(3x) d/dx(sinx) \ dx#
# = e^(3x) sinx - int d/dx(e^(3x)) sin x \ dx + C#
# = e^(3x) sinx - int 3e^(3x) sin x \ dx + C#
Preparing for second IBP
# = e^(3x) sinx - int 3e^(3x) d/dx(- cos x) \ dx + C#
# = e^(3x) sinx + 3e^(3x) cosx - int d/dx (3e^(3x)) cos x \ dx + C#
# = e^(3x) sinx + 3e^(3x) cosx - int 9e^(3x) cos x \ dx + C#
# = e^(3x) sinx + 3e^(3x) cosx - 9I + C#
#implies 10 I = e^(3x) sinx + 3e^(3x) cosx + C#
#I = e^(3x)/10 ( sinx + 3 cosx ) + C#
Same result, second way maybe a little bit snappier.