Representation of Polynomials: Coefficient Representation Point Value Representation Evaluation at Given X
Representation of Polynomials: Coefficient Representation Point Value Representation Evaluation at Given X
Coefficient Representation
aj xj
Point Value representation
< y0, y1 n-1 > evaluated at < x0, x1 n-1 >
Evaluation at given x
A(x)= a0+ x(a1+ x(a2 a j xj
Choose < x0, x1 n-1 > as the 2n-th roots of unity
k = exp(2 i k/n) = cos(2 k/n) + i sin(2 k/n)
n
Operation on polynomials
Coefficient representation Point value representation
Addition - O(n) Addition - O(n)
C(x)=A(x)+B(x) C(x)=A(x)+B(x)
C[j]=a[j]+b[j] < yc,i > = < ya,i +yb,i >
Multiplication - O(n2) Multiplication - O(n)
C(x)=A(x) o B(x) C(x)=A(x) B(x)
-k] < yc,i > = < ya,i . yb,i >
convolution element wise
Transform to point value Transform to coefficient
> y = V .a > a = V-1 . y
Properties of roots of unity
Group under multiplication: kn j
n=
k+j
n
Cancellation: dkdn = kn
Squaring: ( k+n/2n )2 2k
n
n =(
n
k
n )2 =( k
n/2 )
Squares of n complex n-th roots = n/2 complex n/2-th roots
k )j = (( )n - n-1))=0
k k
n n
(k,j) th entry of V is ( kj )
n
(j,k) th entry of V-1 -kj )/n, shown below
n
[V-1 V]jj -kj /n) (
n n
k -j) /n)
n
-1 V] =1; 0 otherwise so that [V-1 V] = I
jj
Discrete Fourier Transform
< y0, y1 n-1 > = DFT (a0, a1 n-1 )
yk aJ ( kjn aj xj and x= kjn
A[0](x)= a0 + a2 x+ a4 x2 n-2 x
n/2-1
n
Return column vector y
Inverse DFT is same problem with y replacing a
Number Theoretic Algorithms
Problem size is linear => proportional to number
of bits needed to store the number in binary
O(n) for number n is exponential complexity
Fast exponentiation x^n linear in width of n
Convert n to binary
Compute successive squares of x (takes O(lg n))
Use binary string to pick relevant powers of x
Example: 3^11 mod 20 = (1*9*3) mod 20 = 7
(3^8 mod 20) (3^2 mod 20)(3^8 mod 20)
GCD computation
euclid (a,b)
If b==0 then return a
Else return (euclid(b, a mod b))
Correctness: rm+2 is gcd (a,b)
a=q1b+r1, b=q2r1+r2, r1=q3r2+r3 ; ri=qi+2ri+1+ri+2
rm-1=qm+1rm+rm+1 ; rm=qm+2rm+1+rm+2 ; rm+1=qm+3rm+2+0
Now rm+2 divides successively rm+1 , rm, rm-1, a, b
Complexity: gcd(a,b) -> gcd(b,c) -> gcd(c,d) implies b = kc + d
c+d and together with a > b
gives a+b > 2(c+d). Therefore in every two steps, the sum
of the numbers get halved. Hence number of steps (or
calls) would be bounded by log (b) the smaller one.
Worst case: The Fibonacci sequence i.e. a=Fn+1 and b= Fn
Extended Euclid algorithm
Express GCD (a,b) as linear combination of a,b
Say, d=gcd(a,b) = ax +by -> to find integers x, y
Extended_euclid (a,b)
If b==0
return (a,1,0)
( Extended_euclid(b, a mod b)
(
Apply this to (a.b) mod n =1; a,b are multiplicative inverses mod n.
Example: Find multiplicative inverse of 50 mod 71 is 27,
50 and 71 are relatively prime, since gcd(50,71)=1
Primality testing
ve integer,
ap-1 mod p = 1 i.e. a and p are relatively prime
Is_prime(p)
-1
compute x =(ap-1 ) mod p [fast exponentiation]
if x
else repeat several times, using different
PL (property-
belongs to P (reduce and solve)
If any problem in NP is not P-time solvable,
then all NPC problems are not P-time solvable
P. Then L P
Circuit Satisfiability Problem
Take any algorithm that produces output for
given input in P-time => verification => NP
Can map this into program steps
Each program step maps to combinational circuit
Paste these circuits - maps to overall circuit
Program I/O maps to circuit I/O in P-time
All such algorithms are reducible ( P ) to CSAT
CSAT is therefore NPC
Such proof outline possible only for CSAT
Algorithm as computation sequence
Proof of NP-completeness for some L
Prove L belongs to NP (verification decision)