Polynomial+Games

Some tests Rik did with his Squeak Polynomials.

Sometimes we want to evaluate a polynomial at a given value of x: code (Polynomial fromString: 'x + 1') valueAt: 2 3	(Polynomial fromString: 'x8 - 1') valueAt: 2 255	(Polynomial fromString: 'x16 - 1') valueAt: 2 65535	(Polynomial fromString: 'x5 + x4 + x3 + x2 + x + 1') valueAt: 2 63	(Polynomial fromString: 'x5 + x4 + x3 + x2 + x + 1') valueAt: 1/2 (63/32)

code Here are some binomial powers: code | p1 px | p1 _ Polynomial fromString: 'x + 1'. px _ p1. (1 to: 10) do: [ :ix | Transcript print: ix; show: ': '; print: px; cr; endEntry. px _ px * p1. ]

1: x + 1 2: x2 + 2x + 1 3: x3 + 3x2 + 3x + 1 4: x4 + 4x3 + 6x2 + 4x + 1 5: x5 + 5x4 + 10x3 + 10x2 + 5x + 1 6: x6 + 6x5 + 15x4 + 20x3 + 15x2 + 6x + 1 7: x7 + 7x6 + 21x5 + 35x4 + 35x3 + 21x2 + 7x + 1 8: x8 + 8x7 + 28x6 + 56x5 + 70x4 + 56x3 + 28x2 + 8x + 1 9: x9 + 9x8 + 36x7 + 84x6 + 126x5 + 126x4 + 84x3 + 36x2 + 9x + 1 10: x10 + 10x9 + 45x8 + 120x7 + 210x6 + 252x5 + 210x4 + 120x3 + 45x2 + 10x + 1

code See Pascal's triangle? code | px p1 | px _ Polynomial fromString: 'x10 - 1'. p1 _ Polynomial fromString: 'x - 1'. px / p1 x9 + x8 + x7 + x6 + x5 + x4 + x3 + x2 + x + 1

code

zzzz