# Fitting data points using trigonometric functions [closed]

I want to curve fit some data points using a specific linear combination of trigonometric functions with the help of NonLinearModelfit as per the following code:

points = {{-5, 0.1768}, {-4, 0}, {-3, 0.5863},
{-2,0}, {-1, 0.3535}, {0, 0}, {1, 0.3535}, {2, 0}, {3,0.5863}, {4, 0},
{5,0.1768}};
model = a*Sin[b*x] + c*Sin[d*x];
fit = NonlinearModelFit[points, model, {a, b, c, d}, x]
Show[ListPlot[points, PlotStyle -> Red], Plot[fit[x], {x, -5, 5}]]


However, I got the following output which doesn't fit the data altogether:

FittedModel[-2.2204*10^-16 Sin[2.6912 x] - 1.1102*10^-16 Sin[4.6912 x]]


A guidance on how to go about evaluating this would be appreciated.

## closed as off-topic by Michael Seifert, MarcoB, LCarvalho, Alexey Popkov, LLlAMnYPOct 23 '17 at 12:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, LCarvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

• Your data is symmetric about $x = 0$: for example, you have the points {-1, 0.3535} and {1, 0.3535}. Meanwhile, your model necessarily satisfies $f(x) = -f(-x)$, regardless of the values of $a, b, c, d$. Since NonlinearModelFit minimizes the least-squares distance from the data points to the curve, the best fit for this model will set the amplitude of the sine waves to zero, so that the curve becomes $f(x) = 0$, which is equally far from the points at $x = \pm 1$. (Any non-zero amplitude would give a larger least-squares error.) This is exactly the result that Mathematica has given you. – Michael Seifert Oct 19 '17 at 17:25
• I'm voting to close this question as off-topic because it deals with a mathematical issue in curve-fitting, not a problem with Mathematica. – Michael Seifert Oct 19 '17 at 17:27
• This is not a serious question: the data size 11 is too small to make reliable conclusions. – user64494 Oct 19 '17 at 19:27
• Thank you all for the comments. I have now understood the issue in my question. – Jayanth Jayakumar Oct 20 '17 at 6:52
• I'm voting to close this question as off-topic because the model chosen is inadequate for the dataset (this is a variation on VTC due to simple mistake). As such, this isn't really a problem with Mathematica. – LLlAMnYP Oct 23 '17 at 12:36

model = e + a*Sin[b*x + f] + c*Sin[d*x + g];