from numpy import sqrt,arccos,pi import numpy as np ''' Program carousel-range.py At which angle of deflection should a physical pendulum released at the top be released/broken to achieve maximum horizontal distance from the pendulum's axis? How far will it fly (w/o friction)? x = max range in units of radius R of the pendulum co = cos(theta) ''' x = 0. N = 1000000 dc = 0.05/N for i in range(N): co = 0.75 - dc*i xprev = x # calculate the range x si = sqrt(1.-co*co) # sin(theta) tmp = 1.+co x = si +2.*co*(tmp*si + sqrt(tmp*(2.-co*co*tmp)) ) # print(i,rangex(c)) if (xprev > x): break co = co + dc/2 print('\n max found @step', i, '\n', 'max range/R =',np.around((x+xprev)/2,8), '\n', 'cos(theta), theta[deg]:\n', np.around(co,9),' ', np.around(arccos(co)*180/pi,8), '\n')