0% found this document useful (0 votes)
27 views12 pages

Newton Iteration and Polynomial Computation:: Algorithms Professor John Reif

This document discusses algorithms for polynomial computation and arithmetic. It begins by introducing Taylor series expansion and Newton's method for finding roots of polynomials. It then discusses using Newton's method to efficiently compute the reciprocal of an integer. The document also covers modular arithmetic, residue computation of polynomials, and the Chinese Remainder Theorem for integer interpolation. It concludes by noting that polynomial computation, evaluation, interpolation and arithmetic are essentially equivalent problems.

Uploaded by

raw.junk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views12 pages

Newton Iteration and Polynomial Computation:: Algorithms Professor John Reif

This document discusses algorithms for polynomial computation and arithmetic. It begins by introducing Taylor series expansion and Newton's method for finding roots of polynomials. It then discusses using Newton's method to efficiently compute the reciprocal of an integer. The document also covers modular arithmetic, residue computation of polynomials, and the Chinese Remainder Theorem for integer interpolation. It concludes by noting that polynomial computation, evaluation, interpolation and arithmetic are essentially equivalent problems.

Uploaded by

raw.junk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1

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)

Newton Iteration: application


division
Polynomial Evaluation and
Interpolation (Chinese
Remaindering)

Reading

Selection:

AHU-Data Chapter 8

To find root of f(x),


use

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)

Application of Newton Iteration

to Reciprocal of an Integer
input

observe that since

integer x, accuracy bound k

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

we need only compute y k up to

y 0 = 2- n if x has n bits

initialize

Steven Cook's Improvement


(his Harvard Ph.D. thesis)

Total Time Cost

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

T h e o r e m Integer Reciprocal can be computed


to accuracy 2 - n in O(log n) integer mults and
additions.

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

degree n-1, n is power of 2

O(M(n))

time

algorithms:

- quotent + divisor of integer division


- square root

[ 1 ] if n=1 then return

1 else
a0

[ 2 ] q(x) Reciprocal ( P 1 ( x ) )

- sin, cosine, etc.

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

T h e o r e m : The algorithm computes

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

at line [3] we compute

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

has degree < n - 1


2

()
(x)x

we get

n
2

step let P(x) = P 1 ( x ) x + P 2 ( x )

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

assume relatively prime p 0 , p1 , ..., pk - 1

i=0

given x
x

Super modular Tree:

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

+, -,

But doesn't extend to d i v i s i o n


(overflow

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

x i = x mod p i for i= 0 ,...,k -1


Applications

where p i < 2b

i n p u t p 0 , p1 , . . . , p k - 1 ,
output

k-1

let p =

Super Moduli Computation

10

P3

Pk - 2

Pk - 1

A l g o r i t h m Residue Computation

11

12

Time Cost for Residue Computation

k-1

input

x, 0 x < P

Pi

let D(n) = time cost for integer division

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

[ 1 ] compute quotent and remainders:

( ) + 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

[ 3 ] output for i = 0,1,..., k-1

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

P 0 (x), P 1 (x), ... , Pk - 1 ( x )


relatively prime
each degree d

i n p u t polynomial f(x ) =

i=0

problem

ai x

evaluate f(x) at x 0 , x1 ,..., x n - 1

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 )

T h e o r e m The Residue Computation can be


done in time O(M(n) log n) where n = k d

where

y = x

'
"
f (x ), f (x ) both degree ( n - 2 )
2

p r o o f use some algorithm as in integer case.

fi needed to only evaluate at


( n - 2 ) points
2
where

y 0 ,..., y ( n - 1 )
2
2

i + n
2

- 1

= w 2i + n = w 2i = x i = y i

15

Other Easy Cases

16

O(n log n) time

( 1 ) x i = bai for i=0,..., n-1


(Chirp Transform)

fi

Single Point Evaluation of


all Derivatives of Polynomial
input

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 ) =

solve by divide & conquer similar to FFT

d f(x )
for k = 0 , . . . n - 1
dx
x = x0

Taylor Series Representation of


f (x ) =

n -1

c i (x

i =0

-x 0 )

Then
f

(k )

(x 0) = k !c k

fi reduces to case of evaluation at


xi = ab

for i = 0 ,...,n - 1

17

Polynomial
(Lagrangian) Interpolation

18

Multipoint Evaluation by
Residue Computation
input

x 0 ,..., x n - 1

i n p u t polynomial f(x) degree n-1


and points x 0 , x1 ,...,x n - 1
[ 1 ] for i=0,..., n-1
let P i (x) = (x-x i )

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

f(x 0 ),..., f(x n - 1 )


O(M(n) log n),
=O(n(log n)2 )

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

Integer Interpolation (Chinese


i n p u t relatively

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

Use Divide & Conquer:

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 )

by Residue Computation O(M(n) log n)

= O(M(n) log n)

assuming

i=0

Interpolation
(2)

T(n) = 2 T

P=

precomputed

( 3 ) Compute

( )

ak = b k

-1

mod Pk

by Extended GCD algorithm


p r o o f s i n c e b k Pk = P mod
then
so

( )

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

fi reduces to multipoint evaluation of


derivative of Q(x)
O(M(n) log n) time!

Examples:
(1)

multiplication

(2)

division

(3)

interpolation

Open

evaluation

Problem:

reduce from time O(M(n)log n)


to O(M(n))

You might also like