0% found this document useful (0 votes)
30 views

Manual

This document provides instructions for using Matlab routines for spectral methods presented in the book Spectral Methods: Algorithms, Analysis and Applications. It outlines routines for evaluating orthogonal polynomials, computing Gaussian quadrature nodes and weights, implementing pseudospectral techniques like discrete transforms and differentiation in physical and frequency spaces, and applying these to solve PDEs. Instructions are provided for Legendre and Chebyshev spectral methods. Users are advised to choose parameters in standard ranges and bugs or comments can be reported by email. Other online spectral method software is also referenced.

Uploaded by

Carolina Ribeiro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Manual

This document provides instructions for using Matlab routines for spectral methods presented in the book Spectral Methods: Algorithms, Analysis and Applications. It outlines routines for evaluating orthogonal polynomials, computing Gaussian quadrature nodes and weights, implementing pseudospectral techniques like discrete transforms and differentiation in physical and frequency spaces, and applying these to solve PDEs. Instructions are provided for Legendre and Chebyshev spectral methods. Users are advised to choose parameters in standard ranges and bugs or comments can be reported by email. Other online spectral method software is also referenced.

Uploaded by

Carolina Ribeiro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Instructions for Matlab Routines

August, 2011
2

A. Introduction

This note is devoted to some instructions to the Matlab routines for the funda-
mental spectral algorithms presented in the book:
Jie Shen, Tao Tang and Li-Lian Wang. Spectral Methods: Algorithms, Anal-
ysis and Applications. Springer Series in Computational Mathematics, 41,
Springer, 2011.
This package consists of a collection of Matlab functions which are indispens-
able for spectral-Galerkin/collocation approximations of partial differential equations.
These include routines for
• Evaluation of Legendre polynomials, Jacobi polynomials, (generalized) La-
guerre polynomials/functions and Hermite polynomials/functions.
• Computation of the Gaussian-type quadrature nodes and weights associated
with these orthogonal polynomials/functions.
• Differentiation in the physical space via differentiation matrix.
• Implementation of pseudospectral techniques: discrete transforms and dif-
ferentiation in frequency spaces.
• Applications of these basic algorithms for solving PDEs.
We attempt to provide one-to-one correspondence between the codes and the
equations, formulas and algorithms in the book, and have made significant efforts to
test these functions. However, the users are advised to choose the underlying degree
of modes and parameters from the range of standard setting. You are more than
welcome to email us if you find bugs or have comments.
We also refer to the readers to the following online software in Fortran or Matlab
on spectral methods:
• Fortran Routines for Spectral Methods by D. Funaro, which are avail-
able at http://cdm.unimo.it/home/matematica/funaro.daniele/rout.htm
• A Matlab Differentiation Matrix Suite by J. Weideman and S. Reddy,
which is downloadable at http://dip.sun.ac.za/ weideman/research/differ.html
• PseudoPack by W.S. Don and B. Costa, which can be found at
http://www.math.hkbu.edu.hk/∼ wsdon/
• Some codes for Spectral Methods in Matlab by L. Trefethen, which can
be downloaded from http://people.maths.ox.ac.uk/trefethen/spectral.html
3

B. Instructions

1. Legendre Spectral Methods

(1) [dy, y]=lepoly(n,x);


Evaluate the Legendre polynomial and its first-order derivative of degree n
at a vector-valued x.
(2) [DY, Y]=lepolym(n,x);
Evaluate the Legendre polynomials and their first-order derivatives of degree
≤ n − 1 at a vector-valued x. Note: {Y (i, j) = Li−1 (xj )}1≤i,j≤n .
(3) [x, w]=legs(n);
Compute the Legendre-Gauss quadrature nodes and weights {xj , wj }nj=1 ,
where the Newton’s method is used for computing the nodes.
(4) x=legsndm(n);
Compute the Legendre-Gauss points {xj }nj=1 by the eigen-method.
(5) [x, w]=legslb(n);
Compute the Legendre-Gauss-Lobatto quadrature nodes and weights {xj , wj }nj=1 ,
where the Newton’s method is used for computing the nodes.
(6) x=legslbndm(n);
Compute the Legendre-Gauss-Lobatto points {xj }nj=1 by the eigen-method.
(7) w=legslbwt(n);
Compute the Legendre-Gauss-Lobatto weights {wj }nj=1 by the weight ex-
pression in Yakimiw [3].
(8) [x, w]=legsrd(n);
Compute the Legendre-Gauss-Radau quadrature nodes and weights {xj , wj }nj=1 ,
where the eign-method is used for computing the nodes.
(9) D=legsdiff(n,x); D=legslbdiff(n,x); D=legsrddiff(n,x);
Compute the first-order differentiation matrix D (of size n × n) associated
with the Legendre-Gauss, Legendre-Gauss-Lobatto and Legendre-Gauss-Radau
points {xj }nj=1 , respectively.
(10) s=ledisctran(n,x,w,p,iflag);
Perform discrete Legendre transforms on the Legendre-Gauss-Lobatto points
and weights {xj , wj }nj=1 . If iflag=0, it conducts the forward transform from
the physical values (stored in p) to the Legendre expansion coefficients (out-
put in s), while if iflag 6=0, it conducts the backward transform from the
4

Legendre expansion coefficients (stored in p) to the physical values (output


in s). See Page 101 of [1].
(11) duh=lefreqdiff(n,uh);
Perform spectral differentiation in the frequency space. Given the Legendre
expansion coefficients (stored in uh), it returns the Legendre expansion co-
efficients of the first-order derivative (output in duh). See Page 105 of [1].

2. Chebyshev Spectral Methods


(1) D=chebdiff(n);
Compute the first-order differentiation matrix (of size (n + 1) × (n + 1))
associated with the Chebyshev-Gauss-Lobatto points. See Page 80 of [2].
(2) w=chebfft(v);
Perform Chebyshev spectral differentiation via FFT. Given the physical val-
ues (stored in v) on the Chebyshev-Gauss-Lobatto points, it returns the
first-order derivative values (output in w). See Page 81 of [2].

———- Many More Routines Are Coming ——–


Bibliography

[1] J. Shen, T. Tang and L.L. Wang. Spectral Methods: Algorithms, Analysis and Applications.
Springer Series in Computational Mathematics, Volumn 41, Springer, 2011.
[2] L. Trefethen. Spectral Methods in Matlab, Volumn 10, SIAM, 2000.
[3] E. Yakimiw. Accurate computation of weights in classical Gauss-Christoffel quadrature
rules,Journal of Computational Physics, 129(2), 406-430, 1996.

You might also like