Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
@Michael Renardy: I just realized that your answer was indeed correct. As you said, the equation can be solved this for $a = \pm k$ satisfying all the boundary conditions. I do not need to go to the $a \neq \pm k$ range. Thanks a lot.