[Numpy-discussion] === RuntimeWarning: INVALID VALUE > encountered in divide ====

Happyman bahtiyor_zohidov at mail.ru
Thu Dec 20 16:58:30 EST 2012


 Well,
If F1 is run in Python shell, everything is properly working, BUT if call through the functions it is wrongly answering!!!  

def F1 (const1, x): # const1 should be complex number
T1=round(2+x+4*x**(1.0/3.0))
T2=const1*x
T3=const1**2
x1,x2,x3,x4 = sph_jnyn(T1, x) --> 1-standard function in Python

x1=x1[1:] 
x2=x2[1:]
x3=x3[1:]
x4=x4[1:]

a1=x1+1.0j*x3
a2=x2+1.0j*x4
y1,y2= sph_jn(T1,T2) --> 2- standard function in Python
y1=y1[1:]
y2=y2[1:]

b1=x1+x*x2
b2=y1+T2*y2
b3=a1+x*a2

an1= T3*y1*b1-x1*b2
an2= T3*y1*b3-a1*b2
a=an1/an2
bn1= y1*b1-x1*b2
bn2= y1*b3-a1*b2
b=bn1/bn2
return a,b  

 

Четверг, 20 декабря 2012, 20:33  от Dag Sverre Seljebotn <d.s.seljebotn at astro.uio.no>:
>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()
>> function
>>          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
>
>http://www.catb.org/esr/faqs/smart-questions.html
>
>Dag Sverre
>_______________________________________________
>NumPy-Discussion mailing list
>NumPy-Discussion at scipy.org
>http://mail.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20121221/0f30a725/attachment.html>


More information about the NumPy-Discussion mailing list