I am working on a project that requires a function (I'll call it target) that will take an input named parameter_vector and will output an equation for other functions to take as an input. The output equation I am using as a test case is the standard quadratic equation:
Ax^2 + Bx + C
My target function will take a parameter_vector in that looks like:
parameter_vector = [A, B, C]
and will use these indices as coefficients in writing out my equation as an output. Here is my code so far:
def target(parameter_vector):
pv = parameter_vector
x = pv[0]*x**2 + pv[1]*x + pv[2]
return x
As I'm sure you can guess, the following error pops up in my shell:
UnboundLocalError: local variable 'x' referenced before assignment
So I did a little research and came across the lambda variable that is used for place-holding a variable. I tried to input:
x = pv[0]*lambda**2 + pv[1]*x +pv[2]
But this popped up:
File "source_parameters.py", line 7
x = pv[0]*lambda**2 + pv[1]*lambda +pv[2]
^
SyntaxError: invalid syntax
Am I approaching this completely wrong? I'm sure even sure whether the output should be a string or not. Any help would be greatly appreciated!