[go: up one dir, main page]

Menu

[r2564]: / trunk / src / input / fr.input  Maximize  Restore  History

Download this file

84 lines (72 with data), 1.9 kB

--Copyright The Numerical Algorithms Group Limited 1991.

-- Manipulation of factored integers
)clear all

(x,y,z,w): FR INT
-- automatic coercion of integers to factored integers
x := 2^8 * 78^7 * 111^3 * 74534
y := 2^4 * 45^3 * 162^6 * 774325
-- computation of 50!
z1 := factorial 50
z := z1 :: (FR INT)
-- examine the structure in a factor
factorList(z).1
-- extract the factors in another form
factorList z
-- construct an object that has the factors to multiplicity one
r:=reduce(*,[(i.factor :: (FR INT)) for i in factorList(z)])
-- some arithmetic
exquo(z,r)
x*y
y*x
(x*y = y*x) :: BOOLEAN
gcd(x,z)
x+y
-- this is how you multiply the terms together
expand(x+y)
-- now look at quotients
f := x/y
g := (x ^ 9) / y
f * g
(f * g) / (g * primeFactor(2,200))
(f * g) / (g * primeFactor(2,200)) * z


--% Manipulation of factored polynomials
)clear all
)set history on

(u,v,w): FR POLY INT

-- coercion to FR POLY INT involves factoring
u := (x^4 - y^4) :: POLY INT
-- primeFactor creates factors that are asserted to be prime
v := primeFactor(x-y,2) * primeFactor(x+y,2) * primeFactor(x^2 + y^2,1)
w := factor(x^2 + 2*x*y + 2*x + 2*y + y^2 + 1) * primeFactor(x-y,2)
unit w
-- some ways of looking at the components of an elements of FR P I
l := factorList u
factorList v
factorList w
l.1.factor
l.1.exponent
l.1.flag
-- this computes a factored object that is similar to v except that
-- each factor occurs with multiplicity 1
s:=reduce(*,[(i.factor :: FR POLY INT) for i in factorList(v)])
-- some arithmetic
exquo(v,s)
gcd(u,v)
u + v
lcm(v,w)
u * v * w
-- "expand" multiplies the factors together
expand(u * v * w)
-- some quotients
u/w
w/(u*v)
-- %%(-1) is the last result, %%(-2) is the one before that
w/(u*v) * u/w
w/(u*v) + u/w

differentiate(w,x)
differentiate(w,y)

associates?(x,-x)

characteristic()$FR POLY INT

1$FR POLY INT
0$FR POLY INT

D(factor (-x), x)