Hi,

On 29 September 2011 05:07, Vinzenz <[email protected]> wrote:

> Hi,
>
> I'm trying to port a Mathematica project to sympy. Therefore, I would
> like to use an algorithm to decompose an expression using Gröbner
> Bases as described in
>
> 8.3 Algebraic Relations, Gröbner Bases: A Short Introduction for
> Systems Theorists ( http://people.reed.edu/~davidp/pcmi/buchberger.pdf
> )
>
> I already figured out, that sympy offers a function to compute Gröbner
> Bases.
> However, what could a solution, similar to what Mathematica's
> PolynomialReduce does in this case, look like in sympy?
> Alternatively, I could for now solve my problem with simple variables
> instead of polynomials and use something similar to Mathematica's
> Coefficient[] to pull out the according coefficients from the
> expression.
>

You may find this
http://mattpap.github.com/masters-thesis/html/src/groebner.html#algebraic-relations-in-invariant-theory
 interesting.

Coefficient[] can be replaced with either Expr.coeff() (partially) or
Poly.nth(), e.g.:

In [2]: (x**2 + 2*x + 3).coeff(x**2)
Out[2]: 1

In [3]: (x**2 + 2*x + 3).coeff(x**1)
Out[3]: 2

Unfortunately (x**2 + 2*x + 3).coeff(x**0) does something different than
expected (see http://code.google.com/p/sympy/issues/detail?id=2558).

In [5]: Poly(x**2 + 2*x + 3).nth(2)
Out[5]: 1

In [6]: Poly(x**2 + 2*x + 3).nth(1)
Out[6]: 2

In [7]: Poly(x**2 + 2*x + 3).nth(0)
Out[7]: 3


>
> This is my Mathematica code for the example:
> ---------------------------------------------------------------------------
> pv = {x1^2 + x2^2,  x]^2*x2^2,  x1^3*x2 - x1*x2^3}
> tau1 =  x1^7*x2 - x1*x2^7
> Vars = {x1, x2, Subscript[j, 3], Subscript[j, 2], Subscript[j, 1]};
> Table[-Subscript[j, i] + pv[[i]], {i, Length[pv]}]
> G = FullSimplify[
>       GroebnerBasis[
>            Table[-Subscript[j, i] + pv[[i]], {i, Length[pv]}], Vars]
>       ];
>
> MatrixForm[G]
>
> {Cf, mRest} = PolynomialReduce[tau1, G, Vars];
> Cf
> mRest
> --------------------------------------------------------------------------
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>
>
Mateusz

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to