solve an integral equation embedded with another integral equation by python 3.2
Question: I need to solve an integral equation embedded with another integral equation
by python 3.2 in win7.

There are 2 integral equations.

The code is here:

    
    
    import numpy as np
    from scipy.optimize.minpack import fsolve
    from numpy import exp
    from scipy.integrate.quadpack import quad
    import matplotlib.pyplot as plt
    import sympy as syp
    
    lb = 0 
    def integrand2(x, a):
        print("integrand2 called")
        return x**(a-1) * exp(-x)
    
    def integrand1(x, b, c):
        print("integrand1 called")
        integral , err = quad(integrand2, lb/b, syp.oo , args=(1+c))
        return c/(b*integral)
    
    def intergralFunc1(b,c):
        integral,err = quad(integrand1, 0, 10, args=(b,c)) 
        print("integral is ", integral, " and err is ", err)
        print("b is ", b, " and c is ", c)
        return 10 - integral
    
    def findGuess():
        vfunc = np.vectorize(intergralFunc1)
        f1 = np.linspace(0.01, 10,10)
        f2 = np.linspace(0.01, 10,10)
        result = vfunc(f1, f2)
        plt.plot(f1, result)
        plt.xlabel('f1')
        plt.subplot(211)
    
        plt.plot(f2, result)
        plt.xlabel('f2')
        plt.subplot(212)
        plt.show()
    
    def solveFunction():
        sol= fsolve(intergralFunc1, 5, 5, full_output=True)
        return sol
    
    if __name__ == '__main__':
         findGuess()
    
        sol = solveFunction()
        print("sol is ", sol)
        print("verification: \n")
        print("f(b,c) is ", intergralFunc1(sol[0],5))
    

I got the results that make no sense.

    
    
         integral is  nan  and err is  nan
         b is  [ 5.]  and c is  5
         f(b,c) is  nan
    

Any help would be appreciated !!!


Answer: For some reason `integrand1` is returning a `numpy.ndarray` where it is
expected to return a float.

Also on my machine `numpy` reported

    
    
     y:289: UserWarning: Extremely bad integrand behavior occurs at some points of the
      integration interval.
    

which means that your problem is numerically very instable. Therefore
nonsensical results are to be expected.

