# Constructing an orthonormal basis with complex numbers?

I have this problem I recently ran into and am wondering how to overcome it: I have $V$, which has a basis of $[e^{ikx}:0\leq k\leq 3]$, and inner product $(f,g) \int_{0}^{a}f(x)\bar{g(x)}$ where $a$ is chosen between $(0,\infty)$. I need to construct an orthonormal basis (going from $v$ to $u$, as $u$ are the orthonormal vectors) of this inner product space. So far, I have performed the following calculations:

I have rewritten $[e^{ikx}:0\leq k\leq 3]$ as $[1, e^{ix}, e^{2ix}, e^{3ix}]$.

Step 1: $||v_1||^2 = \int_{0}^{a}(v_1(x))^2dx = a$ so $u_1=\frac{1}{||v_1||}v_1 = \frac{1}{\sqrt{a}}$.

Step 2: $\tilde{v_2} = v_2 - \langle v_2,u_1 \rangle u_1$

I start this step by calculating the inner product of $v_2$ and $u_1$ by doing the following (this is where I think I may be making a mistake):

$\langle v_2,u_1 \rangle=\int_{0}^{a}v_2(x)u_1dx = \frac{1}{\sqrt{a}}\int_{0}^{a} e^{ix}dx = \frac{1}{\sqrt{a}}(-ie^{ia} + i)$. Upon this, $\langle v_2,u_1 \rangle u_1 = \frac{1}{a}(-ie^{ia} + i)$.

Now we can say that $\tilde{v_2} = e^{ix} - \frac{1}{a}(-ie^{ia} + i)$. I use this to calculate $||\tilde{v_2}||^2 = \int_{0}^{a} \tilde{v_2(x)}^2dx$ which I got to be $(\frac{-i}{2}e^{2ia} + \frac{i}{2}) - (\frac{2(-ie^{ia} + i)}{a})$ and therefore I said $u_2 = \frac{e^{ix} - \frac{1}{a}(-ie^{ia} + i)}{\sqrt{\frac{-i}{2}e^{2ia} + \frac{i}{2} - \frac{2(-ie^{ia} + i)}{a}}}$.

I feel like this problem is becoming overly complicated in terms of calculations and I am questioning where I did something wrong so far. Could someone please guide me in the right direction?

I don't think your calculations can be a lot simpler than that. The mistake I'm seeing is that the norm should be $$\|\bar{v_2}\|^2=\int_0^a |\bar{v_2}(x)|^2\,dx.$$ The norm is supposed to be a non-negative real number. The mistake didn't appear in the first step because $v_1$ is real.