Manipulating Definition of Fourier Series

$$\textbf{The Problem:}$$ Suppose that for any smooth function $$F:[-L,L]\to\mathbb C$$ satisfying $$F(L)=F(-L)$$ we can write for some $$c_n\in\mathbb C$$ $$F(x)=\sum^{\infty}_{n=-\infty}c_ne^{in\pi x/L}.$$ a) Show that if $$f:(0,L)\to\mathbb R$$ is smooth and satisfies $$f(0)=f(L)=0$$ then we can write for some $$a_n\in\mathbb R$$ $$f(x)=\sum^{\infty}_{n=1}a_n\sin\left(\frac{n\pi x}{L}\right).$$

$$\textbf{My Attempt:}$$ I start by defining the function $$F:[-L,L]\to\mathbb R$$ by setting $$F(x)=f(x)$$ if $$x\geq0$$ and $$F(x)=-f(-x)$$ if $$x<0.$$ Then we can use said representation to obtain \begin{align*}F(x)&=\sum^{\infty}_{n=-\infty}c_ne^{in\pi x/L}\\ &=c_0+\sum^{\infty}_{n=1}c_n\left[\cos\left(\frac{n\pi x}{L}\right)+i\sin\left(\frac{n\pi x}{L}\right)\right]+\sum^{-1}_{n=-\infty}c_n\left[\cos\left(\frac{n\pi x}{L}\right)+i\sin\left(\frac{n\pi x}{L}\right)\right]\\ &=c_0+\sum^{\infty}_{n=1}c_n\left[\cos\left(\frac{n\pi x}{L}\right)+i\sin\left(\frac{n\pi x}{L}\right)\right]+\sum^{\infty}_{n=1}c_{-n}\left[\cos\left(\frac{n\pi x}{L}\right)-i\sin\left(\frac{n\pi x}{L}\right)\right]\\ &=c_0+\sum^{\infty}_{n=1}(c_n+c_{-n})\cos\left(\frac{n\pi x}{L}\right)+\sum^{\infty}_{n=1}i(c_n-c_{-n})\sin\left(\frac{n\pi x}{L}\right).\\ \end{align*} Now since $$F(x)=-F(-x),$$ we see that $$c_0+\sum^{\infty}_{n=1}(c_n+c_{-n})\cos\left(\frac{n\pi x}{L}\right)=-c_0-\sum^{\infty}_{n=1}(c_n+c_{-n})\cos\left(\frac{n\pi x}{L}\right),$$ and hence $$c_0+\sum^{\infty}_{n=1}(c_n+c_{-n})\cos\left(\frac{n\pi x}{L}\right)=0.$$ $$\color{blue}{\text{Since the above holds for all x\in[-L,L], we must have that c_0=0 and c_n=-c_{-n} for all n\in\mathbb N.}}$$

Finally, since $$\overline{F(x)}=F(x)$$, it follows that $$ic_n=\overline{ic_n}.$$

Is my reasoning above correct? I think I was not rigorous enough in the deduction in $$\color{blue}{\text{blue}}.$$

Your argument is fine. The blue part requires some information about the functions $$\cos(\frac {n\pi x} L)$$. These functions are orthogonal in $$L^{2} (-L,L)$$ and hence $$\sum \alpha_n \cos(\frac {n\pi x} L)=0$$ implies $$\alpha_n=0$$ for all $$n$$.