On Wed, Nov 26, 2014 at 11:31 AM, Chris Swierczewski <[email protected]> wrote:
> Hello,
>
> Has work has been done on modular reduction of `RootOf` objects? (If not, I
> would like to begin implementing this functionality!) What I mean is this:
>
> import sympy
> from sympy.abc import x
> f = x**3 + 2*x + 1
> a = sympy.RootOf(f,0)
> b = a**3
>
> Since $f(a) = 0$ by definition it would be nice to return
>
> print b
> -1 - 2*a
>
> instead of
>
> print b
> a**3
>
> so that expression swell could be curbed.

This is what I get:

In [1]: f = x**3 + 2*x + 1

In [2]: a = RootOf(f, 0)

In [3]: b = a**3

In [4]: a
Out[4]:
      ⎛ 3             ⎞
RootOf⎝x  + 2⋅x + 1, 0⎠

In [5]: b
Out[5]:
                       3
      ⎛ 3             ⎞
RootOf⎝x  + 2⋅x + 1, 0⎠

So looks like it hasn't been implemented yet.

>
> If this hasn't been implemented could anyone give suggestions on what tools
> to keep in mind when overloading `RoofOf.__pow__()` and related operator
> methods? (I'm proficient at Python and OOP but don't have much experience
> with CAS design. Even if this sounds like a bad idea for Sympy I'd like to
> try it out on my own `MyRootOf` class.

Good question. First, I would implement RootOf.mypow(n) and see if you
can figure out how to get the answer you want. That's the hard part.
What's the algorithm to determine which powers simplify and which not?

Then the next question is how to hook this up into sympy, so that it
simplifies automatically, I guess one would need to add an if
statement into the Pow simplification somewhere.

Ondrej

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CADDwiVDb-O6WAZusAQZjYcGmtDNRhFVH6W9kZAnen2b%3D%3DTDrew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to