Polynomials

advertisement
Polynomials
Content
Evaluation
Root finding
Root Bracketing
Interpolation
Resultant
2
Introduction
Best understood and most applied functions



Taylor’s expansion
Basis of parametric curve/surface
Data fitting
Basic Theorem:


Weierstrass Approximation Theorem
Fundamental Theorem of Algebra
3
Evaluation – Horner’s Method
p( x)  an x  an1 x  an2 x  an3  a1 x  a0
Compare number of
multiplications and
additions
Evaluate p(t)
p(t) = b0
4
Details
p( x)  a0  a1 x  a2 x 2  a3 x 3
p(t )  a0  t a1  t a2  ta3 
b3  a3
b2  a2  tb3
b1  a1  tb2
p(t )  b0  a0  tb1
5
b3  a3
b2  a2  tb3
b1  a1  tb2
Details (cont)
p(t )  b0  a0  tb1
p( x)  a3 x 3  a2 x 2  a1 x  a0
 b3 x 3  b2  b3t x 2  b1  b2t x  b0  b1t 
 b0  x  t b3 x 2  x  t b2 x  x  t b1
 b0  x  t q( x)
p( x)  q( x)  x  t q( x)
p(t )  q(t )
q( x)  b3 x2  b2 x  b1
Evaluate p(t) and p’(t)
p(t) = b0
p’(t) = c1
6
Evaluating xk Efficiently
Instead of using pow(x,k), or any
iterative/recursive subroutines, think
again!
The S-and-X method: S(square)
X(multiply-by-x)
See how it works in the next pages
Understand how to implement in
program
7
Say the exponent k in base-2: a2a1a0
(k>3)
Each symbol, S or X,
represents a multiplication
Except for the leading digit,
replace 1 by [SX], 0 by [S]
10111 23
[ S ][SX ][SX ][SX ]



2




x

x

x

 x


 x 12 2 12 12 1
2
2 2
 x 23
# of :
7
111 7
[ SX ][SX ]
110  6
[ SX ][S ]
x  x   x x   x 
2
2
2
2
101 5
[ S ][SX ]
x    x
2 2
 x 12121
 x 1212 0
 x 12 0 21
 x7
 x6
 x5
4
3
3
8
Implementation
Left-to-right scan
Right-to-left scan
10111 23
[ S ][SX ][SX ][SX ]



2


2 2
 x   x  x   x


12  0 2 12 12 1
x
x
2
2
2
2
2
2
23
11
5
2
1
0
1
1
1
0
1
23
z
1 0 1 1
x16 x8 x4 x2
1
x
9
[Multiplication, division]
FFT…
GCD of polynomials (Euler algorithm)
10
Roots of Polynomials
Low order polynomials (for degree 4)
Quadratics
Cubics
Hi-precision formula
for quadratics
Quartics: see notes
11
Calculator City (ref)
12
Root Counting
P(x) has n complex roots, counting
multiplicities
If ai’s are all real, then the complex roots
occur in conjugate pairs.
Descarte’s rules of sign
Sturm’s sequence
Bounds on roots
[Deflation]
13
Theorems for Polynomial Equations
Sturm theorem:

The number of real roots of an algebraic
equation with real coefficients whose real
roots are simple over an interval, the
endpoints of which are not roots, is equal
to the difference between the number of
sign changes of the Sturm chains formed
for the interval ends.
14
Sturm Chain
15
Example
f ( x)  x 5  3 x  1
x  1.21465,  0.334734, 0.0802951 1.32836i, 1.38879
16
Sturm Theorem (cont)
For roots with multiplicity:


The theorem does not apply, but …
The new equation : f(x)/gcd(f(x),f’(x))
 All roots are simple
 All roots are same as f(x)
17
Sturm Chain by Maxima
18
Maxima (cont)
19
Descarte’s Sign Rule
A method of determining the
maximum number of
positive and negative real
roots of a polynomial.
For positive roots, start with
the sign of the coefficient of
the lowest power. Count the
number of sign changes n as
you proceed from the lowest
to the highest power
(ignoring powers which do
not appear). Then n is the
maximum number of positive
roots.
For negative roots, starting
with a polynomial f(x), write
a new polynomial f(-x) with
the signs of all odd powers
reversed, while leaving the
signs of the even powers
unchanged. Then proceed as
before to count the number
of sign changes n. Then n is
the maximum number of
negative roots.
3 positive roots
4 negative roots
20
Computing Roots Numerically
Newton is the main method for root finding
Can be implemented efficiently using Horner’s
method
Quadratic convergence except for multiple
root
Use deflation to resolve root multiplicity; but
can accumulate error; polynomials are
sensitive to coefficient variations
Newton-Maehly’s method: roots converges
quadratically even if previous roots are
inaccurate
21
22
Experiment
P(x)=(x-1)(x-2)(x-3)(x2+1)
Assume two imprecise roots have been
found, 1.1 & 1.9
The deflated (cubic) polynomial is then
x3-3x2+0.91x-3
23
Original quintic
Converged to 3
in many steps (5 was not a
good guess for 3)
Deflated cubic
Faster convergence, but
solution was plagued with the
propagated error
Maehly procedure
Fast convergence;
accurate solution
xk 1  xk 
p( xk )
p( xk )  p( xk ) xk 11.1  xk 11.9


24
Polynomial Interpolation
Given (n+1) pairs of points (xi,f(xi)) find
a nth-degree polynomial Pn(x) to pass
through these points
Compute the function value not listed in
the table by evaluating the interpolating
polynomial
25
Lagrange Polynomial
High computational cost; cannot reuse
points
Divided difference: a better alternative
26
Divided Difference
27
Divided Difference (cont)
28
29
Resultant (of two polynomials)
An expression involving polynomial
coefficients such that the vanishing of
the expression is necessary and
sufficient for these polynomials to have
a common zero.
30
Resultant (cont)
with
The above system has common zero:
The equation Qz = 0 has nonzero solution IFF R=det(Q) vanishes.
R is called the resultant of the equations.
31
Example
 x2  x  2  0
 2
x  4x  3  0
1 1 2
1
1 2
R
0
1 4 3
1 4 3
 x2  x  2  0
 2
x  4x  3  0
1 1  2
1 1  2
R
 8
1 4 3
1 4 3
32
Sylvester Matrix and Resultant
33
Applications of Resultant
II. Algebraic curve
intersection
I. Common zero
 p ( x)  0

 q ( x)  0
III. Implicitization
Param ateric curve:  (t )   p (t ), q (t ) 
 p ( x, y )  0

 q ( x, y )  0
R(x) = 0 IFF
intersection exists
Find corresponding im plicitequat ion
F ( x, y )  0 for t hesame curve
 p (t )  x  0

 q (t )  y  0
34
Find Common Zero
The system has simultaneous zero iff
the resultant is zero
35
Result from Linear Algebra
has non-trivial
solution if det(A) = 0
A reduced system (remove row n) gives the ratio:
Ai: remove column i
36
Sylvester Resultant
To find the common zero, consider the
reduced system
37
Resultant in Maxima
x as independent
variable
1  x 2  Ay  0

2
 B  xy  y  0
1
0
Ay  1
R  y y2  B
0
0
y
y2  B
38
Algebraic Curve Intersection
 p ( x, y )  x 2  y 2  1  0

 q( x, y )  xy  1  0
No real roots; no intersection (circle & hyperbola)
39
Algebraic Curve Intersection
 p( x, y )  x  12  y 2  1  0

q( x, y )  xy  1  0

2 real roots; 2
intersection
points
40
Implicitization
The above system in t has a common zero whenever (x,y)
is a point on the curve.
… a parabola
Application: parametric curve intersection
Find the corresponding parameter of (x,y) on the curve
41
Parametric Curve Intersection
c1 : p(t )  x(t ), y(t )
implicitize
c2 : q(s)  x(s), y(s)
Cubic Bezier curve and
its control points
f(x,y)=0
F(s)=f(x(s),y(s))=0
Find roots in [0,1]
Bernstein polynomial
42
Quadratic Bezier
Curve Intersection
 x1 
 x2  2
 x(t )   x0 
2
p(t )  
   y  1  t    y  21  t t   y t
y
(
t
)

  0
 1
 2
 x0 1  t 2  x1 21  t t  x2t 2 

2
2




y
1

t

y
2
1

t
t

y
t
1
2 
 0
  x0  2 x1  x2 t 2  2 x1  2 x0 t  x0 


2




y

2
y

y
t

2
y

2
y
t

y
1
2
1
0
0
 0
Sketch using de
Casteljau
algorithm
[1, 2]
0 1  2 
 2t

c1 (t ) :  ,  ,   : c1 (t )  

2
0 1  1
 3t  2t 
 0   1   2
 2s 
c2 ( s ) :   ,   ,   : c2 ( s )   2 
 1  1 1 
2 s  1
f1 ( x, y )  3 x 2  4 x  4 y  0


32 s   42 s   4 2 s 2  1  0
2
20s 2  8s  4  0
s  0.69,0.29
43
De Casteljau Algorithm [ref]
A cubic Bezier curve
with 4 control points
p(t), t[0,1] is defined.
Locate p(0.5)
44
Given (x,y) on the curve,
find the corresponding
parameter t
Inversion
0  t 3 
5 1 3  194

7   2 
5
1
4  t 

0
5  1  1  14 0   t 
 

3 
5
1
4 

 1 
Discarding thefourthrow :
Example
t
1
2
x, y   194 , 41 
5 1

0 5
5  1
7
4
1
3
4
1
t
t 2  5
t
1
3
t 3 
0  2 
t
7   
0
4 
t 
0   
 1 
7
4
1
3
4
0 5
7
4 /0
0 5
7
4
0
1
7
4
3
4
0

45
1
2
Download