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()