Demo entry 6718242

ps4-151

   

Submitted by anonymous on Mar 02, 2018 at 21:20
Language: Python 3. Code size: 1.2 kB.

# -*- coding: utf-8 -*-
from pylab import *
import math

degree = 0
xrange = 0
rangemax = 0
maxpoint = 0


'''numeral values used in question #2'''

height = 75
freefallacc = 9.8
velocity = 36


'''define x(theta). Refer to analytical method'''

def xoftheta(theta):
    crange = ((-velocity * math.sin(theta) * velocity * math.cos(theta) - \
               velocity * math.cos(theta) * math.sqrt(velocity*velocity*\
                math.sin(theta)*math.sin(theta)+2*freefallacc*height)) \
                / (-freefallacc) )
    return crange;


'''for theta in [0,9.9], step = 0.1 in order to keep 2 sig figures'''

while degree < 10:
    radian = math.radians(degree)
    xrange = xoftheta(radian)
    if xrange > rangemax:
        rangemax = xrange
        maxpoint = degree
    degree = degree + 0.1
    
degree = 10


'''for theta in [10,90], step = 1 in order to keep 2 sig figures'''

while degree < 91:
    radian = math.radians(degree)
    xrange = xoftheta(radian)
    if xrange > rangemax:
        rangemax = xrange
        maxpoint = degree
    degree = degree + 1
    
print ('x attains its maximum value at ', maxpoint, 'degree')

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).