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

*disclaimer: I have asked this question quite a few times, so please don\'t post

ID: 3846673 • Letter: #

Question

*disclaimer: I have asked this question quite a few times, so please don't post previous answers*

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. Because I don't know what my ai values are, you'll notice I don't have an input section for them. I do not want an input section for ai, I need a minimization routine that converges to certain ai values such that Fmin is minimized. 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

Explanation / Answer

import numpy

import math

pi = math.pi

m=11
min=0
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
#min value of for each time of the loop after it does the summation
if fmin < min:
min=fmin
else:
continue
#now you can use min after the total #execution of the loop as it will have the #minimum value