2
$\begingroup$

I am working with the cosine function with a very large input, like cos(a* t), where t varies between 1 and ~ 200; and a can be as large as 10^8-

I come across, as expected, the artifact error. If I sample t with a stepsize of 0.01 with a 100, I get a plot like this :

enter image description here

Notice, that for large value of a, the sampling of t needs to be fine, otherwise, you will not get regular cosine shape from -1 to 1. Sometimes, wave peaks, and other times wave troughs will be missed, due to low granularity, and you will end up with a different shape of the wave than the theoritical value.

Now, increase a to be 100000, and as expected, the effect is much more pronounced.

enter image description here

My question : Is there a formula / algorithm, to avoid this effect? Is there a formula, that tells you the correct step size for a large value of a ?

I tried to google the following keywords : large input cosine function computer graphics, but that did not help.

Thank you.

$\endgroup$
1
$\begingroup$

There is in fact a way to avoid this effect and it is outlined by the NYQUIST sampling theorem - which states that the sampling rate should be at least twice as high as the maximum frequency of the function of interest.
In this case where cos(a * t) is the function of interest, the frequency is a/(2*pi) - therefore your sampling rate should be greater than 2 * a/(2*pi) (in this case you may even want the sampling rate to be even higher so that the cosine function has a nice curve to it).
To get the step size from this sampling rate just use t = 1/(sampling rate)
Hope this helps :)

$\endgroup$
1
  • $\begingroup$ thank you! made my day! i knew of this in audio processing, but couldnt build the cnnection! you are a hero! $\endgroup$
    – Sean
    Dec 27 '20 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.