[Numpy-discussion] === I REALLY NEED YOUR HELP OUR PYTHON USERS ====
Dag Sverre Seljebotn
Thu Dec 20 13:33:21 CST 2012
On 12/20/2012 07:32 PM, Happyman wrote:
> Hi Python users,
> First of all, Marry coming Cristmas!!! ALL THE BEST TO YOU AND YOUR FAMILY
> I need solution of integration under trapz() rule:
> There are following functions:
> def F1 (const1, x):
> """several calculations depending on bessel
> functions(mathematical functions) jn(), yv() exists in Python"""
> return a,b
> def F2(const1 ,const2, D) :
> """Several calculation process"""
> x = D / const2
> [a , b] = F1 ( const1, x) # Where x - the same as in F1()
> S= a*b # This is (a*b) just an
> example for simply explanation
> return S
> def F3(D, R):
> """Here I also calculated some process. So:"""
> return arg1**arg3 # Just for example
> def Integrate_all(const1, const2, min1, step1, max1):
> R=arange(min1, max1, step1) # This is for function "F3"
> D = arange ( 0.1, 7.0, 0.0001)
> M = zeros ( size(R) )
> for i in range(0,size(R)):
> M [ i ] = integrate. trapz ( ( F2 ( const1, const2, D
> ) * F3 ( D ,R)) , x=D)
> return M
> const1=complex number, const2= float,
> The aim of the calculation is to use Integrate_all function for
> integration function above!!!!!!!
> When I use those functions directly like one by one separately from
> python shell it works very accurately, BUT when I do it as shown above :
> ERROR OCCURS: C:\calculation.py:194: RuntimeWarning: invalid value
> encountered in divide!!!!!! (I think this is occuring in F1()) -->
> bessel functions >>> jn(n,x) and yv(n,x)
Yet you didn't supply the source code for F1(), so nobody will be able
to help you.
(But what you should do is a) figure out which argument range F1 will be
evaluated in ("print const1, x" should get you started if you don't
know), b) write a seperate function that *only* evaluates F1 in various
points in this range (perhaps plots it etc.). That should probably give
you a clue about what you are doing wrong.
The key is to isolate the problem. That will also help you produce a
version of F1 that you feel confident about posting to the list.
Also, please read
More information about the NumPy-Discussion