Numerical Methods

by Rasmus Handberg

This is my solutions to the exercises in the course "Numerical Methods" in the spring 2008. All programs are written in Fortran 95.

Hello World

Writes "Hello World" on the screen.

Directory
Input:
makefile
hello.f95
Output:
hello
out.txt

QR-decomposition

Solve system of linear equations, calculate determinant and inverse of a matrix.

Note
Exercise
Directory
Input:
makefile
main.f95
matrix.f95
Output:
main
out.txt

Matrix diagonalization

Diagonalise a matrix, to find it's eigenvalues.

Please note that the file matrix.f95 has been changed slightly from the last exercise.

Note
Exercise
Directory
Input:
makefile
main.f95
Jacobi.f95
matrix.f95
Output:
main
out.txt

Least Squares Fit

Performs a Linear Least Squares Fit to a given set of datapoints.

Please note that the file matrix.f95 once again has been changed slightly from the last exercise.

Note
Exercise
Directory
Input:
makefile
main.f95
leastsqrfit.f95
matrix.f95
fit1.gnuplot
fit2.gnuplot
Output:
main
out.txt
fit1.png
fit2.png

The program produces the following plots, showing both a linear fit and a parabola fit:

Linear Fit
Parabola Fit

Interpolation

Interpolate a tabulated function (xi,yi) using a polynomial and quadratic spline interpolation.

Note
Exercise
Directory
Input:
makefile
main.f95
interp.f95
pointerp.gnuplot
Output:
main
out.txt
points.dat
pointerp.dat
qspline.dat
interpolation.png

The program produces the following plot, showing both a polynomial and quadratic spline-interpolation:

Interpolation

RootFinding and Optimization

Find roots of a system of non-linear equations using the modified Newton method. Minimize a function in n variables using the downhill simplex algorithm.

Note
Exercise
Directory
Input:
makefile
main.f95
kind_defs.f95
roots.f95
simplex.f95
matrix.f95
Output:
main
out.txt

Ordinary differential equations

Solve a system of ordinary differential equations using an adaptive-step-size Runge-Kutta routine and using the Prediction-Correction method.

Note
Exercise
Directory
Input:
makefile
main.f95
rk.f95
pc.f95
rk.gnuplot
Output:
main
out.txt
rk.png
pc.png
rk
pc

Numerical Integration

Numerical integration with adaptive quadratures and reuse of points.

Note
Exercise
Directory
Input:
makefile
main.f95
integrate.f95
Output:
main
out.txt

Monte Carlo integration

Numerical Monte Carlo integration with pseudo-random, quasi-random and stratified sampling.

Note
Exercise
Directory
Input:
makefile
main.f95
montecarlo.f95
Output:
main
out.txt

Fast Fourier Transformation

Implementation of a Fast Fourier Transformation (FFT) which applies the Danielson-Lanczos lemma recursively. The FFT is then used to calculate amplitude-spectra and do simple filtering.

Note
Exercise
Directory
Input:
makefile
main.f95
fft.f95
kind_defs.f95
spectrum.gnuplot
filter.gnuplot
Data/simpel_short.dat
Output:
main
out.txt
plot1.png
plot2.png
spectrum
filtered

Project: Fast Fourier Transformation in astrophysics

The project can be found here:

Project

Directory
Input:
makefile
kind_defs.f95
fft.f95
image.f95
spectra.f95
speedtest.f95
m92.f95
Input for Gnuplot:
psf_surf.gnuplot
Output:
out_spectra.txt
out_crabnebula.txt
plot1.eps
speed.eps
psf_surf.png
M92.png
PSFCorrected.png
Some of the figures produced:
M92
Filtered
PSF
To understand what these show, read the project.