简体   繁体   中英

"unsupported operand type(s) for ** or pow() : ' function' and 'int' "

I am trying to solve coupled ODEs . It contains a function raised to power 2.

The following errors appears:

"unsupported operand type(s) for ** or pow() : ' function' and 'int'  "  

The function is:

def psy_trial1(x,params,psy0=0):
    return x*(neural_neural(params,x)
def psy_trial2(x,params, psy0=0):
    return 1+x*neural_network(params,x)
def psy1(x, psy_trial1):
    return A(x)+B(x)*(psy_trial1)**2-psy_trial2

I think the problem is with function power. What is the right way to write a function having some integer power?

Any suggestion or help would be appreciated.

The problem is that you are trying to get power of function psy_trial1 instead of value returned by that function, to fix that you have to call that function. Another bug that I have found is that at the end of return statement in psy1 function you are trying to subtract function psy_trial2 . All fixes are here:

def psy_trial1(x,params,psy0=0):
    return x*(neural_neural(params,x)
def psy_trial2(x,params, psy0=0):
    return 1+x*neural_network(params,x)
def psy1(x, psy_trial1):
    return A(x)+B(x)*(psy_trial1())**2-psy_trial2()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM