Dirichlet problems for the case that the region is a rectangle Find a solution for 
$$u_{xx}+u_{yy}=0 \; for \; (0,a)\times(0,b)$$
$$u(0,y)=u(a,y)=0$$
$$u(x,0)=0\; ,\; u(x,b)=g(x)$$
\begin{equation*}
g(x) = \left\{
\begin{array}{ll}
x      & \mathrm{si\ } 0\le x \le a/2 \\
a - x & \mathrm{si\ } a/2 \le x \le x 
\end{array}
\right.
\end{equation*}
I use separation of variables to solve Dirichlet problems for the case 
that the region is a rectangle then 
$$u(x,y)=\sum_{n=1}^{\infty}{a_n\sin{n\pi x \over a}\sinh{n\pi y \over a}}$$
Now $$u(x,b)=\sum_{n=1}^{\infty}{a_n\sin{n\pi x \over a}\sinh{n\pi b \over a}}=g(x)$$
This is a Fourier sine expansion of $g(x)$ in $\left[0,a\right]$, but  $g(x)$ is a even function.... here I am a bit confused.

The function $g$ is even about the $x=a/2$. $\sin(n\pi x/a)$ is also even about $x=a/2$ for $n=1,3,5,\cdots$, and is odd about $x=a/2$ for $n=2,4,6,\cdots$. The $\sin$ functions are mutually orthogonal on $[0,a]$ with respect to the $L^2[0,a]$ inner product. In order to find constants $a_n$ such that
$$
      g(x) = \sum_{n=1}^{\infty}a_n\sin(n\pi x/a)\sinh(n\pi b/a),
$$
multiply both sides of the above by $\sin(m\pi x/a)$ and integrate over $[0,a]$:
$$
    \int_{0}^{a}g(x)\sin(m\pi x/a)dx=a_m\int_{0}^{a}\sin^2(m\pi x/a)dx \sinh(m\pi b/a).
$$
This gives $a_m$ for $m=1,2,3,\cdots$ and finishes your solution.
