# Fitting a sine function to data

I have a sequence of $n$ points $(x_i,y_i)$, for $i=1,\dots,n$. I would like to find the function, of the form $y=V\sin(x+\phi)$, which best fits the points. Which numerical method could I use? I have a slow system, with little memory, so I am searching for a fast and efficent method, even if not very accurate.

I have tried with gradient descent, but it is slow.

-
How do you define "best fit"? –  Listing Nov 25 '11 at 23:14
The usual method for least-squares fitting is Levenberg-Marquardt. Of course, this needs a good initial estimate for your model's parameters, as with most iterative methods. –  Ｊ. Ｍ. Nov 26 '11 at 2:02