I have the following second order homogeneous linear differential equation:
$$y''(x) = k y\left( x \right), \quad\quad k \in \mathbb{R}$$
Using the exponential approach
$$y\left( x \right) = d e^{r x}, \quad \left\{ d,\, r \right\} \in \mathbb{C} \quad \Longrightarrow \quad y'\left( x \right) = d r e^{r x} \quad \Longrightarrow \quad y''\left( x \right) = d r^{2} e^{r x}$$
leads to:
$$ \begin{align*} y''\left( x \right) &= k y\left( x \right)\\ d r^{2} e^{rx} &= k d e^{r x}\\ r &= \pm \sqrt{k}\\ \Rightarrow y\left( x \right) &= d e^{\sqrt{k} x}\\ \end{align*} $$
Which is a valid solution but now I used a trigonometric approach:
$$ \begin{align*} y(x) &= a\cos(\omega x) + b\sin(\omega x), \quad \quad \left\{ a,\, b,\, \omega \right\} \in \mathbb{C}\\ y''\left( x \right) &= -a \omega^{2} \cos\left( \omega x \right) - b \omega^{2} \sin\left( \omega x \right) = -\omega^{2} y\left( x \right)\\ \end{align*} $$
Which leads to:
$$ \begin{align*} y''\left( x \right) &= k y\left( x \right)\\ -\omega^{2} y\left( x \right) &= k y\left( x \right)\\ \omega &= i \sqrt{k}\\ \implies y(x) &= a \cos\left( i \sqrt{k} x \right) + b \sin\left( i \sqrt{k} x \right) \end{align*} $$
Those seem like different solutions but I know that you should in theory be able to transform one into the other, by using the complex identities for $\cos$ and $\sin$.
$$ \begin{align*} y\left( x \right) &= a \cos\left( i \sqrt{k} x \right) + b \sin\left( i \sqrt{k} x \right)\\ &= \frac{a}{2} \left( e^{i \left( i \sqrt{k} x \right)} + e^{-i \left( i \sqrt{k} x \right)} \right) + \frac{b}{2 i} \left( e^{i \left( i \sqrt{k} x \right)} - e^{-i \left( i \sqrt{k} x \right)} \right)\\ &= \left( \frac{a}{2} - \frac{b}{2 i} \right) e^{\sqrt{k} x} + \left( \frac{a}{2} + \frac{b}{2 i} \right) e^{-\sqrt{k} x}\\ \end{align*} $$
But I can't see how these two solutions are equal. Where is the problem?
Looking at approach one you seemed to be missing both solutions $$ y_+(x) = \lambda_{+}\mathrm{e}^{\sqrt{k}x} $$ but you also have $$ y_{-}(x) = \lambda_{-}\mathrm{e}^{-\sqrt{k}x} $$ and since you have a linear equation as you seen in the other approach $$ y(x) = y_{+}(x) + y_{-}(x) $$ is also a solution $$ y(x) = \lambda_{+}\mathrm{e}^{\sqrt{k}x} + \lambda_{-}\mathrm{e}^{-\sqrt{k}x} $$ and as the comment by @nasser mentions a constant is a constant so you can absorb into a single constant e.g. $\frac{a}{2} + \frac{b}{2}i = \lambda_{+}$ etc.