380 likes | 399 Views
Explore advanced algorithms for integer and polynomial computations, including Newton Iteration, Chinese Remaindering, and polynomial reciprocal calculations. Learn about residue computation, multipoint evaluation, and polynomial interpolation techniques. Discover how these methods can be applied in various practical scenarios and examine the time complexity analysis for different algorithms.
E N D
Advanced Algebraic Algorithms on Integers and Polynomials Analysis of Algorithms Prepared by John Reif, Ph.D.
Integer and Polynomial Computations • Newton Iteration: application to division • Evaluation and Interpolation via Chinese Remaindering Main Lecture Material: Algorithms on Integers Advanced Lecture Material: Extension of Algorithms to Polynomials
Taylor Expansion (cont’d) • To find root f(x), use Newton Iteration: • Example: • To find reciprocal of x choose find root
Application of Newton Iteration to Reciprocal of an Integer • Input integer x, accuracy bound k • Initialize if x has n bits
Application of Newton Iteration to Reciprocal of an Integer (cont’d) • TheoremInteger Reciprocal can be computed to accuracy 2-n in O(log n) integer mults and additions.
Steven Cooks’s Improvement (His Harvard Ph.D. Thesis) • Key Trick: Since we need only compute yk up to 2k+1 bit accuracy of error on kth stage • Total Time Cost • Where M(n) is time cost to multiply two n bit integers
Other Applications of Newton Iterations on Integers • O(M(n)) time algorithms: • Quotient + divisor of integer division • Square root • Sin, cosine, etc. • Used in practice!
Advanced Topic: Extension to Polynomial ReciprocalDefinition of Polynomial Reciprocal • Reciprocal = polynomial r(x) • where and (x) has degree < n-1
Algorithm: Reciprocal (P(x)) • Input polynomial degree n-1, n is power of 2
Proof of the Reciprocal Algorithm • Theorem: The Algorithm Correctly Computes Reciprocal(P(x)) • Proof by induction
Proof Algorithm Computes Reciprocal (P(x)) (cont’d) • By induction hypothesis, if
Proof Algorithm Computes Reciprocal (P(x)) (cont’d) • At line [3] we compute
Modular Arithmetic • Assume relatively prime P0, P1, …, Pk-1 • Let given x, 0 < x < p
Applications to Arithmetic • But doesn’t extend to division(overflow problems)
Super Moduli Computation • Input p0, p1, …, pk-1, where pi < 2b • Output Super modular Tree:
Super Moduli Computation (cont’d) • Time Cost
Algorithm Residue Computation • Input • Outputx0, x1, …, xk-1, when xi =x mod Pi i=0, and k-1 • Recursive algorithm [1] compute quotient and remainders:
Algorithm Residue Computation (cont’d) [2] recursively compute[3] output for i = 0, 1, …, k-1
Time Cost for Residue Computation • Let D(n) = time cost for integer division = O(M(n)) • Total Time for input size n = k· b
Proof of Algorithm for Residue Computation • Idea of Proof of algorithm Uses fact: if x = q v + r and v mod Pi = 0, then X mod Pi = r mod Pi
Advanced Topic: Residue Computation on Polynomials • Input moduli P0(x), P1(x), …, Pk-1(x) assume each degree < d and relatively prime • Algorithm uses similar Super modular Tree tre , but using polynomials rather than integers
Advanced Topic: Residue Computation on Polynomials (cont’d) • Output for i=0, …, k-1 Qi(x) = Q(x) mod Pi(x) Q(x) has degree < kd • Theorem The Residue Computation can be done in time O(M(n) log n) where n = k· d • Proof Idea use same algorithm as in integer case
Advanced Topic: Multipoint Evaluation of Polynomials by Residue Computation • Input polynomial f(x) degree n-1 and points x0, x1, …, xn-1 [1] for i=0, …, n-1 let Pi(x) = (x-xi) [2] By Residue Algorithm Computer for i=0, …, n-1 f(xi) = f(x) mod Pi(x) [3] output f(x0), …, f(xn-1) • Time Cost O(M(n) log n), = O(n(log n)2)
Polynomial Interpolation • Input evaluation points x0, …, xn-1 values y0, …, yn-1 • Output P(x) where yk = P(xk) for k=0, …, n-1
Polynomial Interpolation (cont’d) • Interpolation formula: • Where
Proof of Polynomial Interpolation • Proof uses identities:
Using Chinese Remaindering for Integer Interpolation • Inputrelatively prime P0, P1, …, Pn-1and yi ∈ {0,…Pi-1} for i=0,…,n-1 • Problem compute y < P0 P1 … Pn-1 s.t. yi = y mod Pi i=0, …, n-1
Using Chinese Remaindering for Integer Interpolation • Generalized Interpolation Formula: • Where • proof
Advanced Topic: Preconditioned Interpolation Preconditioned Case assumes coefficients {ak | k=0, …, n-1} precomputed • Use Divide & Conquer
Time Cost for Preconditioned Interpolation • Assuming {a0, …, an-1} precomputed
Precomputation of {a0, …, an-1} • Compute • Compute bk where bkPk = P mod (Pk)2by Residue Computation O(M(n) log n) • Compute ak = (bk)-1 mod Pk by Extended GCD algorithm
Precomputation of {a0, …, an-1} for Polynomial Interpolations • Here Pi = (x-xi) for i=0, …, n-1 reduces to multipoint evaluation of derivative of Q(x) O(M(n) log n) time!
Conclusion • Polynomial and Integer Computations use similar divide and conquer techniques to solve: • Multiplication • Division • Interpolation and evaluation • Open Problem Reduce from time O(M(n)log n) to O(M(n))
Newton Iteration and Polynomial Computation Analysis of Algorithms Prepared by John Reif, Ph.D.