I believe this is an error minimization problem so I am trying to solve the following equation Min((∑ ( (S(t) - A cos(b t + C)))^2 ) Where S(t) is the input signal, t is time and I will sum over t, A is the amplitude, b is radians per second (frequency), and C is the phase angle. I need to solve for A and C so I can subtract the pure tone from the signal, and repeat the function for the next higher frequency. It is my understanding that to find the minimum I need to find the derivative of (∑((S(t) - A cos(b t + C)))^2 and that presents a problem since the input signal is a set of data and not an actual function so I don't know how to find its derivative. Without the derivative of S(t) I don't believe I can find the derivative of the entire function (∑((S(t) - A cos(b t + C)))^2. Is this possible to solve, and if so, how? note: After the fact I realized that I could extract phase angle to a certain degree of error by using a partial derivative holding A=1 and performing these calculations for each possible angle. So for +/- ∏/360 radians (+/- 0.5 degrees) I would need to calculate for all angles 0 <= C < 2∏ and take the minimum from that. I can't do the same for the amplitude since it's domain is infinite. If this can be solved for a known phase angle C, that would also be helpful.