File: chebyshev.py

package info (click to toggle)
jas 2.7.200-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,732 kB
  • sloc: java: 164,370; python: 14,882; ruby: 14,509; xml: 583; makefile: 545; sh: 349
file content (37 lines) | stat: -rw-r--r-- 568 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#
# jython examples for jas.
# $Id$
#

import sys;

from jas import PolyRing, ZZ
from jas import startLog

# chebyshev polynomial example
# T(0) = 1
# T(1) = x
# T(n) = 2 * x * T(n-1) - T(n-2)

#r = Ring( "Z(x) L" );
r = PolyRing(ZZ(), "(x)", PolyRing.lex );
print "Ring: " + str(r);
print;

# sage like: with generators for the polynomial ring
#is automatic: [one,x] = r.gens();

x2 = 2 * x;

N = 10;
T = [one,x];
for n in range(2,N+1):
    t = x2 * T[n-1] - T[n-2];
    T.append( t );

for n in range(0,N+1):
    print "T[%s] = %s" % (n,T[n]);

print;

#sys.exit();