night_owl89
night_owl89

Reputation: 101

Can someone explain how to correctly pass a tuple as an input variable to fsolve in Python without encountering a NameError?

I am using Python.

I am trying to pass a tuple as an input variable ('myvar') to a function, which I then solve. The error message I receive is

NameError: name 'myvar' is not defined

Here the (minimal) snippet of the code I tried:

from scipy.optimize import fsolve
vss = ('myvar')

def f_nb(*vss):
    nb= 0.8 - myvar
    return nb

def tryit(xx):
    myvar = xx
    zz= f_nb(myvar)
    return zz

solz = fsolve(tryit, (0.2))

solz

Upvotes: 0

Views: 33

Answers (0)

Related Questions