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 2 2042
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.framewor k/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
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.v ersion
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jean.rossier |
last post by:
Hello All,
I am facing a problem while importing pylab library(in a .py program file) via
web browser however the same program works when I execute it from the command
prompt.
my configuration :
Fedora Core 3
Apache 2.0
|
by: Dr. Colombes |
last post by:
On my home laptop computer, I'm trying to install the appropriate
modules so that Python version 2.3.3 and IDLE version 1.0.2 (with an
"import matplotlib.matlab" statement) can produce nice MatLab-like
plots.
I have a matplotlib.matlab-capable Python set-up running OK on my
office desktop, which I obtained after downloading and installing a few
more modules (numarray and numeric, I think).
Now I get the following message about...
|
by: Charles Krug |
last post by:
List:
I'm trying to us pylab to see what I'm doing with some DSP algorithms,
in case my posts about convolution and ffts weren't giving it away.
I've been using pylab's plot function, but I'm finding it a bit
cumbersome.
It works, but if I switch from the interactive window to the plot window
and back, the plot window gets trashed.
|
by: Gary Wessle |
last post by:
Hi
I use debian/testing linux Linux debian/testing 2.6.15-1-686
I found some duplicate files in my system, I don't if the are both
needed, should I delete one of the groups below and which one?
-rw-r--r-- 1 root root 80375 2006-01-24 00:28 /usr/lib/python2.3/site-packages/matplotlib/pylab.py
-rw-r--r-- 1 root root 96202 2006-05-07 13:44 /usr/lib/python2.3/site-packages/matplotlib/pylab.pyc
-rw-r--r-- 1 root root 96202 2006-05-07...
|
by: timw.google |
last post by:
Hi all.
I installed matplotlib 0.87.3 under Python 2.4 on both Linux (FC3) and
Windows XP Pro. On the linux install, I can import pylab, but when I
try to do the same thing on the Windows installation, I get
>>> from pylab import *
Traceback (most recent call last):
File "<pyshell#7>", line 1, in -toplevel-
| |
by: ehenlin |
last post by:
Hi,
How to make pylab work together with py2exe?
Have anyone managed to build a stand alone exe with pylab package?
I have made a small test script but that does not work.
setup.py
------------
|
by: amitsoni.1984 |
last post by:
hi, I have some values(say from -a to a) stored in a vector and I want
to plot a histogram for those values. How can I get it done in python.
I have installed and imported the Matplotlib package but on executing
the code
=hist(eig, 10) # make a histogram
I am getting an error saying "NameError: name 'hist' is not
defined".
Is there any other way to plot histograms over a given range?
|
by: oyinbo55 |
last post by:
I am trying to use the pylab plot command on my laptop running Ubuntu
6.06 (Dapper). Although the plot command works fine on my XP desktop
at work, I cannot open the plot window on the laptop. I edited
matplotlibrc to change interactive: to "True". In idle, I entered the
commands:
The terminal window closed abruptly when I typed the closing
parenthesis.
I have been warned not to use the show() command in interactive mode.
I tried:
|
by: Willem-Jan Vriend |
last post by:
I want to use pylab (matplotlib) on a machine without X11. I'm trying to
generate onthefly graphics for an apache2 web service, so they do not
have to be displayed on this machine !
When i do
pylab.figure()
I get the error
TclError: couldn't connect to display ":0.0"
I tried setting the DISPLAY environment variable to "", ":0.0" but I got
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |