Physics 256 - Practical computing for scientists

by Eugeniy E. Mikhailov

Fall 2016

General class information

Syllabus html pdf

Tentative calendar

Tentative list of topics

Office hours

Office hours are 12pm-1pm MTF. Or schedule an appointment.

Grader

ShuangLi Du.

Online grades

Grades are posted into the web grades book. Make sure that posted grades coincide with their paper one.

For the first time login use your WM official email as “login” and hit the reset password button. You will get a password shortly via email.

If you have any suggestions or comments, please, let me know.

Topics covered

Week 1

Lecture 01 - Computers and programming languages introduction

  • Class goals and structure
  • Computers introduction
  • Programming languages overview
  • Discretization - the main weakness of computers
  • Binary representation

presentation and handouts

Lecture 02 - Introduction to Matlab

  • Matlab as a fancy calculator
  • Efficient editing
  • Help related commands
  • Operators precedence
  • Matrices
  • Colon (:) operator
  • Plotting
  • Array element-wise arithmetic operators

presentation and handouts

Week 2

Lecture 03 - Boolean algebra, conditional statements, loops.

  • Boolean algebra
  • Comparison operators
  • Conditional statements
  • Loops
  • Series

presentation and handouts

Lecture 04 - Functions and scripts

  • Scripts
  • Functions
  • Saving and loading variables

presentation and handouts

Complimentary code

Week 3

Lecture 05 - Data reduction and fitting

  • Goodness of the fit
  • Parameter uncertainty estimations
  • Homemade implementation of the fitter
  • Matlab built-ins

presentation and handouts

Complimentary code

Lecture 06 - Data analysis example

presentation and handouts

Complimentary code

echodemo day_temp_analysis_session

In class practice

Week 4

Lecture 07 - Root finding

  • Root finding problem
  • Bisection method
  • False position method
  • Solution convergence

presentation and handouts

Complimentary code

Lecture 08 - Root finding continued

  • Secant method
  • Newton-Raphson method
  • Numerical derivative of a function
  • Ridders method
  • Root finding algorithms gotchas
  • Root finding algorithms summary

presentation and handouts

In class practice

  • Rough implementation of the Newton-Raphson algorithm.
    • How to use it with analytical and numerical derivatives.
  • Danger of very small step in the numerical derivative calculation.

Week 5

Lecture 09 - Numerical integration

  • Integration problem statement
  • The Rectangle method
  • Trapezoidal method
  • Simpson method

presentation and handouts

Lecture 10 - Numerical integration continued

  • Monte Carlo Integration
  • Numerical Integration methods error estimates
  • Multidimensional integration
  • Matlab functions for integration

presentation and handouts

Complimentary code

In class practice: The volume of multi-dimensional sphere

Week 6

Lecture 11 - Other useful tools

  • Scientist toolbox
  • Free software
  • Version control software
  • Final remarks

presentation and handouts

Lecture 12 - Fractals

  • Dimension definition
  • Fractals
  • Affine transformations
  • Coastline length problem

presentation and handouts

Complimentary code

In class practice: Eugeniy’s work flow: remote access, git, and make demos.

Week 7

Lecture 13 - Random number generators and random processes

  • Statistic and probability intro
  • Random number generators

presentation and handouts

Complimentary code

Lecture 14 - Monte Carlo simulations

  • Coin flipping bets
  • Matlab arrayfun
  • The Monty Hall Paradox
  • 1D disease spread

presentation and handouts

Complimentary code

In class practice: going over the virus spread code and the midterm.

Week 8

Lecture 15 - Optimization problem

  • Introduction to optimization
  • 1D minimization with the Matlab’s built-in: fminbnd
  • 1D optimization - golden section search

presentation and handouts

Complimentary code

Lecture 16 - Multi-D optimization problem

  • Multi-D optimization
  • Matlab built in Multi-D minimization - fminsearch
  • Sample problems

presentation and handouts

Complimentary code

Week 9

Lecture 17 - Combinatorial optimization

  • Introduction to the combinatorial problem
  • Backpack problem - brute force approach
  • Traveling salesman problem
  • Permutation generating algorithm

presentation and handouts

Complimentary code

Lecture 18 - Simulated annealing/Metropolis and genetic optimization

  • Simulated annealing/Metropolis algorithm
  • Genetic algorithm

presentation and handouts

Complimentary code

In class practice: deriving and optimizing a student happiness merit function

Week 10

Lecture 19 - Ordinary Differential equations

  • ODE - ordinary differential equations
  • Cauchy boundary conditions
  • Euler’s method

presentation and handouts

Complimentary code

Lecture 20 - Ordinary Differential equations continued

  • The second-order Runge-Kutta method (RK2)
  • The forth-order Runge-Kutta method (RK4)
  • Matlab functions for ODEs

presentation and handouts

Complimentary code

In class practice: help with the midterm project.

Week 11

Lecture 21 - System of linear algebraic equations

  • Matlab solvers

presentation and handouts

Complimentary code

Lecture 22 - Data interpolation

  • Nearest neighbor interpolation
  • Linear interpolation
  • Polynomial fit
  • Cubic spline interpolation
  • Matlab built in interpolation
  • Extrapolation

presentation and handouts

Complimentary code

In class practice:

  • interpolation use example: what is the closest distance between two trajectories.
  • help with the midterm project.

Week 12

Lecture 23 - Secure communications

  • Secure communication and encryption.

presentation and handouts

Lecture 24 - High performance computing

  • Limits to computing speed and storage
  • Parallel computing
  • MATLAB’s parallel tools

presentation and handouts

Complimentary code

In class practice:

  • help with the midterm project.

Week 13

Lecture 25 - Fourier transform

  • Fourier series
  • Discrete Fourier transform (DFT)
  • Matlab implementation

presentation and handouts

Complimentary code

Lecture 26 - Discrete Fourier Transform and filters

  • Discrete Fourier transform
  • Nyquist criteria
  • DFT filters

presentation and handouts

Complimentary code

In class practice:

  • Voice FFT for different people. Use of audiorecorder from MATLAB. Musical notes singing analysis via time dependent spectrum in the separate SpectralView app. Delta function decomposition, i.e. a clapping sound fft.

Week 14

Lecture 27 - Digital filters

  • Speed of FFT
  • Low-pass filter
  • High-pass filter
  • Band-pass filter
  • Band-stop filter
  • Brick wall filters artifacts
  • Windowing
  • Other DFT applications

presentation and handouts

Complimentary code

Week 15

Lecture 28 - Sorting

  • Bubble sort method
  • Quick sort method
  • Heap sorting method
  • The vector heap representation
  • Matlab built ins ‘issorted’ adn ‘sort’

presentation and handouts

See what the president Obama (a senator at that time) has to say about the bubble sort method. Skip to the 34th second.

Complimentary code

Homeworks

Due date is on Monday at 1pm, unless specified otherwise. Make sure to add phys256 to the subject line of your email submission.

Have a look at the sample homework report.

Prerequisite: Install Matlab

Visit W&M IT software support page and download Matlab from appropriate “Licensed Software >> Math & Statistics Software” section. They have several available versions. Either one is fine. Since we are learning Matlab, we will not have time to go to fancy toolboxes which Matlab provides/removes with new releases.

They do have versions for Macs and Linux but you might need to ask for it.

HW 01

Complete an introductory survey.

See assignment in the hw01.pdf. Feel free to use hw01.tex for copy-pasting of the problem statements.

HW 02

Assigned reading: scripts and functions chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

See assignment in the hw02.pdf. Feel free to use hw02.tex for copy-pasting of the problem statements.

data file hw02dataset.dat

HW 03

Assigned reading: fitting chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

See assignment in the hw03.pdf. Feel free to use hw03.tex for copy-pasting of the problem statements.

Data files

HW 04

Assigned reading: numerical derivatives chapter and root finding algorithms chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

See assignment in the hw04.pdf. Feel free to use hw04.tex for copy-pasting of the problem statements.

HW 05

Assigned reading: numerical integration chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

See assignment in the hw05.pdf. Feel free to use hw05.tex for copy-pasting of the problem statements.

Midterm 01

Due date Monday October 3rd of 2016 at 1pm.

See assignment in the midterm01.pdf. Feel free to use midterm01.tex for copy-pasting of the problem statements.

HW 06

HW is due on Wednesday 10/12. See assignment in the hw06.pdf. Feel free to use hw06.tex for copy-pasting of the problem statements.

Assigned reading: random number generators chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

HW 07

See assignment in the hw07.pdf. Feel free to use hw07.tex for copy-pasting of the problem statements.

Assigned reading: optimization chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

HW 08

Continue to read: optimization chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

See assignment in the hw08.pdf. Feel free to use hw08.tex for copy-pasting of the problem statements.

Midterm 02

Due date Monday October 31st of 2016 at 1pm.

See assignment in the midterm02.pdf. Feel free to use midterm02.tex for copy-pasting of the problem statements.

Notice apostrophes in the saving of the movie statement

save('movie_file.mat', 'map_evolution_movie')

HW 09

See assignment in the hw09.pdf. Feel free to use hw09.tex for copy-pasting of the problem statements.

Assigned reading: ODEs chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

Midterm 03

Due date Monday November 14th of 2016 at 1pm.

You can work in a group with the size of 1, 2, or 3 teammates. A team must not consist of any subset of students who have previously worked together on a midterm in this class.

See assignment in the midterm03.pdf. Feel free to use midterm03.tex for copy-pasting of the problem statements.

You might find useful: ODEs chapter. Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

HW 10

You might find useful: DFT chapter and Digital filters chapter Let me know if you spot typos, mistakes, or something strangely sounding. I will give bonus points for corrections and suggestions. Please, make sure that you are referring to the most up-to-date pdf, since I am fixing typos as soon as they are reported or spotted.

See assignment in the hw10.pdf. Feel free to use hw10.tex for copy-pasting of the problem statements.

Complimentary data file hw_data_for_filter.dat

Final exam

You can work in a group with the size of 1, 2, or 3 teammates. No constrains on the team composition, but I advise you to find teammates with a similar to you schedule.

See assignment in the final_exam_2016.pdf. Feel free to use final_exam_2016.tex for copy-pasting of the problem statements.

The Electronic submission deadline for the report and listings is 2pm on December 6th.

Problem files

Data file for problems 1, 2, and 3 capsule_and_plane_problem_datafile1.mat.

Function templates

Voice messages for problem 4. Each group must decode only the one assigned to them.

Some test cases to help you with your simulator check

For problem 1

>> [time,x,y] = capsule_flight_simulator(300, 2, 500, .1, 2*pi/5 );
>> time(end)
ans =
   42.8555
>> x(end)
ans =
   1.6716e+03
>> y(end)
ans =
   5.0681e-04

For problem 2

>> [MaxHeight, t_at_max, vx_at_max, x_at_max] = capsule_max_height_parameters(300, 2, 500, .1, 2*pi/5 )
MaxHeight =
   2.2089e+03

t_at_max =
   16.9071

vx_at_max =
   38.2439

x_at_max =
   1.0391e+03

For problem 3 which is run against file capsule_and_plane_problem_datafile2.mat.

>> [ElevationAngle, Vescape, Tlaunch] = capsule_launch_solution( 'capsule_and_plane_problem_datafile2.mat');

Vescape =
  637.3440


ElevationAngle =
    1.4033


Tlaunch =
    7.1754