Answer :

Let's solve the indefinite integral [tex]\(\int x^2 \cdot e^x \cdot \cos(x) \, dx\)[/tex] step-by-step.

### Step 1: Identify the integral
We need to find:
[tex]\[ \int x^2 e^x \cos(x) \, dx \][/tex]

### Step 2: Integration by parts
We will use integration by parts, which states:
[tex]\[ \int u \, dv = uv - \int v \, du \][/tex]

In this context, choosing the right [tex]\( u \)[/tex] and [tex]\( dv \)[/tex] is crucial. Given the product of a polynomial, an exponential, and a trigonometric function, we might have to apply integration by parts more than once.

Let's try [tex]\( u = x^2 \)[/tex] and [tex]\( dv = e^x \cos(x) \, dx \)[/tex]. This choice simplifies differentiation of [tex]\( u \)[/tex] and leaves us with a more manageable integral to solve later.

### Step 3: Differentiate [tex]\( u \)[/tex] and integrate [tex]\( dv \)[/tex]
- [tex]\( u = x^2 \)[/tex] implies [tex]\( du = 2x \, dx \)[/tex]
- We need to find [tex]\( v \)[/tex] such that [tex]\( dv = e^x \cos(x) \, dx \)[/tex]. For this, we will use integration by parts again within this part.

Let’s solve [tex]\( \int e^x \cos(x) \, dx \)[/tex]:
- Choose [tex]\( u_1 = \cos(x) \)[/tex] and [tex]\( dv_1 = e^x \, dx \)[/tex]
- [tex]\( du_1 = -\sin(x) \, dx \)[/tex]
- [tex]\( v_1 = e^x \)[/tex]
- Integration by parts for [tex]\(\int e^x \cos(x) \, dx\)[/tex]:
[tex]\[ \int e^x \cos(x) \, dx = e^x \cos(x) - \int e^x (-\sin(x)) \, dx \][/tex]
[tex]\[ = e^x \cos(x) + \int e^x \sin(x) \, dx \][/tex]

Now, solve [tex]\( \int e^x \sin(x) \, dx \)[/tex]:
- Choose [tex]\( u_2 = \sin(x) \)[/tex] and [tex]\( dv_2 = e^x \, dx \)[/tex]
- [tex]\( du_2 = \cos(x) \, dx \)[/tex]
- [tex]\( v_2 = e^x \)[/tex]
- Integration by parts for [tex]\(\int e^x \sin(x) \, dx\)[/tex]:
[tex]\[ \int e^x \sin(x) \, dx = e^x \sin(x) - \int e^x \cos(x) \, dx \][/tex]

Combining these, we get:
[tex]\[ \int e^x \cos(x) \, dx = e^x \cos(x) + [e^x \sin(x) - \int e^x \cos(x) \, dx] \][/tex]

Rearrange to solve for [tex]\(\int e^x \cos(x) \, dx\)[/tex]:
[tex]\[ \int e^x \cos(x) \, dx = \frac{e^x (\cos(x) + \sin(x))}{2} \][/tex]

Thus we have:
[tex]\[ v = \frac{e^x (\cos(x) + \sin(x))}{2} \][/tex]

### Step 4: Apply integration by parts
Returning to the initial parts:
[tex]\[ \int x^2 e^x \cos(x) \, dx = x^2 \left( \frac{e^x (\cos(x) + \sin(x))}{2} \right) - \int \left( \frac{e^x (\cos(x) + \sin(x))}{2} \cdot 2x \right) \, dx \][/tex]
[tex]\[ = \frac{x^2 e^x (\cos(x) + \sin(x))}{2} - \int x e^x (\cos(x) + \sin(x)) \, dx \][/tex]

### Step 5: Repeat integration by parts on new integral
The next integral:
[tex]\[ \int x e^x (\cos(x) + \sin(x)) \, dx \][/tex]

- [tex]\( u = x \)[/tex], [tex]\( dv = e^x (\cos(x) + \sin(x)) \, dx \)[/tex]
- [tex]\( du = dx \)[/tex]
- [tex]\( v \)[/tex] was previously determined [tex]\( v = \frac{e^x (\cos(x) + \sin(x))}{2} \)[/tex]
\]

Applying parts again:
[tex]\[ \int x e^x (\cos(x) + \sin(x)) \, dx = x \cdot \frac{e^x (\cos(x) + \sin(x))}{2} - \int \frac{e^x (\cos(x) + \sin(x))}{2} \, dx \][/tex]
[tex]\[ = \frac{x e^x (\cos(x) + \sin(x))}{2} - \frac{1}{2} \int e^x (\cos(x) + \sin(x)) \, dx \][/tex]

### Step 6: Simple final integral
The integral:
[tex]\[ \int e^x (\cos(x) + \sin(x)) \, dx \Rightarrow \frac{e^x (\cos(x) + \sin(x))}{2} \][/tex]

Combining all this, the final result:
[tex]\[ = \frac{x^2 e^x \sin(x)}{2} + \frac{x^2 e^x \cos(x)}{2} - x e^x \sin(x) + \frac{e^x \sin(x)}{2} - \frac{e^x \cos(x)}{2} \][/tex]

Put together the parts:
[tex]\[ \int x^2 e^x \cos(x) \, dx = \frac{x^2 e^x \sin(x)}{2} + \frac{x^2 e^x \cos(x)}{2} - x e^x \sin(x) + \frac{e^x \sin(x)}{2} - \frac{e^x \cos(x)}{2} + C \][/tex]

Where [tex]\( C \)[/tex] is the constant of integration. This completes the integral.