Re : Re: Re : how to handle roots of unity symbolically ?
Subject: Re : Re: Re : how to handle roots of unity symbolically ?
From: Roberto Fernandez
Date: Sat, 24 Nov 2012 11:52:21 +0100 (CET)
----- Stavros Macrakis <macrakis at alum.mit.edu> a ?crit?:
> (%i2) p: x^12-1$
> (%i3) factor(p);
> (%o3) (x-1)*(x+1)*(x^2+1)*(x^2-x+1)*(x^2+x+1)*(x^4-x^2+1)
> (%i4) tellrat(last(%));
> (%o4) [x^4-x^2+1]
> (%i5) rat(x^17),algebraic;
> (%o5) x^3-x
> (%i6) rat(x^24-1),algebraic;
> (%o6) 0
> (%i7) rat(x^6-1),algebraic;
> (%o7) -2
> (%i8) rat(x^12-1),algebraic;
> (%o8) 0
thanks !
I've not yet fully understood what tellrat does, but the following function seems to do almost exactly what I was searching for:
8<-----------------------------------------------------
simplifie(a,n) := block(
local(b, decomposition, taille, premier, expression),
tellrat(w^n - 1),
b:ev(ratsimp(a),algebraic),
decomposition:ifactors(n),
taille:length(decomposition),
for indice:1 thru taille do (
premier:decomposition[indice][1],
division:n/premier,
expression : sum(w^(i*division),i,0,premier-1),
b:ratsubst(0, expression, b)
), b
);
----------------------------------------------------->8
but it still fails to simplify w^2-w+1 , in the case w^6=1
(%i1) simplifie(w^2-w+1, 6);
(%o1) w^2-w+1
for now, I'm happy with it, nevertheless.