Menu

[r2807]: / trunk / course / examples / scipy / roots1d.py  Maximize  Restore  History

Download this file

22 lines (13 with data), 283 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import scipy as S
import pylab as P
coefs = [ 1. , -3.5, -0.5, 11. , -17. , 6. ]
pol = S.poly1d(coefs)
x = P.frange(-4,4,npts=400)
y = pol(x)
P.figure()
P.plot(x,y)
P.axhline(0)
P.ylim(-100,100)
print 'Coefficients of p(x):',coefs
print 'Roots of p(x):',pol.r
P.show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.