I have a slightly complicated periodic function of one variable t, say g[t].
I want to do a least squares fit of that function into the form A*Cos[Ω*t]+B*Cos[2Ω*t], and figure out the values of parameters A and B.
Is there a way to do this in Mathematica? Thanks in advance!
Fourierto calculate a spectrum of values for A and B. Do you really just want the first and second harmonic? Roman's answer below will work fine for calculating individual values. An example from you would clarify what you want. If you can, please edit your post and add an example. – Hugh Apr 30 '19 at 16:06