Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I've been using

scPhiDecomp[expr_]:= PolynomialReduce[expr, {x^2-y^2,2 x y}, {x,y}]

which works great on

scPhiDecomp[a x^2 + 2c x y -a y^2]
>> {{a,c},0}

but doesn't do what I want on

scPhiDecomp[y (a x^2 + 2c x y -a y^2)]
>> {{0,(a x)/2+c y},-a y^3}

How do I use PolynomialReduce[] to produce {{a y, c y}, 0} on the second expression, while still producing the desired result on the 1st?

Thanks, Keith

share|improve this question

migrated from Jul 29 '12 at 19:40

This question came from our site for people studying math at any level and professionals in related fields.

2 Answers 2

That comment was probably too cryptic, so:

One way would be to let x -> Cos[t/2] and y -> Sin[t/2]; we then have x^2 - y^2 == Cos[t] and 2 x y == Sin[t].

So, something like the following (broken up into stages to make it easier to follow):

expr = y (a x^2 + 2c x y -a y^2);
f1 = Simplify[expr /. Thread[{x, y} -> Through[{Cos, Sin}[t/2]]]];
f2 = TrigExpand[PolynomialReduce[f1, {Cos[t], Sin[t]}, {Cos[t], Sin[t]}]];
f3 = f2 /. Thread[Through[{Cos, Sin}[t]] -> {Cos[t/2]^2 - Sin[t/2]^2, 2 Sin[t/2] Cos[t/2]}]; (*unneeded here, but needed if f2 ends up containing expressions like Cos[t]*)
f3 /. Thread[Through[{Cos, Sin}[t/2]] -> {x, y}]

should do the trick.

share|improve this answer
Actually my first attempt at simplifying my expressions was to convert $2 x y$ and $x^2 - y^2$ into $\sin{2 \phi}$ and $\cos{2 \phi}$ and then apply Simplify[]. The reason I switched back is that one of my long term frustrations with Mathematica's Simplify[] routine is that I've never found a way of controlling its use of half and double angle formulas when working with trig. However, I see that your method is more sophisticated, I'll have to give it a try. – Keith Sep 2 '11 at 6:48
Keith, I'd actually say that Gröbner is more sophisticated (and in some cases a sledgehammer solution). :) – J. M. Sep 2 '11 at 8:19
up vote 3 down vote accepted

One way I learned of solving this problem (response from my post on MathGroup) is to use Gröbner bases:

mb = {2*x*y, x^2 - y^2}; (* my basis *)

gb = GroebnerBasis[mb, {x,y}] (* Groebner basis *)
Out = {y^3, x*y, x^2 - y^2}

convGb = {{x/2, -y}, {1/2, 0}, {0, 1}};

bPoly = c*x^2*y + 2*a*x*y^2 - c*y^3;

{bPolyGb, bPolyGbRes} = PolynomialReduce[bPoly, gb, {x,y}]
Out = {{-c, c*x + 2*a*y, 0}, 0}

bPolyGb.convGb // Simplify
Out = {a*y, c*y}

In this simple case, you can derive convGb by solving $\mathrm{gb} = c \cdot \mathrm{mb}$ by hand (where $c$ is convGb).

For the full story on using Gröbner bases you can start at this post.

The central results therein are the functions moduleGroebnerBasis[] and conversionMatrix[].

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.