6.15 algebraic manipulations with radicals (9.8.01)

6.15.1 Les Wright
6.15.2 Robert Israel (10.8.01)
6.15.3 Helmut Kahovec (12.8.01)
6.15.4 Thomas Richard (13.8.01)

6.15.1 Les Wright

I am a mathematical hobbyist puttering around with MVR4 (I know, dated software....) exploring some elementary number theory. In particular, I am trying to get a better grasp of the classic Dirichlet proofs for FLT with n = 5, which is basically high school algebra very ingeniously applied.

I am looking at numbers of the form \(a + b \sqrt {5}\). On raising this to the fifth power and expanding things out I get something that is correct but not compact.

The result is an expression with three terms in a and b and three terms in a, b, and sqrt(5).

How do I tell Maple to collect the terms so that I get the result in this form:

(sum of terms without  sqrt(5)) + (sum of "coefficients" of terms with sqrt(5)) * sqrt(5),

i.e. a number of the form A + B*sqrt(5), where A and B are sums of terms in a and b ?

6.15.2 Robert Israel (10.8.01)

Well, one thing you can do is substitute a symbol for sqrt(5), collect with respect to that, and substitute back. For example:

> R:= (your expression); 
> subs(sq5=sqrt(5),collect(subs(sqrt(5)=sq5,R),sq5));
 

6.15.3 Helmut Kahovec (12.8.01)

This is not at all a trivial task. Below you will find two possible solutions for MapleV/Release4. Each of them works with algebraic numbers of type a+b*sqrt(D) or a+b*sqrt(-D). The first approach does not work within procedures.

Solution 1

> restart; 
> alias(alpha=sqrt(5)); 
> x1:=a+b*alpha; 
 
> x1e:=sort(frontend(collect,[expand(x1^5),alpha])); 
 
         5       3  2          4       4         2  3       5 
 x1e := a  + 50 a  b  + 125 a b  + (5 a  b + 50 a  b  + 25 b ) alpha 
 
> x2:=a+b*I*alpha; 
 
                         x2 := a + I b alpha 
 
> x2e:=sort(frontend(collect,[expand(x2^5),alpha])); 
 
        5       3  2          4 
x2e := a  - 50 a  b  + 125 a b 
 
             4           2  3         5 
     + (5 I a  b - 50 I a  b  + 25 I b ) alpha 
 
> alias(alpha=alpha); 
> rules:={I='i',sqrt(5)=sqrt5}; 
> invrules:=map(u->op(2,u)=op(1,u),rules); 
> subs(invrules,applyop(factor,-1,subs(rules,x1e))); 
 
       5       3  2          4         4       2  2      4   1/2 
      a  + 50 a  b  + 125 a b  + 5 b (a  + 10 a  b  + 5 b ) 5 
 
> subs(invrules,applyop(factor,-1,subs(rules,x2e))); 
 
      5       3  2          4           4       2  2      4   1/2 
     a  - 50 a  b  + 125 a b  + 5 I b (a  - 10 a  b  + 5 b ) 5
 

Solution 2

> restart; 
 
> collecta:=proc(e,K) 
    if has(K,I) then 
      evalc(expand(e)); 
      %-op(-1,%)+map(u->frontend(factor,[u]),op(-1,%)/(K/I))*(K/I) 
    else 
      sort(frontend(collect,[expand(e),K])); 
      map(u->frontend(factor,[u]),%) 
    fi 
  end: 
 
> x1:=a+b*sqrt(5); 
 
> collecta(x1^5,sqrt(5)); 
 
       5       3  2          4         4       2  2      4   1/2 
      a  + 50 a  b  + 125 a b  + 5 b (a  + 10 a  b  + 5 b ) 5 
 
> x2:=a+b*sqrt(-5); 
> collecta(x2^5,sqrt(-5)); 
 
      5       3  2          4           4       2  2      4   1/2 
     a  - 50 a  b  + 125 a b  + 5 I b (a  - 10 a  b  + 5 b ) 5
 

6.15.4 Thomas Richard (13.8.01)

One approach is to use "remove" for the first sum and "select" for the second sum (note the trick to extract sqrt(5)):

> restart: 
> w:=sqrt(5); 
> f:=a+b*w; 
> e:=expand(f^5); 
 
      5      4    1/2       3  2       2  3  1/2          4 
e := a  + 5 a  b 5    + 50 a  b  + 50 a  b  5    + 125 a b 
 
           5  1/2 
     + 25 b  5 
 
> remove(has,e,w)+w*expand(select(has,e,w)/w); 
 
      5       3  2          4    1/2     4         2  3       5 
     a  + 50 a  b  + 125 a b  + 5    (5 a  b + 50 a  b  + 25 b )