SRL Archive - Python/Perl Help and Tutorials

Python Assignment Help


Shield

2015-10-11 19:06:01

Alright… I am really bad with the complex mathematical side of programming so this stupid assignment is getting me really frustrated. Luckily this is the only assignment in this course that involved this much math. I've been working on this part for the past day or two and cannot seem to get it done properly. I have edited this code close to 100 different equations and none of them have worked. In this equation I was able to get the total correct but not the term.

Here is my problem:


This is what I've got for code:


print('\nTERMS OF SERUES USING HIGH PRECISION')
angle_rad = 40
COSX = math.cos(angle_rad)
print('\nAngle: 40 radians')
print('cos of Angle:', COSX)
print('Big power of 10: 1e+40 of type', type(1**40))
print('\n%')

count = 1
BIG10_SQ = (10**40)**2
bigXsq = (angle_rad * 10**40)**2
total = 10**40
term = 10**40

while abs(term) > 3:
term = -term * bigXsq // (2 * count) // (2 * count - 1) // BIG10_SQ
total += term
print('\n%7.0f Term: %60.0f' % ((count), term))
print(' Total:%60.0f' % (total))
count += 1
print(COSX)



I am not worried about the format of the output, I am mainly doing my best to get the main equation correct to get the proper output in the picture with the given equation.

Any help would be greatly appreciated!