Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need someone to minimize this nasty function attached using python 2.7.12. I n

ID: 3846458 • Letter: I

Question

I need someone to minimize this nasty function attached using python 2.7.12. I need to be able to let a0,a1,a2,...a10 varry and run some minimzation routine for the ai that yields the smallest Fmin value. I believe I have the kernal of the equation scripted as follows:

import numpy

import math

pi = math.pi

m=11

first = 0.0
second = 0.0
for p in range(1, m):
temporary_sum_first = 0.0
temporary_sum_second = 0.0
for i in range(0, m):
temporary_sum_first += (a[i] * math.cos(2*pi*i*jpm))
temporary_sum_second += ((-a[i])*i* math.sin(2*pi*i*p/m))

# now square it and sum it
first = first + math.pow(temporary_sum_first, 2)
second = second + math.pow(temporary_sum_second, 2)
# at this point, we have finished summing i=0 to i=m-1 for one value of p, we continue this for m-1 values of p.

#Final Summation Value
Fmin=first+second #this is the function I want to minimize

I have had a bit of trouble with people commenting very unhelpful solutions, so I do ask that you don't comment unless you know how to minimize the function as it keeps others from attempting to solve it if they saw someone else commented. If you need farther clarification, please ask! Just know that i gets summed over first, then squared, then summed over j. I really appreciate the help!

min P 21 Li-o 2TTi

Explanation / Answer

import math
pi = math.pi
m=11
first = 0.0
second = 0.0
a = input('Enter value of a:')
for p in range(1, m):
temporary_sum_first = 0.0
temporary_sum_second = 0.0
for i in range(0, m):
temporary_sum_first += (a[i] * math.cos((2*pi*i*p)/m))
temporary_sum_second += ((-a[i])*i* math.sin((2*pi*i*p)/m))
# now square it and sum it
first += math.pow(temporary_sum_first, 2)
second += math.pow(temporary_sum_second, 2)
# at this point, we have finished summing i=0 to i=m-1 for one value of p, we continue this for m-1 values of p.
#Final Summation Value
Fmin=first+second #this is the function I want to minimize

I have made some small changes in the program

Hope this will work as in the mathematical equation you can see that the value of a is not defined

so you need to define a and give a value for a

It will take as a input .