I have the following ODE defined on $D_x = [-1,1]$:
$$y''(x)=-k^2y(x).$$
Prom the physical problem, I know that the solution is non-zero and that $y(x)$ is a even function [$y(-x)=y(x)$] vanishing at $x=1$.
The general solution to the previous ODE is given by:
$$y(x)=a\sin(kx)+b\cos(kx).$$
I tried to solve this problem by using two different boundary values.
Method 1: $y(1)=0$ and because $y(x)$ is a even function, we can state $y'(0)=0$. Using the general solution we get:
$$0=a\sin(k)+b\cos(k)$$ $$0=ak$$
- Case 1 $a=0$: We obtain $0=b\cos(k)$.
- Case 1a $b=0$: Leads to trivial zero solution.
- Case 1b $\cos(k)=0$: Leads to $k=\pi/2+\pi l$, in which $l \in \mathbb{Z}$.
- Case 2 $a\neq 0$: this implies $k=0$ which leads to $b=0$, hence the trivial zero solution.
So only Case 1b gave a meaningful result given by $$y(x)=\sum_{l=-\infty}^{\infty}b_l\cos((\pi/2+\pi l)x)$$
Method 2: As $y(x)$ vanishes on the boundaries I can also use $y(1)=y(-1)=0$ as boundary condition. Again, using the general solution it is possible to obtain:
$$0=a\sin(k)+b\cos(k)$$ $$0=-a\sin(k)+b\cos(k).$$
From here there are two possible ways to solve this problem.
Procedure 1: Adding both equations:
$$0=2b\cos(k).$$
Case 1: $b=0$, implies $0=a\sin(k)$ Case 1a $a=0$: Leads to trivial zero soltuion. Case 1b $a\neq 0$: Leads to $k=\pi l$, hence the general solution $$y(x)=\sum_{l=1}^{\infty}a_l\sin(\pi l x)$$
Procedure 2: Subtracting both equations: $$0=2a\sin(k)$$
Case 2 $a=0$: Implies $0=b\cos(k)$
Case 2a $b=0$: Implies trivial zero solution.
Case 2b $b\neq 0$: Implies $k=\pi/2+\pi l$, in which $l\in \mathbb{Z}$. So the general solution is given by $$y(x)=\sum_{l=-\infty}^{\infty}b_l\cos((\pi/2+\pi l)x)$$
My Question: How is it possible that two different sets of boundary conditions, descibing the same physical $y(x)$ lead to different results? And how is it possible that for the second method different ways of solving the system lead to different solutions? How can I know which boundary conditions I need to pick, in order to get the "right" solution? I would be glad if someone could point out a mistake that I made or explain me why this happened.
Assuming that $y(1) = y(-1)$ does not guarantee that the solution is even. There are plenty for function satisfying this without being even. So in Method 2 your total solution will be a sum of the solutions found in Procedure 1 and Procedure 2. However the solutions from Procedure 1 does not fulfil the requirement that the solution is even so they have to be discarded (i.e. $a_l = 0$ for all $l$).
In this case it does not matter which method you use as they both yield the correct result in the end (once you keep only the even solutions).