MHB Fitting a function to a sinusoidal curve

AI Thread Summary
To fit a sinusoidal curve using the function f(t)=A[1+B cos(ω₁t+φ)] cos(ω₂t+θ), a user suggests using Excel or LibreOffice Calc's Nonlinear Solver. The setup involves organizing time values, data points, and parameters in specific columns, then minimizing the sum of squared differences between the actual data and the fitted curve. An additional idea involves using Fourier series to reproduce the trace from harmonics and their amplitudes, with a focus on determining the constant a₀. The discussion emphasizes practical techniques for curve fitting and the mathematical relationships involved.
bugatti79
Messages
786
Reaction score
4
Hi Folks,

I have a curve that varies sinusoidally calculated from a numerical program as attached "Trace.png". I would like to fit this amplitude modulation expression to it.

f(t)=A[1+B \cos(\omega_1 t+ \phi)] \cos(\omega_2 t+ \theta)

I managed to adjust the parameters manually to get a very similar curve but couldn't exactly match it. Is there a mathematical technique I could use or is it possible at all?

Thanks
 

Attachments

  • Trace.png
    Trace.png
    5.2 KB · Views: 105
Mathematics news on Phys.org
I would use Excel or LibreOffice Calc's Nonlinear Solver routine to solve this problem. Here's the setup:

Column A contains your time values.
Column B contains your data points.
Column C contains the various parameters you can vary, such as $A, B, \omega_1, \omega_2, \phi,$ and $\theta$.
Column D contains the formula you want to fit, all depending on values from Column C (you'll have to populate Column C with initial guesses). Don't forget to use, e.g.,
Code:
$C$1
to retrieve the value from C1.
Column E contains the square of the differences between Column B and Column D. Sum this column at the bottom.

That's the setup. Next, you invoke the Solver routine, and minimize the sum of squares at the bottom of Column E by varying the cells in Column C. If you're in LibreOffice Calc, you have to tell Calc to use a nonlinear solver, or else you'll get an error.

See if that works for you.
 
Ackbach said:
I would use Excel or LibreOffice Calc's Nonlinear Solver routine to solve this problem. Here's the setup:

Column A contains your time values.
Column B contains your data points.
Column C contains the various parameters you can vary, such as $A, B, \omega_1, \omega_2, \phi,$ and $\theta$.
Column D contains the formula you want to fit, all depending on values from Column C (you'll have to populate Column C with initial guesses). Don't forget to use, e.g.,
Code:
$C$1
to retrieve the value from C1.
Column E contains the square of the differences between Column B and Column D. Sum this column at the bottom.

That's the setup. Next, you invoke the Solver routine, and minimize the sum of squares at the bottom of Column E by varying the cells in Column C. If you're in LibreOffice Calc, you have to tell Calc to use a nonlinear solver, or else you'll get an error.

See if that works for you.

HI Ackbach

THanks, I will give it a go.
 
Hi Folks,

An additional idea cross my mind regarding the attachment "trace.png".

This curve comes from a numerical program which converts this trace to the frequency domain and plots all the harmonics $n_k \omega t$ and their amplitudes $a_n$, $b_n$.

What I would like to do is take these harmonics and their amplitudes and enter them into the Fourier series below to reproduce the same trace

x_t=d_0+d_1 \cos( n_1\omega t - \phi)+d_2 \cos( n_2\omega t - \phi)+d_3 \cos( n_3\omega t - \phi)+...

where $d_0=a_0/2$, $d_n=\sqrt (a_n^2+b_n^2)$ and $\phi_n=tan^{-1} (b_n/a_n)$

However, how would I determine $a_0$?
 
Seemingly by some mathematical coincidence, a hexagon of sides 2,2,7,7, 11, and 11 can be inscribed in a circle of radius 7. The other day I saw a math problem on line, which they said came from a Polish Olympiad, where you compute the length x of the 3rd side which is the same as the radius, so that the sides of length 2,x, and 11 are inscribed on the arc of a semi-circle. The law of cosines applied twice gives the answer for x of exactly 7, but the arithmetic is so complex that the...
Is it possible to arrange six pencils such that each one touches the other five? If so, how? This is an adaption of a Martin Gardner puzzle only I changed it from cigarettes to pencils and left out the clues because PF folks don’t need clues. From the book “My Best Mathematical and Logic Puzzles”. Dover, 1994.
Thread 'Imaginary Pythagoras'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top