-1

I have an equation where my unknown is h and TR which is an array (2D).

I would like to solve the equation below by bisect method and as a result get a new array(2D), which will represent my h

Tpow,k,t - constant

h = np.empty_like(TR)
def f(h):
     return (-TR+(Tpow-T1)*(1-exp((h**2*alfa*t)/k**2)*(1.0-erf(h*sqrt(alfa*t)/k))))


for i in range(len(TR)):
    for j in range(len(TR[0])):    
        h[i][j] = scipy.optimize.bisect(f,0,600)
Duraa
  • 35
  • 1
  • 6
  • Please read [ask] and [mcve]. You have way too much extraneous code and way too little explanation of your expectations vs reality. – Daniel F Aug 21 '18 at 08:51

1 Answers1

0

np.any() accepts a boolean array and returns a single boolean.

You are passing an array of floats, and then doing the comparison on the single boolean output. This is almost certainly not what you want. So instead of this:

if np.any(f(a)*f(b))>0:

do this:

if np.any(f(a) * f(b) > 0):

i.e., keep your comparisons inside np.any or np.all() Repeat for all the rest

Daniel F
  • 11,893
  • 1
  • 21
  • 50