A brief note on Waves by Computer: Adding and Fitting . Read it before a test. Try each question at the end before you open its answer.
The travelling wave y = A sin ( k x − ω t ) y = A\sin(kx - \omega t) y = A sin ( k x − ω t ) , with k = 2 π / λ k = 2\pi/\lambda k = 2 π / λ rad/m and ω = 2 π f \omega = 2\pi f ω = 2 π f rad/s. The speed is v = f λ = ω / k v = f\lambda = \omega/k v = f λ = ω / k . A minus sign sends the wave towards positive x x x . A * np.sin(k * x - w * t) draws the whole rope. np.sin wants radians. x[np.argmax(y)] is where the first crest is. Adding waves Waves add point by point: y = y1 + y2. Beats: two close frequencies swell and fade ∣ f 1 − f 2 ∣ |f_1 - f_2| ∣ f 1 − f 2 ∣ times each second. A standing wave is 2 A sin ( k x ) cos ( ω t ) 2A\sin(kx)\cos(\omega t) 2 A sin ( k x ) cos ( ω t ) . Its nodes are half a wavelength apart. A string fixed at both ends has f n = n v 2 L f_n = \dfrac{nv}{2L} f n = 2 L n v . A square wave is a sum of odd harmonics, each smaller than the last. Measured waves The FFT: np.abs(np.fft.rfft(y)) gives the size of each frequency, and np.fft.rfftfreq(n, d) gives the frequencies, 1 n d \dfrac{1}{nd} n d 1 apart. The tallest bar is a first guess for curve_fit(model, t, y, p0=[A, f, phi]). The errors are np.sqrt(np.diag(pcov)). Readings f s f_s f s a second show only frequencies up to f s 2 \dfrac{f_s}{2} 2 f s . A faster wave aliases to ∣ f − f s ∣ |f - f_s| ∣ f − f s ∣ . A worked example What does this print?
The beat frequency. ∣ 103 − 100 ∣ = 3 |103 - 100| = 3 ∣103 − 100∣ = 3 Hz. The beats. In 4 s there are 3 × 4 = 12 3 \times 4 = 12 3 × 4 = 12 beats. It prints 12.
Practice with new numbers
A program to try The program checks the main formulas for a wave of wavelength 2.5 m and frequency 6.0 Hz.
Run it. What is the speed of the wave, in m/s?
1. Change the two beat frequencies to 45 and 51. What does it print?
Mistakes to avoid No 2 π 2\pi 2 π . The sine needs k = 2 * np.pi / lam and w = 2 * np.pi * f. Adding the frequencies. The beat frequency is the difference. No factor 2. The string has f n = n v 2 L f_n = \dfrac{nv}{2L} f n = 2 L n v , not n v L \dfrac{nv}{L} L n v . No first guess for the fit. Take it from the FFT. Reading too slowly. Fewer than two readings in a cycle give a false frequency. Check yourself What does np.sqrt(np.diag(pcov)) give? Stuck? Show a hint Show the answerA wave has k = 3.0 k = 3.0 k = 3.0 rad/m and ω = 12 \omega = 12 ω = 12 rad/s. Which way does it travel in y = A sin ( k x − ω t ) y = A\sin(kx - \omega t) y = A sin ( k x − ω t ) , and how fast? Stuck? Show a hint Show the answerA sensor takes 80 readings each second. What is the highest frequency it can show correctly? Stuck? Show a hint Show the answerWhy does a standing wave have fixed nodes? Stuck? Show a hint Show the answer