SlideShare a Scribd company logo
1 of 26
Download to read offline
Introduction
Chebyshev Polynomials
Computational Results in Python
A Python Implementation of Chebyshev Functions
Chris Swierczewski 1
cswiercz@amath.washington.edu
1University of Washington
Department of Applied Mathematics
27 May 2010
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
1 Introduction
Polynomial Approximations
The Problem
2 Chebyshev Polynomials
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
3 Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Problem
1 Introduction
Polynomial Approximations
The Problem
2 Chebyshev Polynomials
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
3 Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Problem
A Quick Note
To the applied mathematicians: I know Nick Trefethen gave
several talks on Chebfuns this year. Don’t worry! I hope to discuss
some things he didn’t talk about:
why his methods works so well,
how to actually compute Chebfuns,
how to actually compute integrals, derivatives, global roots.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Problem
Two Key Theorems
Weierstrass Approximation Theorem on R (1885)
Suppose f ∈ C0[a, b]. Then ∀ > 0, ∃p polynomial such that
||f − p||∞ < on [a, b].
(Interesting corrolary: R[x] is dense in C0
[a, b]. Q[x] is dense in R[x].
Therefore |C0
[−1, 1]| = |R|.)
Restriction to Degree n Polynomials: Pn
Given f ∈ C0[a, b] find p∗ ∈ Pn such that
||f − p∗
||∞ ≤ ||f − p||∞ for all p ∈ Pn
Fact: p∗
exists, is unique, and goes by the name “best”, “uniform”,
“Chebyshev”, or “minimax” approximation to f .
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Problem
Objective
Main Goal
Given f : [−1, 1] → R, find a polynomial of lowest degree that
approximates f to within machine epsilon. That is, find
pgoal = min
p,deg(p)
||f − p||∞ < mach
Trefethen’s method: look at polynomials with a particular structure
that make derivatives, integrals, and roots easy to compute.
Use these tools:
Structure #1: Lagrange interpolants
Structure #2: Chebyshev polynomial expansions
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
1 Introduction
Polynomial Approximations
The Problem
2 Chebyshev Polynomials
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
3 Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
Adding Some Structure
Trefethen restricts to the space of Lagrange interpolating
polynomials. Here we will show close they get to the minimax
polynomial approximation.
Largrange Interpolating Approximations
Let Ln(f ) be a Lagrange interpolant of f on n nodes. Then,
||f − Ln(f )||∞ ≤ (1 + ||Ln||∞)||f − p∗
||∞
where p∗ is the minimax polynomial approximation of degree n.
||Ln|| depends on the choice of interpolating points:
Uniform Distribution: ||Ln||∞ = O 2n+1
n log n
Chebyshev Distribution: ||Ln||∞ = O (log(n + 1))
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
More Reasons to Use Lagrange Interpolation
Lagrange Interpolants over the Chebyshev points have good
convergence properties:
Bounded Variation
If ∂kf : [−1, 1] → R has bounded variation for some k ≥ 1 then
||f − Ln(f )|| = O(n−k
)
Analyticity
If f is analytic in a neigborhood of [−1, 1] then
||f − Ln(f )|| = O(Cn
)
for some C < 1.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
Conclusions About Accuracy
Theorem
Chebyshev interpolants are near-best or spectrally accurate.
Spectral accuracy has to do with how well an approximating
function converges in a spectral domain. (i.e. Fourier) The theory
of Sobolev spaces gives a rich and precise description of why this
works. I would love to discuss this, but I won’t.
The point: Lagrange interpolants over the Chebyshev points
(Chebyshev interpolants) are good polynomial approximations.
For example: they defeat the Gibbs phenomenon.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
Practical Uses of Lagrange Interpolation
Barycentric Formula
Let (xj , fj ) be a collection of N + 1 sample points of f . Then the
Lagrange interpolant over these points can be written as
p(x) =
N
j=0
wj
x − xj
fj
N
j=0
wj
x − xj
with wj = (−1)j . (Divide by two for j = 0, N.)
Benefits:
fast (O(N) evaluation operation count),
numerically stable,
O(N) “updating” method for grid refinements.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
Why Restriction to [−1, 1]?
Summary so far: we’ve seen the benefits of using Lagrange
interpolation over the Chebyshev points and how the Barycentric
formula allows O(N) evaluation as well as O(N) method of adding
Chebyshev points.
Trefethen exploits another structure: consider only f : [−1, 1] → R
Chebyshev Polynomials
The Chebyshev polynomials Tn : [−1, 1] → R are defined:
T0(x) = 1
T1(x) = x
Tn+1(x) = 2xTn(x) − Tn−1(x)
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
Chebyshev Polynomial Expansions
Theorem (Trefethen)
If f : [−1, 1] → R is Lipschitz continuous then the Chebyshev
expansion
g(x) =
∞
n=0
anTn(x)
converges absolutely and uniformly to f . Additionally, the
Chebyshev coefficients are given by
an =
2
π
1
−1
f (x)Tn(x)
√
1 − x2
dx
with the special case that for n = 0 the constant changes to 1/π.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
Relating Chebyshev Polynomials to Chebyshev Interpolants
Chebyshev Polynomial Representations
For x ∈ [−1, 1] define θ = arccos(x) ∈ [0, 2π] and z = eiθ. Then:
Tn(x) = cos nθ = 1
2 zn
+ z−n
For Chebyshev interpolants, this is a finite sum:
Expansion Representation
Let p be a Chebyshev interpolant determined by N + 1 grid points
(xi , fi ) over the Chebyshev points xi = cos(πi/N). Then
p(x) =
N
n=0
anTn(x) =
N
n=0
an cos(nθ) = 1
2
N
n=0
an(zn
+ z−n
)
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
Definition of Chebfun
Definition
A chebfun is a minimal degree Barycentric Lagrange interpolant of
a function f : [−1, 1] → R over the Chebyshev points that uses its
Chebyshev polynomial expansion for fast computations.
“Spectrally optimal approximate”
Next section: Given f ∈ Lip[−1, 1], compute its Chebfun, p.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
1 Introduction
Polynomial Approximations
The Problem
2 Chebyshev Polynomials
Lagrange Interpolation
The Barycentric Formula
Chebyshev Polynomials
3 Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Why Python?
Python is a popular, powerful, and easy to use programming
language. Moreover, it’s open-source and free!
Numpy/Scipy
Sage
Clawpack
Brian
Support open-source! (http://www.opensource.org)
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Generating Chebyshev Functions
Init: begin with N = 4 Chebyshev interpolating points, {xi }
and compute fi = f (xi ).
Loop: Compute the discrete cosine transform of the {fi }, {ˆfi },
and divide each term by the number of interpolating points,
N. Set ai = ˆfi /N.
If:
|aN|, |aN−1| < 2 ∗ mach ∗ max
i
|ai |
then truncate the sequence {ai } down to the term with
largest index M exceeding this bound. The remaining M
terms gives you the “optimal Chebyshev interpolant size.
Else: Loop with 2N.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Demo
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Integration
Chebyshev Polynomial Integration
1
−1
Tn(x)dx =
0 if n odd
2
1−n2 if n even
Integral of a chebfun on [−1, 1]:
Clenshaw-Curtis Quadrature
Given a chebfun p(x) = N
n=0 anTn(x),
1
−1
p(x)dx =
N
n even
2
1 − n2
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Differentiation
Chebyshev Polynomial Derivative
If p(x) = N
n=0 anTn(x) then p (x) = N−1
n=0 bnTn(x) with
bn−1 = bn+1 + 2nan, bN = bN+1 = 0, b0 = b2/2 + a1.
Backsolve to find bn and inverse cosine transform to find
(xi , fi ) pairs.
O(N) computation of function derivative.
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Root Finding
Recall that Chebyshev coefficients {an} are the coefficients of the
Laurent series
q(z) =
N
n=0
an zn
+ z−n
.
The roots, zi of q, are the roots of zNq(z); a polynomial of
degree 2N in z.
Find the roots of zNq(z) using your favorite polynomial
root-finding algorithm. (Much easier than for a general
function.)
Roots come in pairs {zn, z−1
n }. Project back down to the real
axis with {zn, z−1
n } → 1
2(zn + z−1
n ) = xn.
Toss out any “roots” xn ∈ [−1, 1].
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Demo
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Future Work
The real power of Chebyshev functions is in creating differential
operators and solving differential equations: given f ∈ L2[−1, 1]
solve
Lu = f .
Reduces to a dense (N × N) matrix solve.
Distinction from finite difference methods: spectral accuracy
is preserved! This means O( mach) accurate solutions, u.
You can implement this! (See next slide.)
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Future Work
The obvious issue: don’t want to compete with Trefethen et. al.’s
work. (Unless I develop an awesomer algorithm!) Possible
solutions:
1 parallel projects in Python/Sage and Matlab,
2 a core C/FORTRAN library with separate Python and Matlab
interfaces. (A la LAPACK.)
Current Python implementation is an excellent platform for new
Python programmers. Learn Python and Mercurial! Get involved!
http://code.google.com/p/pychebfun
Chris Swierczewski A Python Implementation of Chebyshev Functions
Introduction
Chebyshev Polynomials
Computational Results in Python
The Basic Algorithm
Differentiation, Integration, and Root Finding
Future Work
Thank You
Chris Swierczewski A Python Implementation of Chebyshev Functions

More Related Content

What's hot

"reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli..."reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli...Christian Robert
 
Variational Inference
Variational InferenceVariational Inference
Variational InferenceTushar Tank
 
Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS
Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS
Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS Baasilroy
 
Harmonic Analysis and Deep Learning
Harmonic Analysis and Deep LearningHarmonic Analysis and Deep Learning
Harmonic Analysis and Deep LearningSungbin Lim
 
Predicates and Quantifiers
Predicates and Quantifiers Predicates and Quantifiers
Predicates and Quantifiers Istiak Ahmed
 
PaperNo10-KaramiHabibiSafariZarrabi-IJCMS
PaperNo10-KaramiHabibiSafariZarrabi-IJCMSPaperNo10-KaramiHabibiSafariZarrabi-IJCMS
PaperNo10-KaramiHabibiSafariZarrabi-IJCMSMezban Habibi
 
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...BRNSS Publication Hub
 
ABC based on Wasserstein distances
ABC based on Wasserstein distancesABC based on Wasserstein distances
ABC based on Wasserstein distancesChristian Robert
 
Variational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionVariational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionFlavio Morelli
 
PaperNo12-YousefiHabibi-IJAM
PaperNo12-YousefiHabibi-IJAMPaperNo12-YousefiHabibi-IJAM
PaperNo12-YousefiHabibi-IJAMMezban Habibi
 
Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...
Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...
Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...Katsuya Ito
 
ABC convergence under well- and mis-specified models
ABC convergence under well- and mis-specified modelsABC convergence under well- and mis-specified models
ABC convergence under well- and mis-specified modelsChristian Robert
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...HidenoriOgata
 
Discrete maths questions
Discrete maths questionsDiscrete maths questions
Discrete maths questionsDIT University
 
Andrei rusu-2013-amaa-workshop
Andrei rusu-2013-amaa-workshopAndrei rusu-2013-amaa-workshop
Andrei rusu-2013-amaa-workshopAndries Rusu
 

What's hot (19)

"reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli..."reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli...
 
Variational Inference
Variational InferenceVariational Inference
Variational Inference
 
Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS
Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS
Digital Text Book :POTENTIAL THEORY AND ELLIPTIC PARTIAL DIFFERENTIAL EQUATIONS
 
Harmonic Analysis and Deep Learning
Harmonic Analysis and Deep LearningHarmonic Analysis and Deep Learning
Harmonic Analysis and Deep Learning
 
Predicates and Quantifiers
Predicates and Quantifiers Predicates and Quantifiers
Predicates and Quantifiers
 
PaperNo10-KaramiHabibiSafariZarrabi-IJCMS
PaperNo10-KaramiHabibiSafariZarrabi-IJCMSPaperNo10-KaramiHabibiSafariZarrabi-IJCMS
PaperNo10-KaramiHabibiSafariZarrabi-IJCMS
 
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Appli...
 Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Appli... Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Appli...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Appli...
 
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
 
ABC based on Wasserstein distances
ABC based on Wasserstein distancesABC based on Wasserstein distances
ABC based on Wasserstein distances
 
Variational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionVariational Bayes: A Gentle Introduction
Variational Bayes: A Gentle Introduction
 
PaperNo12-YousefiHabibi-IJAM
PaperNo12-YousefiHabibi-IJAMPaperNo12-YousefiHabibi-IJAM
PaperNo12-YousefiHabibi-IJAM
 
Matrix calculus
Matrix calculusMatrix calculus
Matrix calculus
 
Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...
Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...
Convex Analysis and Duality (based on "Functional Analysis and Optimization" ...
 
ABC convergence under well- and mis-specified models
ABC convergence under well- and mis-specified modelsABC convergence under well- and mis-specified models
ABC convergence under well- and mis-specified models
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...
 
Metric space
Metric spaceMetric space
Metric space
 
Discrete maths questions
Discrete maths questionsDiscrete maths questions
Discrete maths questions
 
the ABC of ABC
the ABC of ABCthe ABC of ABC
the ABC of ABC
 
Andrei rusu-2013-amaa-workshop
Andrei rusu-2013-amaa-workshopAndrei rusu-2013-amaa-workshop
Andrei rusu-2013-amaa-workshop
 

Similar to masters-presentation

ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSfenil patel
 
Presentation of volesti in eRum 2020
Presentation of volesti in eRum 2020 Presentation of volesti in eRum 2020
Presentation of volesti in eRum 2020 Apostolos Chalkis
 
Chapter 3 projection
Chapter 3 projectionChapter 3 projection
Chapter 3 projectionNBER
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCSR2011
 
More on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomizationMore on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomizationAbner Chih Yi Huang
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCSR2011
 
Yet another statistical analysis of the data of the ‘loophole free’ experime...
Yet another statistical analysis of the data of the  ‘loophole free’ experime...Yet another statistical analysis of the data of the  ‘loophole free’ experime...
Yet another statistical analysis of the data of the ‘loophole free’ experime...Richard Gill
 
Numerical Study of Some Iterative Methods for Solving Nonlinear Equations
Numerical Study of Some Iterative Methods for Solving Nonlinear EquationsNumerical Study of Some Iterative Methods for Solving Nonlinear Equations
Numerical Study of Some Iterative Methods for Solving Nonlinear Equationsinventionjournals
 
2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolationEasyStudy3
 
Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...
Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...
Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...Aalto University
 
A new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodiesA new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodiesVissarion Fisikopoulos
 
BALANCING BOARD MACHINES
BALANCING BOARD MACHINESBALANCING BOARD MACHINES
BALANCING BOARD MACHINESbutest
 

Similar to masters-presentation (20)

ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONS
 
Presentation of volesti in eRum 2020
Presentation of volesti in eRum 2020 Presentation of volesti in eRum 2020
Presentation of volesti in eRum 2020
 
Chapter 3 projection
Chapter 3 projectionChapter 3 projection
Chapter 3 projection
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
 
A04410107
A04410107A04410107
A04410107
 
AI_Lecture_34.ppt
AI_Lecture_34.pptAI_Lecture_34.ppt
AI_Lecture_34.ppt
 
More on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomizationMore on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomization
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
 
Yet another statistical analysis of the data of the ‘loophole free’ experime...
Yet another statistical analysis of the data of the  ‘loophole free’ experime...Yet another statistical analysis of the data of the  ‘loophole free’ experime...
Yet another statistical analysis of the data of the ‘loophole free’ experime...
 
Numerical Study of Some Iterative Methods for Solving Nonlinear Equations
Numerical Study of Some Iterative Methods for Solving Nonlinear EquationsNumerical Study of Some Iterative Methods for Solving Nonlinear Equations
Numerical Study of Some Iterative Methods for Solving Nonlinear Equations
 
QMC: Transition Workshop - Reduced Component-by-Component Constructions of (P...
QMC: Transition Workshop - Reduced Component-by-Component Constructions of (P...QMC: Transition Workshop - Reduced Component-by-Component Constructions of (P...
QMC: Transition Workshop - Reduced Component-by-Component Constructions of (P...
 
2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolation
 
Volume computation and applications
Volume computation and applications Volume computation and applications
Volume computation and applications
 
Main
MainMain
Main
 
Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...
Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...
Model-Based User Interface Optimization: Part III: SOLVING REAL PROBLEMS - At...
 
Lecture 4 f17
Lecture 4 f17Lecture 4 f17
Lecture 4 f17
 
Spline (2).ppt
Spline (2).pptSpline (2).ppt
Spline (2).ppt
 
A new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodiesA new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodies
 
BALANCING BOARD MACHINES
BALANCING BOARD MACHINESBALANCING BOARD MACHINES
BALANCING BOARD MACHINES
 
3_MLE_printable.pdf
3_MLE_printable.pdf3_MLE_printable.pdf
3_MLE_printable.pdf
 

masters-presentation

  • 1. Introduction Chebyshev Polynomials Computational Results in Python A Python Implementation of Chebyshev Functions Chris Swierczewski 1 cswiercz@amath.washington.edu 1University of Washington Department of Applied Mathematics 27 May 2010 Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 2. Introduction Chebyshev Polynomials Computational Results in Python 1 Introduction Polynomial Approximations The Problem 2 Chebyshev Polynomials Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials 3 Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 3. Introduction Chebyshev Polynomials Computational Results in Python The Problem 1 Introduction Polynomial Approximations The Problem 2 Chebyshev Polynomials Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials 3 Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 4. Introduction Chebyshev Polynomials Computational Results in Python The Problem A Quick Note To the applied mathematicians: I know Nick Trefethen gave several talks on Chebfuns this year. Don’t worry! I hope to discuss some things he didn’t talk about: why his methods works so well, how to actually compute Chebfuns, how to actually compute integrals, derivatives, global roots. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 5. Introduction Chebyshev Polynomials Computational Results in Python The Problem Two Key Theorems Weierstrass Approximation Theorem on R (1885) Suppose f ∈ C0[a, b]. Then ∀ > 0, ∃p polynomial such that ||f − p||∞ < on [a, b]. (Interesting corrolary: R[x] is dense in C0 [a, b]. Q[x] is dense in R[x]. Therefore |C0 [−1, 1]| = |R|.) Restriction to Degree n Polynomials: Pn Given f ∈ C0[a, b] find p∗ ∈ Pn such that ||f − p∗ ||∞ ≤ ||f − p||∞ for all p ∈ Pn Fact: p∗ exists, is unique, and goes by the name “best”, “uniform”, “Chebyshev”, or “minimax” approximation to f . Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 6. Introduction Chebyshev Polynomials Computational Results in Python The Problem Objective Main Goal Given f : [−1, 1] → R, find a polynomial of lowest degree that approximates f to within machine epsilon. That is, find pgoal = min p,deg(p) ||f − p||∞ < mach Trefethen’s method: look at polynomials with a particular structure that make derivatives, integrals, and roots easy to compute. Use these tools: Structure #1: Lagrange interpolants Structure #2: Chebyshev polynomial expansions Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 7. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials 1 Introduction Polynomial Approximations The Problem 2 Chebyshev Polynomials Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials 3 Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 8. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials Adding Some Structure Trefethen restricts to the space of Lagrange interpolating polynomials. Here we will show close they get to the minimax polynomial approximation. Largrange Interpolating Approximations Let Ln(f ) be a Lagrange interpolant of f on n nodes. Then, ||f − Ln(f )||∞ ≤ (1 + ||Ln||∞)||f − p∗ ||∞ where p∗ is the minimax polynomial approximation of degree n. ||Ln|| depends on the choice of interpolating points: Uniform Distribution: ||Ln||∞ = O 2n+1 n log n Chebyshev Distribution: ||Ln||∞ = O (log(n + 1)) Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 9. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials More Reasons to Use Lagrange Interpolation Lagrange Interpolants over the Chebyshev points have good convergence properties: Bounded Variation If ∂kf : [−1, 1] → R has bounded variation for some k ≥ 1 then ||f − Ln(f )|| = O(n−k ) Analyticity If f is analytic in a neigborhood of [−1, 1] then ||f − Ln(f )|| = O(Cn ) for some C < 1. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 10. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials Conclusions About Accuracy Theorem Chebyshev interpolants are near-best or spectrally accurate. Spectral accuracy has to do with how well an approximating function converges in a spectral domain. (i.e. Fourier) The theory of Sobolev spaces gives a rich and precise description of why this works. I would love to discuss this, but I won’t. The point: Lagrange interpolants over the Chebyshev points (Chebyshev interpolants) are good polynomial approximations. For example: they defeat the Gibbs phenomenon. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 11. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials Practical Uses of Lagrange Interpolation Barycentric Formula Let (xj , fj ) be a collection of N + 1 sample points of f . Then the Lagrange interpolant over these points can be written as p(x) = N j=0 wj x − xj fj N j=0 wj x − xj with wj = (−1)j . (Divide by two for j = 0, N.) Benefits: fast (O(N) evaluation operation count), numerically stable, O(N) “updating” method for grid refinements. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 12. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials Why Restriction to [−1, 1]? Summary so far: we’ve seen the benefits of using Lagrange interpolation over the Chebyshev points and how the Barycentric formula allows O(N) evaluation as well as O(N) method of adding Chebyshev points. Trefethen exploits another structure: consider only f : [−1, 1] → R Chebyshev Polynomials The Chebyshev polynomials Tn : [−1, 1] → R are defined: T0(x) = 1 T1(x) = x Tn+1(x) = 2xTn(x) − Tn−1(x) Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 13. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials Chebyshev Polynomial Expansions Theorem (Trefethen) If f : [−1, 1] → R is Lipschitz continuous then the Chebyshev expansion g(x) = ∞ n=0 anTn(x) converges absolutely and uniformly to f . Additionally, the Chebyshev coefficients are given by an = 2 π 1 −1 f (x)Tn(x) √ 1 − x2 dx with the special case that for n = 0 the constant changes to 1/π. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 14. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials Relating Chebyshev Polynomials to Chebyshev Interpolants Chebyshev Polynomial Representations For x ∈ [−1, 1] define θ = arccos(x) ∈ [0, 2π] and z = eiθ. Then: Tn(x) = cos nθ = 1 2 zn + z−n For Chebyshev interpolants, this is a finite sum: Expansion Representation Let p be a Chebyshev interpolant determined by N + 1 grid points (xi , fi ) over the Chebyshev points xi = cos(πi/N). Then p(x) = N n=0 anTn(x) = N n=0 an cos(nθ) = 1 2 N n=0 an(zn + z−n ) Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 15. Introduction Chebyshev Polynomials Computational Results in Python Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials Definition of Chebfun Definition A chebfun is a minimal degree Barycentric Lagrange interpolant of a function f : [−1, 1] → R over the Chebyshev points that uses its Chebyshev polynomial expansion for fast computations. “Spectrally optimal approximate” Next section: Given f ∈ Lip[−1, 1], compute its Chebfun, p. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 16. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work 1 Introduction Polynomial Approximations The Problem 2 Chebyshev Polynomials Lagrange Interpolation The Barycentric Formula Chebyshev Polynomials 3 Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 17. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Why Python? Python is a popular, powerful, and easy to use programming language. Moreover, it’s open-source and free! Numpy/Scipy Sage Clawpack Brian Support open-source! (http://www.opensource.org) Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 18. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Generating Chebyshev Functions Init: begin with N = 4 Chebyshev interpolating points, {xi } and compute fi = f (xi ). Loop: Compute the discrete cosine transform of the {fi }, {ˆfi }, and divide each term by the number of interpolating points, N. Set ai = ˆfi /N. If: |aN|, |aN−1| < 2 ∗ mach ∗ max i |ai | then truncate the sequence {ai } down to the term with largest index M exceeding this bound. The remaining M terms gives you the “optimal Chebyshev interpolant size. Else: Loop with 2N. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 19. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Demo Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 20. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Integration Chebyshev Polynomial Integration 1 −1 Tn(x)dx = 0 if n odd 2 1−n2 if n even Integral of a chebfun on [−1, 1]: Clenshaw-Curtis Quadrature Given a chebfun p(x) = N n=0 anTn(x), 1 −1 p(x)dx = N n even 2 1 − n2 Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 21. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Differentiation Chebyshev Polynomial Derivative If p(x) = N n=0 anTn(x) then p (x) = N−1 n=0 bnTn(x) with bn−1 = bn+1 + 2nan, bN = bN+1 = 0, b0 = b2/2 + a1. Backsolve to find bn and inverse cosine transform to find (xi , fi ) pairs. O(N) computation of function derivative. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 22. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Root Finding Recall that Chebyshev coefficients {an} are the coefficients of the Laurent series q(z) = N n=0 an zn + z−n . The roots, zi of q, are the roots of zNq(z); a polynomial of degree 2N in z. Find the roots of zNq(z) using your favorite polynomial root-finding algorithm. (Much easier than for a general function.) Roots come in pairs {zn, z−1 n }. Project back down to the real axis with {zn, z−1 n } → 1 2(zn + z−1 n ) = xn. Toss out any “roots” xn ∈ [−1, 1]. Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 23. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Demo Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 24. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Future Work The real power of Chebyshev functions is in creating differential operators and solving differential equations: given f ∈ L2[−1, 1] solve Lu = f . Reduces to a dense (N × N) matrix solve. Distinction from finite difference methods: spectral accuracy is preserved! This means O( mach) accurate solutions, u. You can implement this! (See next slide.) Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 25. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Future Work The obvious issue: don’t want to compete with Trefethen et. al.’s work. (Unless I develop an awesomer algorithm!) Possible solutions: 1 parallel projects in Python/Sage and Matlab, 2 a core C/FORTRAN library with separate Python and Matlab interfaces. (A la LAPACK.) Current Python implementation is an excellent platform for new Python programmers. Learn Python and Mercurial! Get involved! http://code.google.com/p/pychebfun Chris Swierczewski A Python Implementation of Chebyshev Functions
  • 26. Introduction Chebyshev Polynomials Computational Results in Python The Basic Algorithm Differentiation, Integration, and Root Finding Future Work Thank You Chris Swierczewski A Python Implementation of Chebyshev Functions