Friday, December 13, 2019

Periods of Trigonometric Functions


import numpy,pylab; [a,b,c]=[.01*numpy.random.randint(30,99for i in range(3)]
d=numpy.max([a,2.*b,3.*c]); n=numpy.random.randint(5,11)
def coord(m,k,p,n):
    t=numpy.arange(0,k*numpy.pi,k*numpy.pi/(72000.*n))
    x=m*numpy.sin(p*t)*numpy.cos(t); y=m*numpy.sin(p*t)*numpy.sin(t)
    return [x,y]
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('silver')
for [x,y] in [coord(a,8.95,1.9,n),coord(b,12.18,2.3,n),coord(c,11.77,1.7,n)]:
    pylab.scatter(x,y,s=.0001,c=[numpy.random.random(3)])
pylab.title(['a=%.2f'%a,'b=%.2f'%b,'c=%.2f'%c,'d=%.2f'%d]) 
pylab.grid(c='slategray',alpha=.4); pylab.show()

No comments:

Post a Comment