FFT, interpolation and phases I am trying to understand how to interpolate discrete sinusoidal data that I (for now) generate myself, and I get problems that I don't understand. I'm a newbie in this field so do not hesitate to point out even the most basic errors.

I have tried two approaches.

The first is to take (Python's/numpy's) fft(), get amplitudes with abs() and phases with 
$$
\frac{\text{angle} - \pi/2}{2 \pi} * \text{signal_length}
$$

Then, for each sampling point $p$ I do a sine series, 
$$
\sum_i \text{amplitude}_i * \sin(2 \pi i * \frac{p - \text{phase}_i}{\text{signal_length}})
$$

For artificial data where the (only) sine lambda is signal_length the fit is perfect regardless of the artificial data phase. However, if I generate the data with sine that has lambda of half the signal length, the fit is far from good for most phase offsets. Obviously, the fit is also not good when I generate a signal from several added sines of different lambdas.

Edit 1: Note that I can artificially correct the phases of different lambdas by dividing them by n, where n is signal_length / lambda of the generating function, but this doesn't help when I don't know the lambda of the generating function and/or when the signal is a mix of several sines.

The second approach was to get separate sine and cosine amplitudes from fft() output by real() and -1 * imag() and then do a summation similar to above for both sine and cosine terms. This works well whenever the phase offset of the generated data is n*2*pi but unwell when it's anything else.

Eventually I'd like to be able to interpolate data generated by a superposition of several sinusoidal functions of various lambdas and phases, but so far it's not looking good. I think there is something that I don't understand about Fourier/DFT.

Note that I can't/don't want to use any built-in ifft functions but I need to do some kind of a sine/cosine summation manually. I tried to write the definition of inverse DFT, but the built-in functions don't understand correctly things such as e^i. Ideally I would want to sum just the sine or the cosine terms, but not both.

Edit 2 LaTeXed some math
I resolved this problem by myself. Using approach 1, I replaced $$phase_i$$ with $$\frac{phase_i}{i+1}$$ in the summation formula, and suddenly everything worked perfectly.