55
Johann Radon Institute for Computational and Applied Mathematics Linz, Österreich 15. März 2004

Spectral Differencing with a Twist

  • Upload
    kirkan

  • View
    47

  • Download
    0

Embed Size (px)

DESCRIPTION

Spectral Differencing with a Twist. Johann Radon Institute for Computational and Applied Mathematics Linz, Österreich 15. März 2004. Spectral Differencing with a Twist. Johann Radon Institute for Computational and Applied Mathematics Linz, Österreich 15. März 2004. - PowerPoint PPT Presentation

Citation preview

Page 1: Spectral Differencing with a Twist

Johann Radon Institute for

Computational and

Applied Mathematics

Linz, Österreich

15. März 2004

Page 2: Spectral Differencing with a Twist

Johann Radon Institute for

Computational and

Applied Mathematics

Linz, Österreich

15. März 2004

Page 3: Spectral Differencing with a Twist

[email protected] www.math.sfu.ca/~mrt

Richard BaltenspergerUniversité Fribourg

Manfred TrummerPacific Institute for the

Mathematical Sciences &Simon Fraser University

Johann Radon Institute for

Computational and

Applied Mathematics

Linz, Österreich

15. März 2004

Page 4: Spectral Differencing with a Twist

Pacific Institute for the Mathematical Sciences

www.pims.math.ca

Page 5: Spectral Differencing with a Twist

Simon Fraser University

Page 6: Spectral Differencing with a Twist

Banff International Research Station

PIMS – MSRI collaboration (with MITACS)

5-day workshops 2-day workshops Focused Research Research In Teams

www.pims.math.ca/birs

Page 7: Spectral Differencing with a Twist

Round-off ErrorsRound-off Errors

• 1991 – a patriot missile battery in 1991 – a patriot missile battery in Dhahran, Saudi Arabia, fails to intercept Dhahran, Saudi Arabia, fails to intercept Iraqi missile resulting in 28 fatalities. Iraqi missile resulting in 28 fatalities. Problem traced back to accumulation of Problem traced back to accumulation of round-off error in computer arithmetic.round-off error in computer arithmetic.

Page 8: Spectral Differencing with a Twist

IntroductionIntroduction

Spectral Differentiation:

• Approximate function f(x) by a Approximate function f(x) by a globalglobal interpolant interpolant

• Differentiate the global Differentiate the global interpolant interpolant exactlyexactly, e.g.,, e.g.,

Page 9: Spectral Differencing with a Twist

Features of spectral Features of spectral methodsmethods+ Exponential (spectral) accuracy, + Exponential (spectral) accuracy,

converges faster than any power of converges faster than any power of 1/N1/N

+ Fairly coarse discretizations give + Fairly coarse discretizations give good resultsgood results

- Full instead of sparse matrices- Full instead of sparse matrices

- Tighter stability restrictions- Tighter stability restrictions

- Less robust, difficulties with - Less robust, difficulties with irregular domainsirregular domains

Page 10: Spectral Differencing with a Twist

Types of Spectral MethodsTypes of Spectral Methods

• Spectral-GalerkinSpectral-Galerkin: : work in work in transformed space, that is, with the transformed space, that is, with the coefficients in the expansion.coefficients in the expansion.

Example:Example: uutt = u = uxxxx

Page 11: Spectral Differencing with a Twist

Types of Spectral Types of Spectral MethodsMethods

•Spectral CollocationSpectral Collocation (Pseudospectral): (Pseudospectral): work in physical work in physical space. Choose collocation points xspace. Choose collocation points xkk, , k=0,..,N, and approximate the k=0,..,N, and approximate the function of interest by its values at function of interest by its values at those collocation points. those collocation points.

Computations rely on interpolation.Computations rely on interpolation.

• Issues: Aliasing, ease of computation, Issues: Aliasing, ease of computation, nonlinearitiesnonlinearities

Page 12: Spectral Differencing with a Twist

InterpolationInterpolation• Periodic function, equidistant Periodic function, equidistant

points: FOURIERpoints: FOURIER

• Polynomial interpolation: Polynomial interpolation:

• Interpolation by Rational functionsInterpolation by Rational functions

•Chebyshev points

•Legendre points

•Hermite, Laguerre

Page 13: Spectral Differencing with a Twist

Differentiation Matrix Differentiation Matrix DD

Discrete data set Discrete data set ffkk, , k=0,…,Nk=0,…,N

Interpolate between collocation Interpolate between collocation points points xxkk

p(xp(xkk) = f) = fkk

Differentiate Differentiate p(x)p(x)

Evaluate Evaluate p’(xp’(xkk) = g) = gkk

All operations are linear: All operations are linear: g = Dfg = Df

Page 14: Spectral Differencing with a Twist

SoftwareSoftware• FunaroFunaro: FORTRAN code, various : FORTRAN code, various

polynomial spectral methodspolynomial spectral methods

• Don-Solomonoff, Don-CostaDon-Solomonoff, Don-Costa: : PSEUDOPAK FORTRAN code, more PSEUDOPAK FORTRAN code, more engineering oriented, includes engineering oriented, includes filters, etc.filters, etc.

• Weideman-ReddyWeideman-Reddy: Based on : Based on Differentiation Matrices, written in Differentiation Matrices, written in MATLAB (fast Matlab programming)MATLAB (fast Matlab programming)

Page 15: Spectral Differencing with a Twist

Polynomial InterpolationPolynomial Interpolation

Lagrange form: “Although admired Lagrange form: “Although admired for its mathematical beauty and for its mathematical beauty and elegance it is not useful in elegance it is not useful in practice”practice”

•“Expensive”

•“Difficult to

update”

Page 16: Spectral Differencing with a Twist

Barycentric formula, version Barycentric formula, version 11

Page 17: Spectral Differencing with a Twist

Barycentric formula, version Barycentric formula, version 22 =1

Set-up: O(N2)

Evaluation: O(N)

Update (add point): O(N)

New fk values: no extra work!

Page 18: Spectral Differencing with a Twist

Barycentric formula: Barycentric formula: weights wweights wkk

=0

Page 19: Spectral Differencing with a Twist

Barycentric formula: Barycentric formula: weights wweights wkk

Equidistant points:

Chebyshev points (1st kind):

Chebyshev points (2nd kind):

Page 20: Spectral Differencing with a Twist

Barycentric formula: Barycentric formula: weights wweights wkk

Weights can be multiplied by the same constant

This function interpolates for any weights ! Rational interpolation!

Relative size of weights indicates ill-conditioning

Page 21: Spectral Differencing with a Twist

Computation of the Computation of the Differentiation MatrixDifferentiation MatrixEntirely based upon interpolation.Entirely based upon interpolation.

Page 22: Spectral Differencing with a Twist

Barycentric FormulaBarycentric Formula

Barycentric Barycentric (Schneider/Werner):(Schneider/Werner):

Page 23: Spectral Differencing with a Twist

Chebyshev DifferentiationChebyshev Differentiation

Differentiation Differentiation Matrix:Matrix:

xk = cos(k/N)

Page 24: Spectral Differencing with a Twist

Chebyshev Matrix Chebyshev Matrix has has Behavioural Behavioural ProblemsProblems• Trefethen-Trummer, 1987 Trefethen-Trummer, 1987 • Rothman, 1991Rothman, 1991• Breuer-Everson, 1992Breuer-Everson, 1992• Don-Solomonoff, 1995/1997Don-Solomonoff, 1995/1997• Bayliss-Class-Matkowsky, 1995Bayliss-Class-Matkowsky, 1995• Tang-Trummer, 1996Tang-Trummer, 1996• Baltensperger-Berrut, 1996Baltensperger-Berrut, 1996

numericnumericalal

Page 25: Spectral Differencing with a Twist

Chebyshev Matrix and Chebyshev Matrix and ErrorsErrors

Matrix

Absolute Errors

Relative Errors

Page 26: Spectral Differencing with a Twist

Round-off error analysisRound-off error analysis

has relative error

and so has

, therefore

Page 27: Spectral Differencing with a Twist

Roundoff Error Analysis Roundoff Error Analysis

• With “good” computation we expect With “good” computation we expect an error in Dan error in D01 01 of O(Nof O(N22))

• Most elements in D are O(1)Most elements in D are O(1)

• Some are of O(N), and a few are O(NSome are of O(N), and a few are O(N22))

• We must be careful to see whether We must be careful to see whether absolute or relative errors enter the absolute or relative errors enter the computationcomputation

Page 28: Spectral Differencing with a Twist

RemediesRemedies

• Preconditioning, add ax+b to f to Preconditioning, add ax+b to f to create a function which is zero at the create a function which is zero at the boundaryboundary

• Compute D in higher precisionCompute D in higher precision

• Use trigonometric identitiesUse trigonometric identities

• Use symmetry: Flipping TrickUse symmetry: Flipping Trick

• NST: Negative sum trickNST: Negative sum trick

Page 29: Spectral Differencing with a Twist

More ways to compute DfMore ways to compute Df

• FFT based approachFFT based approach

• Schneider-Werner formulaSchneider-Werner formula

If we only want Df but not the matrix D (e.g., time stepping, iterative methods), we can compute Df for any f via

Page 30: Spectral Differencing with a Twist

Chebyshev Differentiation Chebyshev Differentiation MatrixMatrix

““Original Formulas”:Original Formulas”:

CancellationCancellation!

xk = cos(k/N)

Page 31: Spectral Differencing with a Twist

Trigonometric IdentitiesTrigonometric Identities

Page 32: Spectral Differencing with a Twist

Flipping TrickFlipping Trick

Use

and “flip” the upper half of D into the lower half, or the upper left triangle into the lower right triangle.

sin( – x) not as accurate as sin(x)

Page 33: Spectral Differencing with a Twist

NST: Negative sum trickNST: Negative sum trick

Spectral Differentiation is exact for constant functions:

Arrange order of summation to sum the smaller elements first - requires sorting

Page 34: Spectral Differencing with a Twist

Numerical ExampleNumerical Example

Page 35: Spectral Differencing with a Twist

Numerical ExampleNumerical Example

Page 36: Spectral Differencing with a Twist

ObservationsObservations

•Original formula for D is very inaccurate

•Trig/Flip + “NST” (Weideman-Reddy) provides good improvement

•FFT not as good as “expected”, in particular when N is not a power of 2

•NST applied to original D gives best matrix

•Even more accurate ways to compute Df

Page 37: Spectral Differencing with a Twist

Machine DependencyMachine Dependency

•Results can vary substantially from machine to machine, and may depend on software.

•Intel/PC: FFT performs better

•SGI

•SUN

•DEC Alpha

Page 38: Spectral Differencing with a Twist

Understanding theUnderstanding theNegative sum trickNegative sum trick

Page 39: Spectral Differencing with a Twist

Understanding theUnderstanding theNegative sum trickNegative sum trick

Error in D

Error in f

Page 40: Spectral Differencing with a Twist

Understanding NSTUnderstanding NST22

N

kjjkjkk DD

,0

Page 41: Spectral Differencing with a Twist

Understanding NSTUnderstanding NST33

N

kjjkjkk DD

,0

The inaccurate matrix elements are multiplied by very small numbers leading to O(N2) errors -- optimal accuracy

Page 42: Spectral Differencing with a Twist

Understanding the Understanding the Negative sum trickNegative sum trick

N

kjjkjkk DD

,0

NST is an (inaccurate) implementation of the Schneider-Werner formula:

Schneider-Werner Negative Sum Trick

Page 43: Spectral Differencing with a Twist

Understanding the Understanding the Negative sum trickNegative sum trick

N

kjjkjkk DD

,0

•Why do we obtain superior results when applying the NST to the original (inaccurate) formula?

•Accuracy of Finite Difference Quotients:

Page 44: Spectral Differencing with a Twist

Finite Difference QuotientsFinite Difference Quotients

•For monomials a cancellation of the cancellation errors takes place, e.g.:

•Typically fj – fk is less accurate than xj – xk, so computing xj - xk more accurately does not help!

Page 45: Spectral Differencing with a Twist

Finite Difference QuotientsFinite Difference Quotients

Page 46: Spectral Differencing with a Twist

Finite Difference QuotientsFinite Difference Quotients

Page 47: Spectral Differencing with a Twist

Fast Schneider-WernerFast Schneider-Werner

•Cost of Df is 2N2, SW costs 3N2

•Can implement Df with “Fast SW” method

D f

SW

SW

Size of each corner blocks is N½

Cost: 2N2 + O(N)

Page 48: Spectral Differencing with a Twist

Polynomial Polynomial DifferentiationDifferentiation

• For example, Legendre, Hermite, LaguerreFor example, Legendre, Hermite, Laguerre

• Fewer tricks available, but Negative Sum Fewer tricks available, but Negative Sum Trick still provides improvementsTrick still provides improvements

• Ordering the summation may become even Ordering the summation may become even more importantmore important

Page 49: Spectral Differencing with a Twist

Higher Order DerivativesHigher Order Derivatives

• Best not to compute DBest not to compute D(2)(2)=D=D22, etc., etc.

• Formulas by Welfert (implemented in Weideman-Reddy)Formulas by Welfert (implemented in Weideman-Reddy)

• Negative sum trick shows again improvementsNegative sum trick shows again improvements

• Higher order differentiation matrices badly conditioned, Higher order differentiation matrices badly conditioned, so gaining a little more accuracy is more important than so gaining a little more accuracy is more important than for first orderfor first order

Page 50: Spectral Differencing with a Twist

Using D to solve Using D to solve problemsproblems

• In many applications the first and last row/column In many applications the first and last row/column of D is removed because of boundary conditionsof D is removed because of boundary conditions

• f f ->-> Df appears to be most sensitive to how D is Df appears to be most sensitive to how D is computed (forward problem = differentiation)computed (forward problem = differentiation)

• Have observed improvements in solving BVPsHave observed improvements in solving BVPs

Skip

Page 51: Spectral Differencing with a Twist

Solving a Singular BVPSolving a Singular BVP

Page 52: Spectral Differencing with a Twist

ResultsResults

Page 53: Spectral Differencing with a Twist

CloseClose

• Demystified some of the less intuitive Demystified some of the less intuitive behaviour of differentiation matricesbehaviour of differentiation matrices

• Get more accuracy for the same cost Get more accuracy for the same cost • Study the effects of using the various Study the effects of using the various

differentiation matrices in applications differentiation matrices in applications • Forward problem is more sensitive Forward problem is more sensitive

than inverse problem than inverse problem • Df: Time-stepping, Iterative methodsDf: Time-stepping, Iterative methods

Page 54: Spectral Differencing with a Twist

To think aboutTo think about

• Is double precision enough as we are Is double precision enough as we are able to solve “bigger” problems? able to solve “bigger” problems?

• Irony of spectral methods: Irony of spectral methods: Exponential convergence, round-off Exponential convergence, round-off error is the limiting factorerror is the limiting factor

• Accuracy requirements limit us to N Accuracy requirements limit us to N of moderate size -- FFT is not so of moderate size -- FFT is not so much faster than matrix based much faster than matrix based approachapproach

Page 55: Spectral Differencing with a Twist

And now for the twist….And now for the twist….