Computer algebra with Squeak

David Stes stes at mundivia.es
Wed Aug 26 21:54:37 UTC 1998


 Hello,

 I was working on a project to build a small computer algebra system in
Squeak, and have just updated the package that I made available on the web
at http://cage.rug.ac.be/~stes/squeak.html. 

 (I think this would be a good application of Squeak, in mathematics, and
I've also added the URL of my package to the Squeak Swiki server at
http://minnow.cc.gatech.edu/squeak.20)

 There's already some simple things you can do with the package (and more
to come) : 

 Create a BigInt instance,

one := BigInt int:1 1

 Make a polynomial z+1,

p := Polynomial scalar:one 1
t := Term scalar:one symbol:'z'exponent:1 'z'
p insertTerm:t 'z' + 1

 Square the polynomial,

q := p square 'z'^2 + 2 'z' + 1

 Add a term in a different variable (to get a multivariate polynomial)

t := Term scalar:one symbol:'a' exponent:1 'a'
q insertTerm:t 'z'^2 + 2 'z' + 'a' + 1
q := q square 'z'^4 + 4 'z'^3 + (2 'a' + 6) 'z'^2 + (4 'a' + 4) 'z' + 
'a'^2 + 2 'a' + 1

 Now convert the polynomial from the recursive representation (where 
coefficients are polynomials) to the expanded representations, where the 
polynomial is an (expanded) sum of monomials,

p := q makeExpanded 'z'^4 + 4 'z'^3 + 6 'z'^2 + 4 'z' + 'a'^2 + 2 'a' 
'z'^2 + 4 'a' 'z' + 2 'a' + 1

 The total degree and order of the polynomial,

p degree 4
q order 0

 Get the leading monomial (or term etc.)

p leadingMonomial 'z'^4

 Convert back to recursive representation

p makeRecursive 'z'^4 + 4 'z'^3 + (2 'a' + 6) 'z'^2 + (4 'a' + 4) 'z' + 
'a'^2 + 2 'a' + 1


 I hope to eventually have a good set of 'building blocks' for algebra in
Squeak, and then you could use Squeak for other computations as well
(group theoretical, for instance). 

David.





More information about the Squeak-dev mailing list