factor x^2-3



Gosse michel a ?crit :
> How can i do for maxima to answer (x-sqrt(3))*(x+sqrt(3))
>   

It depends on what you really want to do. I don't know any maxima 
function solving in terms of radicals any polynomial which is solvable 
by radicals over Q. That could be a nice project, easy for degree 2 (see 
below), a little messy for degrees 3 and 4 (Cardan, Ferrari), harder for 
higher degree (computation of Galois groups and deciding whether they 
are sovable) !

If you just want to express the roots of some polynomial (here x^2-3), 
or factor it,  in terms of some algebraic number r (here sqrt(3)) that 
you consider as "well known"  and relevant for this problem, then you 
can use a second argument to factor, namely the minimal polynomial of 
the algebraic number :

(%i30) factor(x^2-3,r^2-3);
(%o30) (x-r)*(x+r)

of course it looks like a tautology, because it is as hard to define 
sqrt(3) than to factor x^2-3. But

(%i31) factor((x+1)^2-3,r^2-3);
(%o31) (x-r+1)*(x+r+1)

is slightly less trivial, and

(%i32) factor(x^4+1,r^2-2);
(%o32) (x^2-r*x+1)*(x^2+r*x+1)

is more interesting  ; but you have to guess in advance that sqrt(2) has 
something to do with x^4+1, either because you did some drawings with 
roots of unity, or because you previously computed numerically
(%i5) polyfactor:true$ allroots(x^4+1); 
(%o6) 1.0*(x^2-1.414213562373095*x+1.0)*(x^2+1.414213562373095*x+1.0)

Once you get the result in terms of r, you can substitute back sqrt(...) 
in place of r.


If you want to solve quadratic polynomials with rational coefficients, 
you can guess that the discriminant D is relevant, so use the minimal 
polynomial r^2-D.
Here is a function to do the job :

(%i29) 
quadfactor(p):=block([a,b,c,i,f],[c,b,a]:makelist(ratcoeff(p,x,i),i,0,2), 
D:b^2-4*a*c, f:subst(r=sqrt(D),factor(p,r^2-D)))$
(%i30) quadfactor(x^2-x-7);
(%o30) (2*x-sqrt(29)-1)*(2*x+sqrt(29)-1)/4
(%i31) quadfactor(x^2-x+7);
(%o31) (2*x-3^(3/2)*%i-1)*(2*x+3^(3/2)*%i-1)/4

I hope that helps.

Eric