Newton Iteration and Polynomial Computation:: Algorithms Professor John Reif
Newton Iteration and Polynomial Computation:: Algorithms Professor John Reif
Algorithms
Professor John Reif
Taylor Expansion
2
(x - x 0)
f (x ) = f (x 0) + (x - x 0 )f (x 0) +
f (x 0) +. . .
2
f( x )
(x - x )f (x
0
ALG 3.3
f(x )
0
x0
Newton Iteration
and
Polynomial Computation:
(a)
(b)
Reading
Selection:
AHU-Data Chapter 8
to
Newton iteration:
f (x )
x i +1 = x i - i
f (x i )
Example:
To find reciprocal of x
choose f(y) = 1- 1 find root y = 1
xy
x
f (y )
y i +1 = y i - i = y i (2 - y i x )
f (yi)
to Reciprocal of an Integer
input
f o r i=1 to k
do
y k where
p r o o f let error e k
then
e k+1
2 k + 1 bit accuracy.
y i +1 y i (2 - y i x )
output
1 - yk x 1
2k
y 0 = 2- n if x has n bits
initialize
1 - yk x 1
k
2
2
= 1 - yk x
l o gn
M(2 k +1) O (M (n ))
k =o
= 1 - yk + 1 x
where M(n) is time cost to multiply two n
= 1 - x yk (2 - y kx )
= ( ek )
= ( e0 )
bit
= 2
-2
since
1
2
integers.
Other Applications of
Newton Iteration on Integers
Algorithm:
Reciprocal (P(x))
i=0
n-1
i n p u t polynomial
P(x) =
ai x
O(M(n))
time
algorithms:
1 else
a0
[ 2 ] q(x) Reciprocal ( P 1 ( x ) )
n-1
where
P 1 (x) =
i=
used in practice!
ai
i- n
x 2
[3] R( x ) 2r1 ( x ) x ( 2 ) n - 2 - r1 ( x )2 P( x )
3
R(x)
[ 4 ] return
n-2
R( x ) 2r1 ( x ) x ( 2 ) n - 2 - r1 ( x )2 P( x )
3
2n-2
reciprocal
(P(x)) =
= r(x)
x
P(x)
since
where
r (x ) p (x ) = x 2 n - 2 + e (x )
and e (x)
proof
has degree
inductive
P (x ) = P 1 (x ) x + P 2 (x )
P(x)R(x) = 2r 1 ( x ) P 1 ( x ) x
< n-1
2n-2
so r(x) = 1
a0
Substituting
n-2
R (x ) p (x ) = x
w h e r e d e g ( P 1 ) = n - 1, d e g ( P 2 ) n - 1
2
2
3n - 4
=x
- e 1(x )x 2 + r 1 (x )p 2 (x )
3n - 4
- 0(x
2n - 4
R(x)
r 1 (x) = reciprocal (P 1 (x )) then
But
r 1(x ) P1(x ) = x n - 2 + e 1 (x )
so
3
2
+ e 1 ( x ) for r 1 ( x ) p 1 ( x ) ,
By induction hypothesis, if
()
(x)x
we get
n
2
where e 1 (x )
+ 2r 1 ( x ) P 2
- r 1 (x ) p 1 (x )x 2 + r 1 (x )p 2 (x )
by induction
b a s i s n=1 fi P(x) = a0
n
2
r (x ) = x n - 2
r (x ) p (x ) = x
2n - 2
+ o ( x n - 2)
n-2
Modular
Arithmetic
i=0
given x
x
pi
0 x < p,
( x ,..., x
)
0
k-1
where
1-1
log k
to
1-1
P0 P1
Arithmetic:
(w , w , . . . , w )
u op v 1-
k-1
1
0
1
1
P0
P1
P2
Time Cost
op
+, -,
ki M ( 2 ib )
l o gk
v i = v mod p i
problems)
i =0
= O( M (k b) l o gk
Pk - 2 Pk - 1
P2 P3
where w i = ui op vi mod pi
u i = u mod p i
P0 P1 . . . Pk - 2 Pk - 1
P0 P1 P2 P3
where p i < 2b
i n p u t p 0 , p1 , . . . , p k - 1 ,
output
k-1
let p =
10
P3
Pk - 2
Pk - 1
A l g o r i t h m Residue Computation
11
12
k-1
input
x, 0 x < P
Pi
i=0
= O(M(n))
output
x0 , x 1 , . . . , x k - 1
xi = x mod Pi
when
i=0, and k-1
Total Time
recursive
algorithm
( ) + 2k D (b )
T (n ) = 2T n
2
(k -1 ) / 2
x = q 1v 1 + r 1 ,
v1 =
x = q 2v 2 + r 2 ,v 2 =
[ 2 ] recursively
i=0
Pi
2T
k -1
Pi
( 2 . 2 ) r 2 mod P i
+ O (M (n ))
proof of algorithm:
f o r i = 0 ,..., ( k - 1 )
2
f o r i = ( k - 1 ) + 1 ,..., k - 1
2
uses fact if x = q v + r
and v mod Pi = 0, then
x mod Pi = r mod Pi
x mod P i =
( n2 )
+ O (n )
O (M (n ) l o gn )
(k -1)
+1
i =
2
compute
( 2 . 1 ) r 1 mod P i
n = k b
r 1 mod P i
for
i (k - 1 )
2
r 2 mod P i
for
i > (k - 1 )
2
13
Residue
Computation
of
Polynomials
14
Multipoint
Polynomial
Evaluation
n-1
i n p u t moduli
i n p u t polynomial f(x ) =
i=0
problem
ai x
Q(x) degree kd
Easy Cases:
o u t p u t for i=0, ..., k-1
Q i (x) = Q(x) mod Pi ( x )
FFT Case x i = w i
= principal root of unity
'
method
"
f(x ) = f (y ) + x f (y )
where
y = x
'
"
f (x ), f (x ) both degree ( n - 2 )
2
y 0 ,..., y ( n - 1 )
2
2
i + n
2
- 1
= w 2i + n = w 2i = x i = y i
15
16
fi
reduced to FFTn
n-1
f(x ) =
i=0
( 2 ) x i = ba2i + cai + d
(Aho,
Steiglitz,
Ullman)
output
(k )
ai x
and point x 0
k
(x ) =
d f(x )
for k = 0 , . . . n - 1
dx
x = x0
n -1
c i (x
i =0
-x 0 )
Then
f
(k )
(x 0) = k !c k
for i = 0 ,...,n - 1
17
Polynomial
(Lagrangian) Interpolation
18
Multipoint Evaluation by
Residue Computation
input
x 0 ,..., x n - 1
y0 ,..., y n - 1
o u t p u t P(x) where y k = P(xk ) for k=0,...,n-1
y1
y0
yn-1
[ 2 ] By Residue Algorithm
Computer for i=0,..., n-1
f ( x i)
x0
x1
f(x) mod P i ( x )
Interpolation
[ 3 ] output
Time Cost
P (x ) =
where
ak =
proof
formula:
n -1
y k a k (x
k =0
(x k
i k
use
xn-1
i k
-x i )
- xi )
identities:
a k (x - x i ) m o d(x - x k ) = 1
i k
fi a k (x = x i ) m o d(x - x j ) = 0
i k
19
Remaindering)
Preconditioned
20
prime P 0 , P1 ,..., P n - 1
problem
compute y <
precomputed
P Pi s.t.
y i = y mod Pi
coefficients { a k | k=0,...,n-1}
assume
y i e { 0 , . . . , P i - 1 } f o r i = 0 ,...,n - 1
and
i=0,...,n-1
y =
Interpolation
Pi
n-1
Y =
y k ak
k=0
Generalized
i k
Formula:
n -1
y k a k Pi
k =0
i k
n-1
(n - 1 )/2
where
ak =
s i ,k
i k
=
and
y k ak
k=0
Pi
i k
i=0
-1
(n-1)/2
proof
ak
i k
Pi
mod P j =
)(
+
1
0
j =k
jk
i=0
Pi
i = ( n - 1 ) +1
2
Pi
yk ak
i k
i=0
(n-1)
k = ( n - 1 ) +1
2
n-1
n-1
n-1
k = ( n - 1 ) +1
2
n-1
s i ,k = (P i ) m o dP k
Interpolation
y k ak
(n-1)/2
(n-1)/2
k=0
i
i k
i = ( n - 1 ) +1
2
y k ak
i k
i=0
Pi
Pi
21
Precomputation
22
of {a0 ,...,a n - 1 }
n-1
( 1 ) Compute
Preconditioned
()
n
2
+ 2 M
Pi
Compute bk where
()
n
2
{ a o ,.., a n - 1 }
b k Pk = P mod (Pk )
= O(M(n) log n)
assuming
i=0
Interpolation
(2)
T(n) = 2 T
P=
precomputed
( 3 ) Compute
( )
ak = b k
-1
mod Pk
( )
P = d Pk
( )
Pk
+ bk Pk
Pi = d P k + b k
i k
so
bk =
Pi
i k
mod Pk
23
Precomputation of {a 0 ,...,a n - 1 }
for Polynomial Interpolations
here
P i = (x-xi ) for
i=0,...,n-1
24
Conclusion:
Polynomial Computation and Arithmetic
essentially
Equivalent Class of Problems:
bk = Q(x)
(x-xk)
=
n-1
where
Q ( x ) - Q ( x k)
Q ( x )=
since
( x - x k)
( x - x j)
j=0
Q ( x k) = 0
= d Q(x) x = x
dx
k
Examples:
(1)
multiplication
(2)
division
(3)
interpolation
Open
evaluation
Problem: