Search code examples
pythonargumentsfunction-prototypesargument-unpacking

Writing a function of two variables as a function in one variable


Let's say I have the following function that is in 2 variables -

def banana(x,y):
    return exp(((-x**2/200))-0.5*(y+0.05*(x**2) - 100*0.05)**2)

and I would like to write it as -

def banana(x):

where x here is a vector of two variables; if that's possible?

Thanks for your help!


Solution

  • may be something like

    def banana(x):
        return exp(((-x[0]**2/200))-0.5*(x[1]+0.05*(x[0]**2) - 100*0.05)**2)