function calculateNyquist() {
var fmaxInput = document.getElementById('maxFrequency');
var unitSelect = document.getElementById('freqUnit');
var resultBox = document.getElementById('resultBox');
var nyquistResult = document.getElementById('nyquistResult');
var explanationText = document.getElementById('explanationText');
var errorMsg = document.getElementById('errorMsg');
var fmax = parseFloat(fmaxInput.value);
var multiplier = parseFloat(unitSelect.value);
// Reset state
errorMsg.style.display = 'none';
resultBox.style.display = 'none';
// Validation
if (isNaN(fmax) || fmax = 1000000000) {
displayValue = (nyquistRateHz / 1000000000).toFixed(2);
displayUnit = "GHz";
} else if (nyquistRateHz >= 1000000) {
displayValue = (nyquistRateHz / 1000000).toFixed(2);
displayUnit = "MHz";
} else if (nyquistRateHz >= 1000) {
displayValue = (nyquistRateHz / 1000).toFixed(2);
displayUnit = "kHz";
} else {
displayValue = nyquistRateHz.toFixed(2);
displayUnit = "Hz";
}
// Remove trailing .00 if present
if (displayValue.endsWith(".00″)) {
displayValue = displayValue.slice(0, -3);
}
// Display results
nyquistResult.innerHTML = displayValue + " " + displayUnit;
var unitText = unitSelect.options[unitSelect.selectedIndex].text;
explanationText.innerHTML = "To reconstruct a signal with a maximum frequency of " + fmax + " " + unitText + " without aliasing, you must sample it at a rate of at least " + displayValue + " " + displayUnit + ".";
resultBox.style.display = 'block';
}
How to Calculate Nyquist Rate of a Signal
In the world of Digital Signal Processing (DSP) and telecommunications, bridging the gap between the analog world (continuous waves) and the digital world (discrete data) relies heavily on the Nyquist-Shannon Sampling Theorem. This theorem defines the fundamental limits of analog-to-digital conversion.
Whether you are an audio engineer, a telecommunications student, or a data scientist, understanding how to calculate the Nyquist rate is essential to prevent signal distortion known as aliasing.
What is the Nyquist Rate?
The Nyquist Rate is the minimum sampling rate required to fully reconstruct a continuous-time signal from its discrete samples without error. According to the sampling theorem, for a band-limited signal, the sampling frequency ($f_s$) must be strictly greater than twice the highest frequency component ($f_{max}$) present in the signal.
If you sample slower than this rate, high-frequency components will "fold over" into lower frequencies, creating artifacts and distortions that cannot be removed later. This phenomenon is called aliasing.
The Formula
The calculation is straightforward. To find the Nyquist rate, you identify the highest frequency present in your analog signal and multiply it by two.
Nyquist Rate = 2 × fmax
fmax: The highest frequency component (bandwidth) of the signal.
Nyquist Rate: The minimum samples per second required (measured in Hz).
Difference Between Nyquist Rate and Nyquist Frequency
These two terms are often confused but represent reciprocal concepts:
Nyquist Rate: A property of the signal. It is $2 \times f_{max}$. It tells you how fast you need to sample.
Nyquist Frequency: A property of the sampler. It is $f_s / 2$. It tells you the maximum signal frequency the system can handle given a specific sampling rate.
Real-World Examples
Here are some common signal types and their corresponding Nyquist rates:
Signal Type
Max Frequency (fmax)
Nyquist Rate (Minimum Sampling)
Standard Used Rate
Human Voice (Telephony)
3.4 kHz
6.8 kHz
8 kHz
Human Hearing (Audio)
20 kHz
40 kHz
44.1 kHz (CD Quality)
FM Radio
15 kHz
30 kHz
~32-48 kHz (Digital Radio)
Analog TV Video
6 MHz
12 MHz
13.5 MHz
Why Do We Sample Higher Than the Nyquist Rate?
You might notice in the table above that the "Standard Used Rate" is often slightly higher than the calculated Nyquist Rate. For example, CD audio is sampled at 44.1 kHz, even though the Nyquist rate for 20 kHz audio is only 40 kHz.
This "oversampling" is done for practical engineering reasons:
Imperfect Filters: Analog anti-aliasing filters are not perfect "brick walls." They need a transition band to attenuate frequencies above $f_{max}$ before they reach the Nyquist limit. A slightly higher sampling rate provides this buffer room.
Noise Reduction: Sampling higher allows for better signal-to-noise ratios in quantization noise handling.
Step-by-Step Calculation Guide
To use the calculator above effectively, follow these steps:
Identify the Bandwidth: Determine the highest frequency component in your signal. If you are recording a guitar, the highest harmonic might be around 10-12 kHz.
Input the Value: Enter this number into the "Maximum Signal Frequency" field.
Select Unit: Ensure you choose the correct unit (Hz, kHz, MHz, or GHz).
Result: The tool will display the minimum sampling frequency required. In practice, choose a piece of hardware (ADC) that exceeds this number.