$$\Delta u(x,y)=0$$ $$x,y\in(0,1),$$ $$\frac{\partial u(0,y)}{\partial x}=0,\quad \frac{\partial u(1,y)}{\partial x}=0,\quad\frac{\partial u(x,0)}{\partial y}=0,\quad\frac{\partial u(x,1)}{\partial y}=\frac{1}{2}-x$$
Are the boundary conditions contradicting each other? $\frac{1}{2}-x$ only admit $\sin(2n \pi x)$ which violates boundary conditions at $(0,y) $ and $(1,y)$
MY attempted solution: finite fourier transform on the $x$ domain, then figure out the coefficient which runs into the above problem.
Can anyone enlighten me what is wrong with my method or the boundary condition? Thanks!
Laplace equation has solutions that are very restricted! One boundary condition determines the set of solutions, but it's still an infinite series of solutions, so the other boundary condition can be satisfied via Fourier series.
In your case, the Neumann boundary condition suggests functions
$$\cos(n \pi x)\cosh (n\pi y)$$
Notice several things: first of all, cosine is the one that has zero derivative at the boundary. Secondly, it's perfectly valid to have a half-period on the domain (no $2$ inside the cosine). And thirdly, I constructed a harmonic function that automatically satisfies also the boundary condition at $y=0$. In general, you would use both $\sinh$ and $\cosh$ or $\exp(\pm n\pi y)$, but $\cosh$ already has zero derivative at $y=0$ so we're done there.
Why precisely this function? Well, Laplace equation is satisfied by complex analytical functions, and it's not difficult to extend cosine to the complex plane. The above can be obtained from superposition of $\Re e^{\pm in\pi z}$ where $z=x+iy$.
Now your solution reads as
$$\sum_{n=1}^\infty a_n \cos(n \pi x)\cosh (n\pi y)$$
Notice that Laplace equation only permits a one-parametric family of solutions. Now you need to determine the coefficients $a_n$. This is almost trivial, because you just plug in $y=1$: $$\frac12-x=\frac{\partial}{\partial y}\sum_{n=1}^\infty a_n \cos(n \pi x)\cosh (n\pi y) |_{y=1}$$
$$\frac12-x=\sum_{n=1}^\infty a_n n\pi \cos(n \pi x)\cosh (n\pi)$$ This is just a cosine Fourier transform. If you don't want a hassle with getting all the prefactors wrong, just multiply by $\cos (m\pi x)$ on both sides and integrate. Orthogonality will take care of the rest, and you will get $a_n$ in terms of coefficients of the left side.