[Edu-sig] Algebra + Python

Seth David Schoen schoen@loyalty.org
Mon, 30 Apr 2001 23:54:01 -0700


Kirby Urner writes:

> The Poly objects are in play:
> 
>   >>> f = Poly([2,3,4])
>   >>> f
>   Polynomial: 2*x**2 + 3*x + 4
>   >>> f(10)
>   234
>   >>> f.degree
>   2
>   >>> f.deriv()
>   Polynomial: 4*x + 3
>   >>> df = f.deriv()
>   >>> df(10)
>   43
>   >>> g = Poly([-1,0,0,2])
>   >>> g
>   Polynomial: -1*x**3 + 2
>   >>> g(-1)
>   3
>   >>> dg = g.deriv()
>   >>> dg
>   Polynomial: -3*x**2
>   >>> dg(-1)
>   -3

Could this be extended to a symbolic math implementation?  At least,
could you implement compose, add, subtract, multiply, and divide methods
so that

f.compose(g)
f.add(g)

would work?

-- 
Seth David Schoen <schoen@loyalty.org>  | And do not say, I will study when I
Temp.  http://www.loyalty.org/~schoen/  | have leisure; for perhaps you will
down:  http://www.loyalty.org/   (CAF)  | not have leisure.  -- Pirke Avot 2:5