--Copyright The Numerical Algorithms Group Limited 1991.

)cl all

--  Examples of all the factor functions in the system.

-- factorization of integer numbers
n:=45234258258293
factor n

-- factorization of gaussian integers
m:(Complex Integer) := 1324567+%i*53523582
factor m

-- factorization of polynomials over finite fields
u:UP(x,PF(19)) :=3*x**4+2*x**2+15*x+18
factor u

-- factorization of polynomials over the integers
v:UP(x,INT):= (4*x**3+2*x**2+1)*(12*x**5-x**3+12)
factor v

-- factorization of multivariate polynomial over the integers
w:MPOLY([x,y,z],INT) :=(x**2-y**2-z**2)*(x**2+y**2+z**2)*(z*y+3*z)
factor w

-- factorization of univariate and multivariate over the rational numbers
f:MPOLY([x,y,z],FRAC INT) :=(4/9*x**2-1/16)*(x**3/27+125)
factor f

-- factorization over rational functions
g:DMP([x,y],FRAC POLY INT):=a**2*x**2/b**2 -c**2*y**2/d**2
factor g

-- decomposition of a rational function
r:FRAC POLY INT:= (a**3/b**3-c**3/(b+1)**3)*(a*d+a/c)
factorFraction r

-- factorization over simple algebraic extensions
aa|aa**2+aa+1
p:UP(x,SAEaa) :=(x**3+aa**2*x+1)*(aa*x**2+aa*x+aa)**2
factor(p)$SAEFACT(UP('aa,FRAC INT),SAEaa,UP(x,SAEaa))

-- factorization over algebraic numbers
a:=rootOf(a**2+3)$AN
factor(x**2+x+1,[a])
