Question: I need help revising this script in python 2.7.12. Instead of ai just being an input for 1 value, i need ai to range from
I need help revising this script in python 2.7.12. Instead of ai just being an input for 1 value, i need ai to range from a0-a10, such that I can input values for each one. i = 10 would be m-1 in this case. Can someone help me rewrite this code in this way? For further intuition on what the function is, I have its derivation circled in red.
#importing math for mathematical operation import math
#getting input from user ai=input('Enter a value of ai=')) m=11 first=0 second=0 pi=3.14 #calculation for summation for i in range(0,m-1): for p in range(1,m-1): first=first+ai*math.cos(2*pi*i*p/m) second=second+(-ai*i)/m*math.sin(2*pi*i*p/m) first=math.pow(first,2) second=second*math.pow(m,2) Fmin=first+second print("Summation value:") print(Fmin)
a Cos(tm M-1 m-1 21Tip P m-1 m-1 ofiP Sm min m I m- 1 to be minimized want ai for i: at 6:21P 2TTip m-1 m-1 di Sin m m o P Say m 5, for i,j
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
