> < ^ Date: Fri, 07 Jan 1994 10:36:00 +0100
> < ^ From: Alexander Hulpke <hulpke@math.colostate.edu >
< ^ Subject: Re: expressions involving roots of unity

Dear Forum.

In his message, Jakob Hirbawi asked:

Suppose I have an expression involving roots of unity, such as :

```x := [ 0, 1, -3/5*E(20)+3/5*E(20)^9+1/5*E(20)^13-1/5*E(20)^17, 0 ];
```

is it possible to substitute every instance of E(n) in x with some other
function f(n) and have the new expression automatically evaluated? Thanks.

The following function should do the work:

```# replace all instances of E(n) in <list> by <func>(n).
TransformedCyclotomics:=function(list,func)
local n,i,l;
l:=[];
for i in list do
if IsRat(i) then
else
n:=NofCyc(i); # the cyclotomic field used
Add(l,ValuePol(CoeffsCyc(i,n),func(n))); # replace E(n) by func(n)
fi;
od;
return l;
end;
```

This function really ''replaces'' each 'E' by <func>. I don't know, which
use you have in mind, but probably (if your f is somehow ''compatible'' with
the Galois group) you might want to do all calculations in the same
cycloctomic field, containing all cyclotomics in the list.
If you want this function to simulate Galois mappings, you should also look
up GaloisCyc in the manual, which is designed to apply Galois maps.

Hope that helps,

Alexander

```-- Alexander Hulpke, Lehrstuhl D f"ur |Ce po`eme est, en effet, divis'e en
Mathematik, RWTH Aachen            |cinq strophes successivement et respec-
|tivement compos'ees de 3-1-4-1-5 vers,
ahulpke@math.rwth-aachen.de         |   Jacques Bens:  Le sonnet irrationnel
```

> < [top]