## Programming and PHY 3101

### Programming tools in PHY 3101

In this course I will introduce you to two free programming tools that are extensively used (and are similar to others that are heavily used) by physicists and engineers: python, a general purpose programming language, and one of several possible tools that can be used to manipulate and solve mathematical expressions in symbolic form. The tools are free (costly ones such as Mathematica Maple, etc. are also possible) and run on all popular operating systems (Windows, Mac, Linux).

• Python: Python is a 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"). Python is a powerful tool for solving problems where one has to use conditional logic, loops and external routines. It also has many libraries that extend its power. However, we will only use its most basic features in this course.
• CAS software: You should also acquire a "computer algebra system" or CAS, capable of doing mathematics in symbolic form. A CAS allows you to manipulate mathematical expressions in symbolic form (trig functions, polynomials, special functions, etc), work with exact rational expressions like 2/5 + 1/3, differentiate and integrate complex expressions, compute Taylor series to arbitrarily high powers, solve equations and differential equations, and plot functions.

### Substitutions

If you have MatLab, R, C++ or C you can use those instead of python

For the CAS, you have several choices.

• Sympy: This was my original recommendation. However, further research has convinced me that this software is not easily downloaded and installed by people who are not Unix users. However, if you do install it, I have provided tutorials below.
• wxMaxima: I have used wxMaxima for several years in another class with good results. I have provided tutorials for it below.
• Sage: I have also used Sage in a previous class and have tutorials for it below. Note that it comes packaged for Windows and Mac OSX, but is a very large download and install.
• Sagecloud: This Sage site is operated by the University of Washington under an NSF grant. It allows multiple users to access its resources. You can get a free account and start using it immediately. You can create, edit, execute and save programs at the site. You can also upload and download Sage programs to/from your local machine.
• Mathematica: Mathematica is a commercial product that is expensive, though it is available as a relatively inexpensive student version. However, it can also be used for free at the UFApps site. Please check out this option.
• Maple: I used Maple several years ago, but have not used it lately. It costs money but it is a nice program.

### Optional CAS tool: Sage

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. Sage has become somewhat complicated to install, and it doesn't appear to work with Windows, so I am providing a link to the cloud version at the University of Washington. Once you get an account, you can play with the system and try the tutorials.

 Sage tutorials and resources Cloud version of Sage This Sage site is operated by the University of Washington under an NSF grant. It allows multiple users to access its resources. You can get a free account and start using it immediately. You can create, edit, execute and save programs at the site. You can also upload and download Sage programs to/from your local machine. Cloud Sage tutorial You have to create an account and login to test out the system. However, there does not seem to be a tutorial that teaches you how to use it. 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.

### Optional CAS tool: wxMaxima

wxMaxima (a graphical version of Maxima) is another CAS program. 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.

 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.

### Optional CAS tool: Sympy

Sympy is written entirely in Python so after installation it is very easy to use. The problem, as noted above, is downloading and installing it. If you are proficient with python installations or use a python package distribution, this might not be a problem.