from numpy import arange, sin, cos, pi from matplotlib.pyplot import plot, xlabel, legend, show def superposition (U1=1.0, U2=1.0, phi=0.0, f=1.0, tmax=4.0, npoints=1000): t=arange(npoints)/(npoints-1)*tmax u1 = U1*sin(2*pi*f*t) u2 = U2*sin(2*pi*f*t+phi) plot(t,u1,'--',lw=.75,label='u1') plot(t,u2,'--',lw=.75,label='u2') plot(t,u1+u2) xlabel("t") legend() show()