Re: pylab, matplotlib ... roots function question
Hi, [...] No, that's actually wrong. What version of numpy are you using? With a recent SVN checkout of numpy, I get the correct answer: In [3]: roots([1,0,0]) Out[3]: array([ 0., 0.]) In [17]: import sys, numpy In [18]: sys.version Out[18]: '2.5 (r25:51908, Sep 23 2006, 01:23:14) \n[GCC 4.1.1]' In [19]: numpy.version.version Out[19]: '1.0rc1' moon:/pool/PROG/python # uname -a Linux moon 2.6.16.13-4-smp #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux I think I will get and compile newer version of source BTW, I also look for good (more or less complete and/or interessting) tutoruals on signal processing with python something like low/high-pass filtering/ploting of wave files etc I would appreciate pointers very much. I am learning this at the moment, when it all starts to make sense to me, I will write such a tutorial on my own later Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
pylab, matplotlib ... roots function question
Hello NG, given this call to roots funtion from pylab In [342]: roots([0,2,2]) Out[342]: array([-1.]) as far as I understand it [a0,a1,a2] stands for a0+a1*x+a2*x^2 in the above case it yields 2x^2+2x = 2x(1+x) and the roots are 0 and -1 I am wondering why roots function gives me only the -1 second try In [343]: roots([1,0,0]) Out[343]: array([], dtype=float64) ok, as it should be In [344]: roots([0,0,1]) Out[344]: array([], dtype=float64) here again, 0 is the root of x^2 Do I miss something important? Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: pylab, matplotlib ... roots function question
Schüle Daniel wrote: Hello NG, given this call to roots funtion from pylab It's actually from numpy and numpy questions are best asked (and best answered!) on numpy-discussion. http://www.scipy.org/Mailing_Lists In [342]: roots([0,2,2]) Out[342]: array([-1.]) as far as I understand it [a0,a1,a2] stands for a0+a1*x+a2*x^2 in the above case it yields 2x^2+2x = 2x(1+x) and the roots are 0 and -1 I am wondering why roots function gives me only the -1 No, it's the other way around. In [1]: from numpy import * In [2]: roots? Type: function Base Class: type 'function' Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy-1.0.2.dev3507-py2.5-macosx-10.4-i386.egg/numpy/lib/polynomial.py Definition: roots(p) Docstring: Return the roots of the polynomial coefficients in p. The values in the rank-1 array p are coefficients of a polynomial. If the length of p is n+1 then the polynomial is p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n] So you were really solving 2*x + 2 = 0, the single root of which is -1. second try In [343]: roots([1,0,0]) Out[343]: array([], dtype=float64) ok, as it should be No, that's actually wrong. What version of numpy are you using? With a recent SVN checkout of numpy, I get the correct answer: In [3]: roots([1,0,0]) Out[3]: array([ 0., 0.]) -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list