a small repo to experiment with simple computer algebra. a place where I kind of test out ideas.
- clone repo:
git clone https://github.com/Jobhdez/classes.git
- run tests:
pytest -q tests.py
- load files:
exec(open(<file>).read())
pip3 install pytest
brew install git
for macsudo apt install git
for Ubuntu
for the linear algebra system look at the tests for examples.
>>> exec(open('poly.py').read())
>>> poly = Poly(3,2,1)
>>> poly
Polynomial(3, 2, 1)
>>> add1 = Addition.compute(poly, poly)
>>> add1
Polynomial(6, 4, 2)
>>> composite = CompositeAddition(poly, poly, poly)
>>> composite.compute()
>>> sub = Subtraction(poly, poly)
>>> sub
<__main__.Subtraction object at 0x105178a60>
>>> sub.compute()
Polynomial(0, 0, 0)
>>> op = CompositeSubtraction(sub.compute(), sub.compute(), sub.compute())
>>> op.compute()
Polynomial(0, 0, 0)
>>> sub.poly
Polynomial(7, 8, 9)
>>> poly1 = sub.poly
>>> poly2 = sub.poly2
>>> sub_composite = CompositeSubtraction(poly, poly, poly2)
>>> sub_composite.compute()
Polynomial(-7, -8, -9)
>>> poly = Poly(5,4,3,2,1)
>>> eval_poly(poly, 3)
Integer(547)
>>> poly = Poly(4,3,2,1)
>>> deriv = Deriv(poly)
>>> deriv.compute()
Polynomial(12, 6, 2)
-- Job