# How to find the formula within an oscillating data patern?

#### Dutchmountain1

##### New Member
Hi,

I have a large pool of data and if I graph the data i can see an oscillating patern. How can I let Excel find the oscillating formula?

Cheers,

Dutchmountain

### Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

#### Eric W

##### MrExcel MVP
Welcome to the Board.

Hard to say without seeing your data. Curve-fitting is inherently tricky. You say that you have an oscillating pattern. This suggests a SIN function. The general formula of a sine is:

y = a*SIN(b*x+c)+d

You could set up a formula with those 4 coefficients in cells A1:A4 (for example). Then copy the formula down the rows where your data is, using the x value from your data. Then have another formula next to that formula which has the square of the difference between the original y value and the calculated y value from your formula. Finally, have one final formula that sums up the sum of the squares.

Now set up the Solver. You can either Google how to do that, or come back here and ask. But the gist of it is to set up the Solver so that it calculates what the minimum value of your sum of squares cell is, by varying the A1:A4 values.

But all this is just an outline, it could be much trickier. You might need to worry about converting your values to radians. The formula might be something weird like SIN(x)*COS(x)+SIN(a*x^2+b*x+c). There could be a lot of analysis involved. Things like knowing what the data represents could help. Good luck!