Code Search for Developers
 
 
  

polyroots1d_skel.py from matplotlib at Krugle


Show polyroots1d_skel.py syntax highlighted

#!/usr/bin/env python
"""Simple demonstration of polynomials and root finding."""

import numpy as N
import scipy as S
import pylab as P

def plot_poly(x,y,roots):
    """Simple utility to make a charting screen with x/y axes"""
    P.figure()
    P.axhline(0,color='g')
    P.axvline(0,color='g')
    P.grid()
    P.plot(x,y,'b-')
    P.scatter(roots.real,roots.imag,s=80,c='r')
    P.xlabel('Re')
    P.ylabel('Im')

# Create the coefficients for a polynomial with nroots_minus1 at x=-1, one
# root at -2 and one root at 1:
coefs = XXX  # Hint: use reduce() and N.convolve

# Construct the polynomial and get its roots
pol = S.poly1d(coefs)
roots = pol.r

print 'Polynomial p(x):\n',pol,'\n'
print 'p(x) built with coefs:',coefs
print 'Roots of p(x):',roots

# Sample and plot p(x)
x = XXX
y = XXX

# Show roots
plot_poly(x,y,roots)
P.xlim(-3,2)
P.ylim(-250,100)
P.title('All roots')

# Make a new plot around the -1 cluster of roots (use a window of size eps
# around -1)
eps = 0.05
XXX

# Display on screen
P.show()




See more files for this project here

matplotlib

Matplotlib is a pure python plotting library with the goal of making\r\npublication quality plots using a syntax familiar to matlab users. \r\nThe library uses Numeric for handling large\r\ndata sets and supports a variety of output backends

Project homepage: http://sourceforge.net/projects/matplotlib
Programming language(s): C,C++,Python
License: other

  faces/
    faces_skel0.tgz
    fmatch_skel1.py
  fortran_wrap/
    Makefile
    fib3.f
    test.py
  distributions_skel.py
  erathostenes_skel.py
  fft_imdenoise_skel.py
  fit_synapse_skel.py
  fitting_skel.py
  montecarlo_pi_skel.py
  polyroots1d_skel.py
  qsort_skel.py
  quad_newton_skel.py
  recarray_demo_skel.py
  regress_demo_skel.py
  scrape_key_stats_skel.py
  shoot_skel.py
  spline_demo_skel.py
  stats_descriptives_skel.py
  stats_distributions_skel.py
  trapezoid_skel.py
  wallis_pi_skel.py
  wordfreqs_skel.py