Meets MWF 10:00-10:50 Regener Hall 118


Instructor: Prof. Keith Lidke

Room 1140, Physics and Astronomy
e-mail: klidke@unm.edu
phone: (505)277-0302

Teaching Assistant: Hanieh Farsibaf

e-mail: hmfarsibaf@unm.edu

Office Hours

Prof. Lidke: Each day after class or by appointment.
Hanieh: Thursday 11:30-12:30 in lobby of Physics (Lomas & Yale) or by appointment.



Overview


This class is designed as an introduction to programming for the undergraduate physics major. The class begins with no assumption of prior programming experience. An emphasis will be on building strong programming skills using the MATLAB programming environment. Applications and examples will include data analysis (curve fitting and optimization), simulating physical systems, solving systems of linear equations and Monte Carlo techniques.

There is no required text for the class.



Grading


Letter grades correspond with numerical scores as given by this scale: Grade Scale. Grades will be assigned based on the following:

Homework (70%)

Weekly homework assignments will consist of problems that must be solved using MATLAB code. Each problem will be scored as 1 or 0 based on whether the code produces the correct result or not. The grader will not attempt to fix code in any way. An additional .1 points of extra credit will be given for each problem for well-documented code. I encourage students to study together and learn from each other. However, all homework must be created in its entirety by each student. Evidence of copied homework will result in all involved students being dropped from the class. Assignments are due at 24:00 on the due date. No late assignments will be accepted.

The grader must be able to easily run your homework and therefore there must not be any confusion between your submissions and that from others. Homework submissions must be in the format: "LastName_HW1.m". If the solution consists of multiple files because of multiple problems or functions, then name files "LastName_HW1_Problem1.m" or "LastName_HW1_FuncName.m".

Submission Procedure: Login to your learn.unm.edu account. Find the current homework assignment for Physics 290. Upload each *.m file as an separate file. Let me know if you have problems. As a LAST resort if you are having problems, you may email me your files with subject line '290 Homework X'.

Quizes (20%)

Each Friday class will start with a short ~10 point quiz. Lowest scoring quiz of the semester will be dropped. No make-up quizzes will be offered.

Final Exam (10%)




Home Work Assignments

Homework Due Date Assignment Solution
1 15-Jan HW1.m
HW1_Solution.m
HW1_Solution_CalSquare.m
2 22-Jan HW2.m
HW2_Solution.m
HW2_Solution_isprime.m HW2_Solution_MathOps.m
EC1 27-Jan EC1.m
3 29-Jan HW3.m
HW3_Solution.m HW3_Solution_NIntegrate.m
4 9-Feb HW4.m
HW4_Solution.m HW4_Solution_ODESolver.m
5 16-Feb HW5.m
HW5_Solution.m HW5_Solution_ODESolver.m
HW5_Solution_CentralPotential.m
HW5_Solution_Planet.m
EC2 20-Feb EC2.m
6 23-Feb HW6.m
HW6_Solution.m HW6_Solution_RootFinding.m
7 2-Mar HW7.m
HW7_Solution.m HW7_Solution_GoldenSection.m
HW7_Solution.pdf
8 16-Mar HW8.m
HW8_Solution.m HW8_Solution_myHist.m
9 23-Mar HW9.m
HW9_Solution.m
10 30-Mar HW10.m
HW10_Data.mat
HW10_Solution.m HW10_Solution_Exponential.m
EC3 10-April EC3.m
EC4 17-April EC4.m
11 13-April HW11.m
HW11Data.mat
HW11_Solution.m HW11_Solution_SlopeLogL.m
HW11_Solution_GUI.m
12 20-April HW12.m
HW12Data.mat
HW12_Solution.m
13 1-May HW13.m
HW13_Solution.m
HW13_Solution_2DIsing.m
2DIsingPhaseTransition.png
Final 8-May Final Exam Project Due.



Lecture Notes



Date Skills and Concepts Discussed MATLAB Lecture Notes

12-Jan


Working in the Command Window and Editor; 'for' and 'while' loops; Using 'help' and 'doc'; Basic data types.

Jan_12.m

14-Jan


Arrays and Matrices; Plotting; Functions. Additional Material: Printing text to Command Window (fprintf); Conditional Statements;

Jan_14.m
AddVars.m

16-Jan


Structures; Intro to Object Oriented Programming

Jan_16.m
CheckPrime.m
LaserData

21-Jan


Creating a class definition; Creating and using objects.

Jan_21.m
LaserData2.m

23-Jan


Practice creating a class definition and using objects; Short intro to numerical integration.

Jan_23.m
CalcPrimes.m

26-Jan


Matrix versus Element-wise operations; Numerical integration; Anonymous functions.

Jan_26.m
NIntegrate.m

28-Jan


Switch-Case conditional; Class constructor and destructor; Creating video files; Mass on a spring visualization.

Jan_28.m
ConTest.m
Mass on spring math

30-Jan


Solving first order ODEs using the Euler method

Jan_30.m


2-Feb


Solving second order ODEs using the Euler method

Feb_2.m


4-Feb


Saving and loading files; Solving second order ODEs using THE Runge-Kutta method

Feb_4.m


6-Feb


General Q&A. Practice with classes.

Feb_6.m
SimpleClass.m


9-Feb


Rutherford Scattering

Feb_9.m
CentralPotential.m
ODESolver.m


11-Feb


Kepler Orbits

Feb_11.m
Planet.m


13-Feb


Error handling; Some simple linear algebra.

Feb_13.m
mycross.m


16-Feb


Root finding and minimization: Newton's method.





18-Feb


Root finding and minimization: Newton's method continued.



Feb_18.m
NewtonSolver.m


20-Feb


MATLAB's 'Publish' functionality; Root finding and minimization: Secant method.





23-Feb


Intro to random numbers; Finding a function minimum on an interval.

Feb_23.m
MinFinder290.m


25-Feb


Finding a function minimum using the Golden Section Search method.

Feb_25.m
updateGRInterval.m


27-Feb


Snow Day!


2-March


More about Golden Section Search; Rutherford scattering revisited.


4-March


Central Limit Theorem; Random Walks
March_4.m


6-March


Multi-dimensional Function minimization using 'fminsearch'
March_6m


16-March


Logic with vectors; Finding pi with random numbers
March_16m


18-March


Statistics of constant rate processes; Waiting time distribution
See March_20


20-March


Statistics of constant rate processes; Poisson Distribution; Intro to parameter estimation
March_20.m


23-March


Parameter estimation from noisy data
March_23.m
firstOPoly_Poiss.m
firstOPoly_Norm.m

25-March


Uncertainty of Parameter Estimates I
March_25.m
firstOPoly_Norm.m

27-March


The Monte Hall Problem; Intro to Bayes' Rule.
A student simulation from class

30-March


Uncertainty of Parameter Estimates II
March_30.m
PoissLambdaLogL.m

3-April


Markov Chain Monte-Carlo (MCMC); Intro to programmatic GUI
April_3.m
simplegui.m

6-April


Using a GUI from a class
April_6.m
FirstOrderPoly.m

8-April


The Symbolic math toolbox
April_8.m


10-April


Complex numbers and waves
April_10.m


13-April


Interference and Diffraction (Continued from April 10)
April_13.m


15-April


Intro to Fourier Transforms
April_15.m


17-April


More Fourier Transforms
April_17.m


20-April


1D Ising Model
April_20.m


22-April


2D Ising Model
April_22.m


24-April


2D Ising Model continued; correlation length; Polymer models
April_24.m
WLCvsF.m
GenTestVector.m


27-April


The inversion method; Selecting a vector with random orientation in 3D; Class Inheritance
April_27.m
TestClassA.m
TestClassAB.m
TestClassC.m
TestClassACB.m


29-April


Correlation length and radial averaging
April_29.m




Reference Material

A reference text recommended by a student in our class: MATLAB for Engineers

Installing MATLAB

Create an account at mathworks.com using your UNM email address.
Download and install MATLAB 2014b or later. We will not need or use most toolboxes. If you want to save download time and disk space, just install MATLAB and these toolboxes:
Statistics
Symbolic Math Toolbox

Others I find useful, but we will probably not use in class are:
Image Processing Toolbox
Optimization Toolbox
Parallel Computing Toolbox
Signal Processing Toolbox

At the point where it asks you to validate, you need to sign in with your mathworks account and provide an activation key. The key is given in the pdf linked to this page under the MATLAB section.


MATLAB Examples


Other

MATLAB documentation

MIT OCW MATLAB course

Interview with Cleve Moler, creator of MATLAB

Numerical Recipes

http://www.cplusplus.com

http://www.cprogramming.com "