**Welcome to the home page Computational Physics Courses in the School of Physics and Astronomy at Cardiff University.**

**This page includes the content for PX1224: Computational Skills for Problem Solving**

The course uses the Python programming language and the Spyder development environment.

# Why learn computational skills?

Most real world physics and astronomy problems are difficult to solve exactly using the mathematical techniques that you are learning. The problems which are assigned in classes are specially chosen so that you can solve them with the techniques you have learned. However, most problems cannot be solved in this manner and in general we must either:

- Make some approximations in order to be able to solve the problem. For example, it's quite common to neglect air resistance when solving mechanics problems. There is a real skill in knowing which effects can safely be ignored when seeking approximate solutions.
- Make use of computational methods to solve the problem numerically. This involves taking the problem and implementing the solution on a computer. Again, this will not provide an "exact" solution and care must be taken with assessing the numerical accuracy of the solution.

Computers are also very useful for analyzing experimental data. As a simple example, it is much quicker (and more accurate) to calculate a best fit line, and associated errors, on a computer rather than making the plot by hand. The same is true for more complex experimental data which can only be analyzed on a computer due to both the complexity of the data and the size of the data sets.

Computers can also be used for simulations. Often, it is useful to have an idea of the result you might expect from an experiment before performing it. If you can code up a simulated experiment on a computer, then you can run the experiment many, many times to get a sense of the results that you would expect to obtain.

In the first year course, we will introduce some basic computational techniques, and show how they can be used to solve problems that you’ve seen in other courses and labs. This is expanded upon in the second and third year computing classes.

# Why Python?

Python is a relatively new language (started in 1990) that has become widely used in recent years. There are several reasons that we have chosen to use the Python programming language in the Cardiff computational physics courses:

**Python is an interactive language.**This means that you don't have to compile and then run the code before you see what it does; you can execute each line as you type it. This feature makes it much faster to get going in Python.**Python is freely available.**Python runs on Windows, Mac and Linux (in case you were wondering) and can be freely downloaded and used on any of these systems. This means that you will be able to download and install Python on any PC or laptop that you have access to.**Python is widely used in the school.**A growing number of research groups in the department use Python. For example- Gravitational wave astronomy
- Herschel Astronomy
- Nanophysics

**Python is used in the real world**. Companies that use Python internally include Google, Yahoo, and Lucasfilm Ltd. For more examples, see Organizations Usign Python. It is also regularly rated as one of the ten most used languages.