Re: Re: A question about algebraic numbers using Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg62814] Re: [mg62798] Re: [mg62762] A question about algebraic numbers using Mathematica
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Tue, 6 Dec 2005 00:03:10 -0500 (EST)
• References: <869C3FFA9CA97944A4EEF55353DE74245D4B91@ST-EXCL05.statoil.net> <200512051841.NAA21123@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Andrzej Kozlowski wrote:
> On 5 Dec 2005, at 23:38, Kent Holing wrote:
>
>
>> thanks
>>Since in my case of interest the quartic q(x) and 2-x are irreducible
>>over Q we must have that GCD[q(x),2-x] = 1 so  there exist
>>polynomials u
>>and v such that u q + v (2-x) = 1.
>>Since u is constant (the degree of u < the degree 2-x) and q(r) = 0 we
>>have that v(2-r) = 1, so
>>v is the inverse of 2-r in Q[r]. Is this an easier way of determing
>>the
>>inverse of 2-r?
>>By the way, could you provide me with the inverse of 2c-r?
>
>
> Yes, you are right of course, but I think you would want Mathematica
> do this for you?  Mathematica has a function PolynomialExtendedGCD in
> the package Algebra`PolynomialExtendedGCD` and this function will do
> exactly what you need when a,b and c are integers but will not work
> with symbols. So although mathematically your argument is correct, I
> do not think Mathematica can be of help in this.

This will work after the next release.

<<Algebra`PolynomialExtendedGCD`

poly =  r^4 - 2*c*r^3 + (c^2-2*a^2)*r^2 + 2*a^2*c*r - a^2*c^2;

In[5]:= {g, {u,v}} = PolynomialExtendedGCD[poly, 2*c-r, r];

The inverse should be v:

In[7]:= InputForm[v]
Out[7]//InputForm=
(-2*a^2*c)/(-5*a^2*c^2 + 4*c^4) + (2*c^3)/(-5*a^2*c^2 + 4*c^4) -
(2*a^2*r)/(-5*a^2*c^2 + 4*c^4) + (c^2*r)/(-5*a^2*c^2 + 4*c^4) +
r^3/(-5*a^2*c^2 + 4*c^4)

We check that we have a reciprocal relation.

In[8]:= PolynomialMod[v*(2*c-r), poly]
Out[8]= 1

> As for your last question, I think it can be done in the same way.
> Here are all the steps again:
>
>
> First define the polynomial:
> In[1]:=
> poly = r^4 - 2*c*r^3 + (c^2 - 2*a^2)*r^2 + 2*a^2*c*r -
>      a^2*c^2;
>
> Next find the polynomial poly1 satisfied by (2c -r):
>
> In[2]:=
> poly1 = First[GroebnerBasis[{poly, v - (2*c - r)},
>      {a, b, c, v}, {r}]]
>
> Out[2]=
> 4*c^4 - 12*v*c^3 - 5*a^2*c^2 + 13*v^2*c^2 - 6*v^3*c +
>    6*a^2*v*c + v^4 - 2*a^2*v^2
>
> Next find the part free of v:
>
> In[3]:=
> free = poly1 /. v -> 0
>
> Out[3]=
> 4*c^4 - 5*a^2*c^2
>
> The polynomial q below is our inverse:
>
> In[4]:=
> poly2 = Cancel[(poly1 - free)/v]
>
> Out[4]=
> -12*c^3 + 13*v*c^2 + 6*a^2*c - 6*v^2*c + v^3 - 2*a^2*v
>
> In[5]:=
> q = Expand[poly2 /. v -> 2*c - r]/free
>
> Out[5]=
> (-2*c^3 - r*c^2 + 2*a^2*c - r^3 + 2*a^2*r)/
>    (4*c^4 - 5*a^2*c^2)
>
> Finally, we check that it really is the inverse, that is, that q*(2c -
> r) gives remainder 1 on division by poly:
>
> In[6]:=
> FullSimplify[PolynomialReduce[q*(2*c - r), poly, r]]
>
> Out[6]=
> {{1/(c^2*(4*c^2 - 5*a^2))}, -1}
>
> Somehow I got -1 so the inverse is actually -q.  (However as it is
> already after midnight here I shall leave it at that).
>
> Andrzej Kozlowski
> [...]

The GroebnerBasis approach is a bit easier if one works with v*(2*c-r)-1
as a generator.

In[12]:= InputForm[v2 = vv /. First[Solve[GroebnerBasis[{poly,
vv*(2*c - r)-1}, {vv,r},
CoefficientDomain->RationalFunctions][[2]]==0, vv]]]
Out[12]//InputForm=
-((2*a^2*c - 2*c^3 + 2*a^2*r - c^2*r - r^3)/(c^2*(-5*a^2 + 4*c^2)))

We check that this agrees with our previous result.

In[13]:= Together[v2-v]
Out[13]= 0

This method is basically how the Algebra` add-on function
PolynomialPowerMod does negative powers.

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Types in Mathematica, a practical example
• Next by Date: Re: Re: Types in Mathematica thread
• Previous by thread: Re: A question about algebraic numbers using Mathematica
• Next by thread: Re: Turning on numerical computation