Given Laplace's equation $$u_{xx} + u_{yy} = 0$$ and 2 boundary conditions
- $u(x,y)=x^2y$
- $u(\cos\theta, \sin\theta) = 1 + \cos\theta$
in the unit disc. I want to solve Laplace equation.
After using separation of variables I get

where $f(\theta)$ is the boundary conditions. If use the second condition, I get $a_0=\frac{2\pi}{\pi}=2$ and $b_n=0$ since odd function but the problem is with $a_n$ as I keep getting 0. $\frac{1}{\pi}\int_0^{2\pi}{(1+cos\theta)cos n\theta d\theta}=\frac{1}{\pi}\int_0^{2\pi}{cos\theta cos n\theta d\theta}=\frac{1}{2\pi}\int_0^{2\pi}{cos(n+1)\theta d\theta}$ which equals 0 unless $n=-1$ (integral = $\pi$)but can $n$ be a negative number i.e. $a_{-1}$?
and also for first condition, is the same method i.e. using $cos\theta,sin\theta$?
In polar coordinates, the separated solutions of the Laplace equation are (up to constant coefficients):
The last three have a singularity at the origin, so can't be used in a disk; they are listed here for completeness.
Thus, given $1+\cos \theta$ as the boundary condition in the disk, you can readily write down the solution $1+r\cos\theta$ by picking the functions from the above catalog to match the boundary values.
Your computation with cosines is incorrect because $$\cos\theta \cos n\theta \ne \cos (n+1)\theta$$ See Product-to-sum identities.
Concerning $u(x,y)=x^2y $, I guess this condition is also meant to be enforced on the boundary of unit disk. In polar coordinates it becomes $\cos^2\theta \sin\theta$. Use the above product-to-sum identities to write this as a linear combination of terms like $\cos n\theta$ and $\sin n\theta$. Then match them to separated solutions above.