MevsEinstein said:
Where do you get these values from?
We are trying to fit ##y = d\cos(ax + b) + c##
Those four parameters are:
Vertical scale: d
Vertical offset: c
Frequency offset: a
Phase offset: b
The way I would have obtained the values would be to start with the symmetries in the data.
BVU's graph is a thing of beauty to work from for that purpose. It displays graphically the picture that should be in one's head. [My mind's eye would have tried a simpler fit to an absolute value function, but I can squint and see a cosine instead]
The horizontal midpoint is at y=20 exactly. So we can immediately take the vertical offset
##c=20##.
Now look at the values for x=1 and x=4. Those are both on the zero line of the graph of cosine. So those are one half cycle apart (could also be 1.5 cycles or 2.5, etc, but we'll not go there). From that we get that the frequency shift
##a=\frac{\pi}{3} = 1.04719755##.
The vertical midpoint is at x=2.5 exactly. You want a minimum of the cosine result there. So it would be convenient to take ##ax+b = \pi## at ##x = 2.5##. But I do not want to do things that way...
Consider that ##d## will be negative and and taken ##ax+b = 0## at ##x = 2.5##. We already have ##a = \frac{\pi}{3}## so we can solve for ##b## and get that the phase offset
##b = -\frac{5\pi}{6} = 2.6179938##
Now all we have to do is figure out the vertical scale ##d##. If you look at the data values for x=2 or x=3 compared to a center line at x=2.5, both of those are 1/3 of the way through a quarter cycle of the cosine function. So they correspond to the cosine of ##\frac{\pi}{6}##. We already have the vertical offset (##c = 20##) and want to solve for the vertical scale (##d##). We have the given data ##y=10## for both ##x## values.
So we want ##d \cos \frac{\pi}{6} + 20 = 10##. We can solve this and obtain.
##d = \frac{-10}{cos (\pi/6)} = -19.098593##
[Note that ##d## came out negative just as we wanted because we chose to center our cosine on ##x=2.5##]
If I haven't muffed some arithmetic or algebra along the way, all of this (except the decimal values, of course) should be exact.