Evaluate the integral:
\[
I = \int e^x (x+1)^2 \, dx
\]
Step 1: Expand the square:
\[
(x+1)^2 = x^2 + 2x + 1
\]
So,
\[
I = \int e^x (x^2 + 2x + 1) \, dx = \int e^x x^2 \, dx + 2 \int e^x x \, dx + \int e^x \, dx
\]
Step 2: Evaluate each integral separately using integration by parts.
- For \( \int e^x x^2 \, dx \):
Let \( u = x^2 \), \( dv = e^x dx \) then \( du = 2x dx \), \( v = e^x \).
\[
\int e^x x^2 dx = x^2 e^x - \int 2x e^x dx
\]
- For \( \int 2x e^x dx \):
Let \( u = 2x \), \( dv = e^x dx \), then \( du = 2 dx \), \( v = e^x \).
\[
\int 2x e^x dx = 2x e^x - \int 2 e^x dx = 2x e^x - 2 e^x + C
\]
Step 3: Substitute back:
\[
\int e^x x^2 dx = x^2 e^x - (2x e^x - 2 e^x) = x^2 e^x - 2x e^x + 2 e^x
\]
Step 4: Now evaluate the entire integral \( I \):
\[
I = \left(x^2 e^x - 2x e^x + 2 e^x\right) + \left(2x e^x - 2 e^x\right) + e^x + C
\]
Simplify:
\[
I = x^2 e^x - 2x e^x + 2 e^x + 2x e^x - 2 e^x + e^x + C = x^2 e^x + e^x + C = e^x (x^2 + 1) + C
\]
Therefore, the value of the integral is:
\[
\boxed{e^x (x^2 + 1) + C}
\]