Best fit to an oscillating function

In summary, the conversation discusses a plot of a function obtained numerically that has oscillations at a high frequency and an envelope with a lower frequency. The speaker is trying to find a function that closely matches this plot and is considering using a Fourier transform for this purpose. They also mention the possibility of downshifting the signal to make it more amenable to the transform. The conversation ends with a discussion about using Mathematica to find the edges of the plot and determine the desired low frequency signal.
  • #1
kelly0303
560
33
Hello! I have a plot of a function, obtained numerically, that looks like the red curve in the attached figure. It is hard to tell, but if you zoom in enough, inside the red shaded area you actually have oscillations at a very high frequency, ##\omega_0##. On top of that you have some sort of envelope, with a lower frequency, ##\omega_1##. I am trying to find a function that comes as close as possible to this. In green is what I obtained using:

$$A\sin(\omega_1 t/2)^2(1+\cos(\omega_0t/2))^2$$
where ##A## is just an overall amplitude (and I shifted everything for clarity). However I am not sure how to get the rest of the behaviour, basically fill in the gaps in my function relative to the red one. Can someone advice me on what functional form would I need to add to my expression to get that? Thank you!

func.png
 
Mathematics news on Phys.org
  • #2
Have you considered a Fourier transform?
 
  • Like
Likes Scottpm, berkeman, FactChecker and 1 other person
  • #3
DaveE said:
Have you considered a Fourier transform?
Thank you! What exactly do you mean? Fourier transform of what?
 
  • #4
kelly0303 said:
Thank you! What exactly do you mean? Fourier transform of what?
Fourier transform of your original signal. It will tell you how to write it as a sum of sines and cosines. If you absolutely to have it as an envelope times a constant oscillation, it will take a bit more work.

If you don't mind sharing the data (at least privately), I would like to take a go at it.
 
  • #5
DrClaude said:
Fourier transform of your original signal. It will tell you how to write it as a sum of sines and cosines. If you absolutely to have it as an envelope times a constant oscillation, it will take a bit more work.

If you don't mind sharing the data (at least privately), I would like to take a go at it.
Ah I see, thank you I will look into that. There is no actual data. The red-line is generated by numerically integrating on ODE, but I am attaching below the points used in that plot.
 

Attachments

  • data.txt
    2.4 MB · Views: 82
  • #6
If each low-frequency cycle contains thousands (or even hundreds) of high frequency cycles, you may have numerical problems with the Fourier transform. You will have to process way more samples than are really needed to answer your question.

Instead, shift the signal down so that your ##\omega_0 ## is lower, keeping your ##\omega_1## structure the same. (Then when you plot it, you will be able to see, let's say 20 cycles of ##\omega_0 /2## within one cycle of ##\omega_1##. After this down shift the signal will be more amenable to Fourier transform with a moderate number of samples.

You can down shift the "carrier" frequency by multiplying the original signal by ##e^{-\omega_2 t}## where ##\omega_2## is a few percent less than ##\omega_0##.

Edit:
As hutchpd has said, you need an 'i' in the exponential.

Downshifting will be a bit more complicated than I have indicated above... I will post later with more details, or maybe someone can fill in the details.
 
Last edited:
  • #7
You need an "i" in the exponential yes?
 
  • #8
hutchphd said:
You need an "i" in the exponential yes?
Yup.

Edit: Wait, I believe there was an i in the original... But anyway.
 
  • Like
Likes hutchphd
  • #9
It will probably work if you just take every 10th or 100th sample (leaving you with say 20 samples per "big" cycle) and pretend that's your actual signal.
 
  • #10
Just for fun, I asked Mathematica to find the edges in the OP's plot:

1678151257093.png


I am now trying to find out if Mathematica can convert the bitmap edges to vectors. Any ideas?

Also, is it correct that the desired low freq. signal is the average of the upper and lower boundaries of the outlines above?
 

1. What is the purpose of finding the best fit to an oscillating function?

The purpose of finding the best fit to an oscillating function is to determine the most accurate mathematical representation of a set of data points that exhibit oscillating behavior. This can be useful in various fields such as engineering, physics, and economics, where oscillations are commonly observed.

2. How is the best fit to an oscillating function determined?

The best fit to an oscillating function is typically determined by using a mathematical technique called curve fitting. This involves finding the parameters of a function that minimize the difference between the function and the given data points. In the case of an oscillating function, this may involve adjusting the amplitude, frequency, and phase of the function.

3. What are some common oscillating functions used to fit data?

Some common oscillating functions used to fit data include sine and cosine functions, as well as more complex functions such as Fourier series or Bessel functions. The choice of function depends on the nature of the data and the underlying physical phenomenon being studied.

4. Can the best fit to an oscillating function be used for prediction?

Yes, the best fit to an oscillating function can be used for prediction, but its accuracy may depend on the quality of the data and the chosen function. It is important to note that extrapolating beyond the range of the given data may lead to less accurate predictions.

5. Are there any limitations to using the best fit to an oscillating function?

One limitation of using the best fit to an oscillating function is that it assumes a continuous and periodic behavior of the data. This may not always be the case in real-world scenarios, and the fit may not accurately represent the data in these cases. Additionally, the accuracy of the fit may be affected by outliers or errors in the data.

Similar threads

  • General Math
Replies
2
Views
716
  • Classical Physics
Replies
17
Views
1K
  • Atomic and Condensed Matter
Replies
1
Views
81
  • Classical Physics
Replies
4
Views
790
  • Advanced Physics Homework Help
Replies
2
Views
816
  • Introductory Physics Homework Help
Replies
17
Views
363
  • Introductory Physics Homework Help
Replies
9
Views
690
Replies
11
Views
2K
Replies
5
Views
355
Back
Top