If you can't read please download the document
Upload
nguyenduong
View
228
Download
0
Embed Size (px)
Citation preview
Teaching numerical methods : a first experience
Ronojoy AdhikariThe Institute of Mathematical SciencesChennai.
Numerical Methods : the first class
14 students, spread across second and third years of undergraduate study.
Physics, Mathematics and Computer Science.
Physics : knew why numerical methods are necessary, moderate programming skills.
Mathematics : very little idea about numerical methods, very poor programming skills.
Computer Science : poor idea about numerical methods, very good programming skills.
Purpose
The purpose of computing is insight, not numbers.
Numerical methods can give insight into problems we cannot otherwise solve.
R. W. Hamming
No purpose!
The purpose of computing numbers is not yet in sight.
Motivation : physical models
CFD
NLD
Computational Fluid Dynamics
Nonlinear Dynamics
Molecular Dynamics
MD
Motivation : mathematics of algorithms
A higher order polynomial interpolation does not always guarantee a smaller error. Indeed, it may so happen that the error increases with the degree of the interpolating polynomial. This is called the Runge phenomenon.
Example: interpolating the Lorentzian
f(x) =1
1 + x2
Motivation : mathematics of algorithms
!1 !0.5 0 0.5 1!1
!0.5
0
0.5
1
1.5equispaced points
max error = 5.9001
!1 !0.5 0 0.5 1!1
!0.5
0
0.5
1
1.5Chebyshev points
max error = 0.017523
xk = cos(k
N)
Black magic ?
fN+1 = f1, f0 = fN
12N
f 1
...
f N
= h1
0 12 12
12 0. . .. . .. . . 0 12
12
12 0
f1
...
fN
Motivation : algorithmic complexity
pbc:Other boundary conditions also possible.
Toeplitz (constant entries along diagonals) and circulant (reflecting pbc).
Motivation : algorithmic complexity
f 1
...
f N
= h1
. . . 112
23
. . . 112112
. . . 23
. . .. . . 0
. . .. . . 23
. . .
112112
. . .23
112
. . .
f1
...
fN
With quartic interpolation the matrix is pentadiagonal:
The bandwidth increases with increasing order of interpolation.What is the best way to compute a spectral differentiation matrix ?
Mathematical methods
What do we learn in a mathematical methods course ?
CalculusLinear Algebra
Orthogonal FunctionsDifferential Equations
Partial Differential Equations.....
Numerical methods
What do we learn in a numerical methods course ?
CalculusLinear Algebra
Orthogonal FunctionsDifferential Equations
Partial Differential Equations.....
b
aI(x; {xk}, {yk})dx
Interpolation : the central idea
(xk, yk) k = 1 . . . Ndata
I(x; {xk}, {yk})
dI(x; {xk}, {yk})dx
|x = xi
derivative quadrature
interpolant
Numerical analysis and computer programming
What does numerical analysis have to do with C, C++ ..?
Nothing really...
Numerical analysis can be done in almost any computer language. Historically, Fortran was the language of choice.
Modern codes are written in C, C++, Java, Python, Ruby ...
The course was language agnostic!
Open resources
Wikipedia is an excellent starting point for topics.
Open resource : programs
http://www.netlib.org/
http://www.gnu.org/software/gsl/
Open resource : libraries
http://www.nr.com/
Open resource : environments
http://www.scilab.org/
http://www.gnu.org/software/octave/
Open resource : books and websites
http://www.mathworks.com/moler/index_ncm.html
http://www.mathworks.com/moler/index_ncm.htmlhttp://www.mathworks.com/moler/index_ncm.html
Course website for out-of-class interaction.
Undergraduate course given to the students of the Chenna i Mathemat ica l Institute. Mix of physics, mathematics and computer science students, spread across different years. Standard topics were covered. Choice was given to code in C/C++ or Matlab/Octave, but teaching was language agnostic. GSL was recommended to C/C++ users. Format was 1.5 hours of classroom lecture per week and 1.5 hours of lab. Students knew at least one computer language. Weekly assignments and a final project were used for evaluation.
http://numericalmethods.wikidot.com/
Outlook
Undergraduate courses in numerical methods extremely necessary.
Must focus on basics first, the building blocks of numerical analysis, before proceeding towards packages or molecular dynamics and Monte Carlo.
Do not reinvent the wheel : use libraries! GSL is a very good general purpose library, suited to work in physics. (eg : has a Monte Carlo module).
For moderate work (roughly 10,0000 degrees of freedom) there is an enormous saving in human time in using environments like Matlab/Octave, while the saving in computer time is not more than half. Strongly encourage use of environments.
Try to make numerical methods fun, not a drudgery of using the VI editor, messing with compiler flags, linking ....
Thanks to the organisers for inviting me to speak.
Thank you for your attention.