Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Squares in Q[r], a question about algebraic numbers in mathematica
Replies: 1   Last Post: Aug 8, 2012 9:36 PM

 Ralph Dratman Posts: 62 Registered: 5/13/11
Squares in Q[r], a question about algebraic numbers in mathematica
Posted: Aug 8, 2012 9:36 PM

Kent,

Not having enough knowledge of algebraic fields, I don't really
understand what you are doing, but in trying to follow it, I moved
your Mathematica function code back into the regular global code area.
Maybe the output from the code in this form will help you understand
what is going on.

I do not recommend you use "Quiet" while testing, as it hides error
messages which you will want to see. Also, I suggest removing the
semicolons ( ; ) from your lines when trying things out in global code, so
you can see the output of each line separately. (However, you must
always use the semicolons inside a module).

I suggest you start every notebook with the following two lines of code:

messageHandler = If[Last[#], Interrupt[]] & ;

The above will make Mathematica halt when any error message is issued.

Please paste the following code, one line at a time, into
a new notebook, such that you get a separate Mathematica
cell for each line. Alternatively, paste all the code into Mathematica
at once, then separate each line into its own cell, using cmd-D (Mac)
or ctrl-D (Windows).

When you test the code, run each line separately by
clicking in its cell and pressing Enter. That allows you to
see individual output below each input cell.

========================================
Code to be entered into Mathematica, one cell per line:
========================================

ClearAll[a7,a,p,r,pExpanded,f,q]

a7 = Root[x^4 + (5/8) x^2 + (5/8) x + (205/256), x, 1]

(* --- function arguments to sq (the same function as SqrtQr) --- *)

a = a7

p = (r^2 + 1)^2 /. r -> a

(* --- end of function arguments --- *)

pExpanded = Expand[p]

f = Check[ToNumberField[Sqrt[pExpanded], a], "non-square"]

q = AlgebraicNumberPolynomial[f, r]

Plus[q]^2

=======================================
End of code to be entered into Mathematica
=======================================

For your information, following is the same code, shown as each
input line followed by the output line I obtained for it. You
might need to check your output from each input line against
what is shown here, in case the email causes errors to appear.

=========================================================
(This should not be pasted into Mathematica, as it contains extraneous text.)
=========================================================

In[13]:= a7 = Root[x^4 + (5/8) x^2 + (5/8) x + (205/256), x, 1]

Out[13]= Root[205 + 160 #1 + 160 #1^2 + 256 #1^4 &, 1]

(* --- function arguments to sq (which is the same function as SqrtQr) --- *)

In[14]:= a = a7

Out[14]= Root[205 + 160 #1 + 160 #1^2 + 256 #1^4 &, 1]

p = (r^2 + 1)^2 /. r -> a

Out[11]= (1 + Root[205 + 160 #1 + 160 #1^2 + 256 #1^4 &, 1]^2)^2

(* --- end of function arguments --- *)

In[15]:= pExpanded = Expand[p]

Out[15]= 1 + 2 Root[205 + 160 #1 + 160 #1^2 + 256 #1^4 &, 1]^2 +
Root[205 + 160 #1 + 160 #1^2 + 256 #1^4 &, 1]^4

In[16]:= f = Check[ToNumberField[Sqrt[pExpanded], a], "non-square"]

Out[16]= AlgebraicNumber[
Root[205 + 40 #1 + 10 #1^2 + #1^4 &, 1], {1, 0, 1/16, 0}]

In[17]:= q = AlgebraicNumberPolynomial[f, r]

Out[17]= 1 + r^2/16

In[18]:= Plus[q]^2

Out[18]= (1 + r^2/16)^2

=========================================================

Good luck!

Ralph Dratman

On Wed, Aug 8, 2012 at 3:18 AM, Kent Holing <KHO@statoil.com> wrote:
> The code below confuses me:
> I thought that it should return for example (r^2+1)^2 when applied to (r^2+1)^2 whatever a is.
> The code is supposed to do the following:
> Given an element p (say polynomial) in Q[r] for a root r of a given polynomial in Q[x], the code should return p as q^2 for q the square root q of p as an element (polynomial) of Q[r] if q exists.
> But, it does not! When applied to (r2+1)^2 it returns in fact (r^2/16+1)^2, using r/4 instead of r?
>
> The code:
> SqrtQr[a_,p_]:=Module[{f,q},
> f=Check[ToNumberField[Sqrt[p//Expand],a],"non-square"]//Quiet;
> q=AlgebraicNumberPolynomial[f,r]//Quiet;
> Plus[q]^2];
> sq[a_,p_]:=SqrtQr[a,p];
>
> If
> a=Root[x^4+5/8x^2+5/8x+205/256,x,1];
> then
> sq[a,(r^2+1)^2/.r->a] returns (r^2/16+1)^2, not (r^2+1)^2.
>
> Any comments are highly appreciated.
> Kent Holing, Norway