Lesson 1 of 15
Sinusoids
Sinusoids
The sinusoid is the fundamental building block of signal processing. Every real-world signal — audio, radio, seismic — can be decomposed into a sum of sinusoids by the Fourier theorem.
The Sinusoidal Signal
A continuous sinusoidal signal is described by:
where:
- = amplitude (peak value)
- = frequency in Hz (cycles per second)
- = time in seconds
- = phase offset in radians
Angular Frequency
It is often convenient to write the angular frequency:
so the signal becomes .
Example
A 440 Hz sinusoid (concert A) with amplitude 1 and zero phase:
At seconds (quarter cycle), — the peak.
Your Task
Implement:
sinusoid(A, f, t, phi=0)— returnsangular_frequency(f)— returns
import math
def sinusoid(A, f, t, phi=0):
return A * math.sin(2 * math.pi * f * t + phi)
def angular_frequency(f):
return 2 * math.pi * f
# 440 Hz sine at t=0 (zero crossing)
print(round(sinusoid(1.0, 440.0, 0.0), 4)) # 0.0
# At quarter period: t = 1/(4*440)
print(round(sinusoid(1.0, 440.0, 1/1760), 4)) # 1.0
print(round(angular_frequency(60.0), 4)) # 376.9911Python runtime loading...
Loading...
Click "Run" to execute your code.