So, I've been working on a signal described by the equation $$y(t) = \cos(2\pi \ |sin(2\pi t)|).$$ On paper, I've calculated a sampling frequency of at least 2 cycles/sec, since the frequency of my signal is bound between 0 and 1 cycles/sec. However, while working on it in MATLAB I need to have the sampling frequency by ten times that amount for perfect reconstruction, and I'm not exactly sure as to why that might be.

I'm attaching the code below in case it's of any use. Thanks in advance!

% Define the sampling frequency
fs = 20;
Ts = 1/fs;

% Anonymous function definition of function x_a
y_og = @(t) cos(2.*pi.*abs(sin(2*pi*t)));

% Reconstruct x_a(t) from it samples
prompt = "Enter number of terms p: " ;
p = input(prompt);
t = linspace (-5, 5, 401);
y_rec = zeros(size(t));
for i = 1 : length(t)
    for k = -p : p
    y_rec(i) = y_rec(i) + sum(y_og(k.*Ts) .* sinc(fs .* (t(i) - k.*Ts)));

% Graph the function
plot (t, y_og(t), t, y_rec);
title(['Reconstruction using p = ', num2str(p)]);
xlabel('t (sec)');
  • $\begingroup$ Please show your paper work as well. $\endgroup$
    – Hilmar
    Commented Jun 6, 2023 at 18:35

2 Answers 2


On paper, I've calculated a sampling frequency of at least 2 cycles/sec, since the frequency of my signal is bound between 0 and 1 cycles/sec.

How did you figure out that one ? The Taylor expansion of a cosine is given as

$$ \cos(x) = 1-\frac{x^2}{2!}+\frac{x^4}{4!}-\frac{x^6}{6!} ... $$

For $x(t) = 2\pi\sin(t)$ you are going to have a lot of $\sin^n(t)$ terms there which leads to plenty of higher harmonics.

The signal is not bandlimited so it can't be sampled without aliasing. Best you can do is to crank up the sample rate until the residual aliasing error is small enough for your specific application.

  • 1
    $\begingroup$ Possibly relevant. The suggestion there is to look at the infinite sum of Bessel functions and then integrate those. Might not be much use! :-) $\endgroup$
    – Peter K.
    Commented Jun 6, 2023 at 19:25
  • $\begingroup$ Well, my thought was that the frequency of my signal is basically the absolute value of a sine wave that it would have to be limited to f ∈ [0, 1]. Unless of course there's something else I'm missing. $\endgroup$
    – aofarmakis
    Commented Jun 6, 2023 at 20:22
  • 1
    $\begingroup$ I have no idea why you think $|\sin(t)|$ is bandlimited. The fundamental frequency is double the sine's frequency (i.e. $4 \pi \frac{\text{rad}}{s}$ but there is an infinite number of even harmonics. $\endgroup$
    – Hilmar
    Commented Jun 6, 2023 at 21:32

It's always good to do a check plot. I believe you're being mislead by the outer cosine, and not taking into account the fact that you're taking the cosine of a nonlinear function of time (the sine).

Here's your signal in the interval $t \in [0, 1]$.

enter image description here

There's some notable features of this:

  • It repeats four times in one time unit
  • It's a mix of pointy bits and well-rounded bits

All in all, this means that it has components at much higher frequencies than 1.

This is a sinusoid of a sinusoid -- as such, its spectrum will be a Bessel function. In general, the spectrum of something like this will extend into infinity; if that is the case here then there is no finite sampling frequency that will result in a mathematically perfect reconstruction -- just some compromise sampling rate that'll result in a good-enough reconstruction.

  • $\begingroup$ Never heard of a Bessel function, but I'll definitely look into it! Intuitively to me it sounds like maybe this has something to do with the rate of change of the signal, right? Also, will it always extend infinitely, or are there cases where that doesn't occur? $\endgroup$
    – aofarmakis
    Commented Jun 6, 2023 at 20:28
  • $\begingroup$ I was assuming that you already understood the concept of a signal being composed of spectral components, and what bandwidth meant, and that you had just failed to do a check plot. I may be wrong -- how much do you understand about the Fourier transform of a signal, and the fact that a signal may repeat at one Hz and yet still have components going out to infinite frequencies? $\endgroup$
    – TimWescott
    Commented Jun 7, 2023 at 4:37
  • $\begingroup$ I understand a signal may have harmonics (i.e. multiples of the base frequency), and that the signal's Fourier transform basically describes its energy over the frequency spectrum rather than how we usually see it, i.e. as the energy of the signal over time, but that's about it for the most part. When it comes to the intricate details relating to the mathematics of it, I can't say I know much currently. $\endgroup$
    – aofarmakis
    Commented Jun 7, 2023 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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