Fitting a function to a sinusoidal curve

In summary: I looked at the code and it doesn't seem to specify it.I would need to look at the code and figure out what the values for $a_0$ are.In summary, you can reproduce the trace from a numerical program by entering the harmonics and amplitudes into a Fourier series. However, the values for the amplitude are not specified in the code.
  • #1
bugatti79
794
1
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.

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

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: 76
Mathematics news on Phys.org
  • #2
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.
 
  • #3
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.
 
  • #4
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

[tex]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)+...[/tex]

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$?
 
  • #5
for your question. Fitting a function to a sinusoidal curve is a common problem in many scientific fields, including physics, engineering, and mathematics. There are several mathematical techniques that can be used to fit a function to a sinusoidal curve, depending on the specific parameters and data available.

One approach is to use a least squares fitting method, which involves minimizing the sum of the squared differences between the data points and the fitted curve. This method can be used to find the best-fit values for the parameters A, B, ω1, ω2, φ, and θ in your amplitude modulation expression.

Another approach is to use a Fourier series to approximate the curve. This involves representing the curve as a sum of sinusoidal functions with different frequencies and amplitudes. By adjusting the coefficients of the Fourier series, you can find the best-fit curve for your data.

It is also possible to use non-linear regression techniques, such as the Levenberg-Marquardt algorithm, to fit a function to your data. These methods involve finding the best-fit parameters by minimizing a cost function that takes into account both the data points and the function being fitted.

In conclusion, there are several mathematical techniques that can be used to fit a function to a sinusoidal curve. It may be helpful to consult with a mathematician or data analysis expert to determine the best approach for your specific data and parameters.
 

FAQ: Fitting a function to a sinusoidal curve

What is a sinusoidal curve?

A sinusoidal curve is a mathematical function that describes a repeating oscillating pattern in the form of a sine or cosine wave. It is commonly used to model natural phenomena such as sound, light, and motion.

Why is it important to fit a function to a sinusoidal curve?

Fitting a function to a sinusoidal curve allows us to accurately describe and predict the behavior of a system or phenomenon. It also allows us to analyze the data and extract meaningful information, such as the amplitude, frequency, and phase of the sinusoidal pattern.

How do you fit a function to a sinusoidal curve?

The process of fitting a function to a sinusoidal curve involves finding the best mathematical model that describes the data. This can be done using various techniques such as least squares regression, Fourier analysis, or curve fitting algorithms.

What are the common types of functions used to fit a sinusoidal curve?

The most commonly used functions to fit a sinusoidal curve are sine and cosine functions, as they are the fundamental trigonometric functions that describe the shape of a sinusoidal curve. Other functions that can be used include exponential, logarithmic, and polynomial functions.

What factors can affect the fit of a function to a sinusoidal curve?

The accuracy of the fit depends on several factors, such as the quality of the data, the choice of the mathematical model, and the variability of the data points. Other factors that can affect the fit include noise, outliers, and the presence of multiple frequencies in the data.

Similar threads

Replies
1
Views
904
Replies
9
Views
2K
Replies
4
Views
5K
Replies
1
Views
1K
Replies
6
Views
3K
Back
Top