Im new to programming and have been set a task to create a function that will sum up an even Fourier series (so no bn's) for 50 different x's between pi and -pi if the user inputs the respective coefficients. As far as I can tell, I need to set up a double for loop, one to set the values of X, and one to do the sum with each of these values and their respective coefficients.
I dont get an error message, and my array of values for X is correct. However, when I input a few coefficients to test it, the output of the sum (cosSumValues) is just an array of 0's.
n is an array of numbers 1-len(coefficients), and coefficients is what the user inputs
Here's my double for-loop:
for i in range(nx):
X = AllValues[i]
for j in range(1, len(coefficients)):
cosSumValues[j] = cosSumValues[j] + coefficients[j]*numpy.cos(n[j]*X)
print xValues, cosSumValues
return xValues, cosSumValues
Thanks for your help.