When I was trying to solve the following differential equation: $$ \frac {d^2x}{dt^2} + 4x = t^2 $$ I arrived to the following particular expression $x_h(t)$: $$ x_h(t) = Ae^{2it} + Be^{-2it} $$ where $i$ is the imaginary number;
The teacher set it directly to : $A\cos2t + B\sin2t$
While originally $e^{it} = \cos(it) + \sin(it)$
How he concluded that ?
Let's start with $x_h(t) = \hat{A} \mathrm{e}^{2\mathrm{i}t} + \hat{B} \mathrm{e}^{-2\mathrm{i}t}$, where we use hats because these constants aren't going to be as useful so we will replace them shortly. Using Euler's formula, $$ x_h(t) = \hat{A} (\cos(2t) + \mathrm{i}\sin(2t)) + \hat{B} (\cos(-2t) + \mathrm{i}\sin(-2t)) $$ and we immediately apply the even-odd properties of sine and cosine, to get \begin{align*} x_h(t) &= \hat{A} (\cos(2t) + \mathrm{i}\sin(2t)) + \hat{B} (\cos(2t) - \mathrm{i}\sin(2t)) \\ &= (\hat{A} +\hat{B}) \cos(2t) + (\hat{A} - \hat{B}) \mathrm{i}\sin(2t) \text{,} \end{align*} where we have collected by sines and cosines.
Since $\hat{A}$ and $\hat{B}$ are arbitrary (complex) constants, so are $(\hat{A} +\hat{B})$ and $(\hat{A} - \hat{B})\mathrm{i}$. You should recognize that this is a pair of independent constants. ( $$ \begin{pmatrix} \hat{A} +\hat{B} \\ (\hat{A} -\hat{B})\mathrm{i} \end{pmatrix} = \begin{pmatrix} 1 & 1 \\ \mathrm{i} & -\mathrm{i} \end{pmatrix} \cdot \begin{pmatrix} \hat{A} \\ \hat{B} \end{pmatrix} $$ and the determinant of that matrix is not zero.) So we can replace them with symbols for different arbitrary constants : $$ x_h(t) = A \cos(2t) + B \sin(2t) \text{.} $$
Other than allowing us to carefully discriminate between the "before matrix multiplication" and "after matrix multiplication" completely arbitrary constants, the hats didn't do anything useful. There is a semantic error going from "$x_h(t) = A \mathrm{e}^{2\mathrm{i}t} + B \mathrm{e}^{-2\mathrm{i}t}$" to "$ x_h(t) = A \cos(2t) + B \sin(2t)$" because the first $A,B$ do not generally have the same values as the second $A,B$, but, it is widespread practice to not be too concerned about the details of arbitrary constants until they actually need values (for instance, to match an initial condition or a boundary condition). When you see that re-use of $A$ and $B$ you are supposed to understand that "this $A$ and $B$" are not numerically the same as "that $A$ and $B$", but so far they're both arbitrary, so this is largely a distinction without a difference at the level of abstraction at which we are solving differential equations; arbitrary constants are arbitrary.