PREVIOUS: Programming Review
UP: Course Outline
NEXT: Numerical ODEs
PHYS 305: Computational Physics II
Winter 2022
2. Introductory Exercises
numerical differentiation
read
Numerical Recipes
, Sec. 5.7
example files:
differentiate0.py
differentiate1.py
plot errors versus dx:
differentiate2.py
more elaborate plotting:
differentiate3.py
fitting and extrapolation:
differentiate_extrap.py
numerical integration
Some
Newton-Cotes formulae
read
Numerical Recipes
, Sec. 4.1
basic example:
integrate0.py
Exercise 2.1: Measure the slope of the straight line in the log-log plot produced by the above example. Now modify the code to perform the integration using the Trapezoid rule. How does the slope of the line change?
Romberg integration
read
Numerical Recipes
, Sec. 4.3
Quadratures
read
Numerical Recipes
, Sec. 4.6
example:
gauss_cheb.py
quadrature application (Gauss-Chebyshev)
Homework #1