Using Programming Languages
in PHZ4390
 
Main page
Overview
Programming
Online materials
Particle Data Book
  Summary tables of particles
  Basic review tables
  Particle listings
  Atomic / nuclear properties
  Astrophysics / cosmology
Other links
  Physics Department
  Other physics courses
  Comics

In this course I will introduce you to some programming tools that are similar to those used by particle physicists: python (a general programming language) and a computer algebra system such as wxMaxima or Sage . The tools are free (costly ones such as Mathematica Maple, etc. are also possible) and can run on all popular operating systems (Windows, Mac, Linux), although Sage needs special handling for Windows.

I recommend You need to download both software packages and install them on your home/laptop computer. If you have other tools like Mathe, you are free to use those instead.

Python is full-scale programming language (similar to C++ and Java) but has a much simpler syntax and runs directly without compiling (it's technically called a "scripting language"). Used extensively by physicists, Python has many libraries that extend its power. However, we will only use its most basic features in this course. You can download either the 2.7.x or the newer 3.x version since the differences are not that important at the elementary level. Python is a powerful tool for solving problems where one has to use conditional logic, loops and external routines.

Python tutorials and other resources
Official tutorial This is a useful tutorial on the Python website, but you probably want to start at Chapter 3.
Simple tutorial Good for those of you new to programming. It's aimed at Python v2.6, but it's perfectly adequate for learning any version.
   

wxMaxima (a graphical version of Maxima) is an advanced free tool that allows you to calculate symbolic or numerical expressions such as derivatives and definite or indefinite integrals; evaluate Taylor expansions to arbitrary order; sum finite or infinite series; solve equations and differential equations, plot expressions and functions, etc. Its documentation is not great, however, so I am providing you with tutorials that allow you to learn from examples, which is the way I learned it.

Below are some resources that you will find useful to come up to speed in wxMaxima. I will also provide worksheets that you can evaluate to test your skills.

wxMaxima tutorials and other resources
avery tutorial 1
pdf output
Basic wxMaxima, including syntax, exact and floating point math, basic expressions using polynomial, exponential and trig functions, factoring and expanding numbers and algebraic expressions, defining expressions and functions, substitution, trigonometric evaluation.
avery tutorial 2
pdf output
Derivatives, definite and indefinite integrals, taylor series, plotting functions
avery tutorial 3
pdf output
Sums of expressions in closed form, numerical integration, 2-D plots.
avery tutorial 4
pdf output
Not finished yet.
10 minute tutorial This is a short tutorial that you might find useful
William Stein tutorial A pdf file with Maxima examples
Ted Woollett page This site has several pdf files of increasing complexity that walk you through the Maxima language. I found it helpful when trying to understand some of the more arcane points of the language.

Sage is another possibility as a computer algebra system. It runs on top of Python and thus most of its commands use underlying Python syntax and constructs, a real plus when writing more than 1-line functions. Below are links to some tutorials that you might find useful for learning the syntax and capabilities.

Sage tutorials and other resources
avery tutorial 1
pdf output
Basic Sage, including syntax, exact and floating point math, arbitrary precision evaluation, basic expressions using polynomial, exponential and trig functions, factoring and expanding numbers and algebraic expressions, defining symbolic variables, defining functions, using substitution, trigonometric evaluation.
avery tutorial 2
pdf output
Derivatives, definite and indefinite integrals; taylor series; sums of powers of integers and expressions in closed form; using assume() to specify whether a variable is real, complex, integer, postive, etc.; special functions, paritcularly orthogonal polynomials.
avery tutorial 3
pdf output
2-D and 3-D plots.
Standard Sage tutorial This is from the Sage main page. It's useful, but tends to have too much information for users who don't care about the internals.