############################################################################################# # A gnuplot script to plot the sum of real harmonics as part of Problem 4.1 in UQP. # Plots with linear combinations of two and six harmonics are shown. # # Y2(x) = cos(2*pi*x/1.5) + cos(2*pi*x/1.6) # Y6(x) = Y2(x) + cos(2*pi*x/1.7) + cos(2*pi*x/1.8) + cos(2*pi*x/1.9) + cos(2*pi*x/2.0) # # written by thomas l. gibson September 12, 2013 ############################################################################################# ######Initialize Constants c1 = 2*pi ###### xrange L0 = 10 # Narrow View #L0 = 40 # Wide View ############################################################################################ f(x) = 0 Y2(x) = cos(c1*x/1.5) + cos(c1*x/1.6) Y6(x) = Y2(x) + cos(c1*x/1.7) + cos(c1*x/1.8) + cos(c1*x/1.9) + cos(c1*x/2.0) #set nokey set key top left set title "Finite Sum of Real Harmonics" set samples 1000 plot [-L0: L0] [-8: 8] Y2(x) t 'Sum of Two Harmonics' lw 2 lc rgb 'red',\ Y6(x) t 'Sum of Six Harmonics' lw 2 lt 1 lc rgb 'blue',\ f(x) t '' lw 3 lc rgb 'black' set xlabel "x" pause -1 "Hit return to make harmonic_wavepacket.ps or cntl c to exit." #z(x) = 0 set terminal postscript enhanced set output "harmonic_wavepacket.ps" #set nokey replot reset exit