for a personal project, I created the following discrete cosine waves:
1.) $$x[n] = 5\cos(2\pi1000n+\frac{\pi}{2})$$
2.) $$x[n] = 3\cos(2\pi2000n+\frac{\pi}{3})$$
With sampling frequency of $16000Hz$ and a duration of 100 seconds, I had $1.6$ million samples. I applied the discrete fourier transform on these. This was my result:

On frequency 1000Hz, the magnitude was $4$ million. On frequency 2000Hz, the magnitude was $2.4$ million.
To get the first cosine wave back, I first took the magnitude of $4$ million, divided it by the number of samples, so by $1.6$ million. Then I multiplied the result by $2$ (to account for the negative frequency). The result was 5, which actually is the amplitude for the original first cosine wave.
The same I did for the second cosine wave, and got the original amplitude back.
However, why do we not do this for the phase as well? I only get the correct phase back when I do not divide by the number of samples, and when I do not multiply the answer by two. I fail to see the reason behind this, and I've been looking everywhere. The DFT is weighed, so I think the dividing should happen. I will appreciate any and all help.
The phase shouldn't change when you divide by N or multiply by 2. The bin values are just complex numbers, and when you divide or multiply complex numbers by a real number the phase won't change, since real numbers have 0 phase.
There has to be some mistake in the way you calculated the phase, if you got it correctly before dividing by N.