Numerical methods in LQG

The aim of this notebook is to familiarize you with the basic Mathematica instructions we will use in these lectures.

At the beginning of the lectures we will need to switch to slide mode. Click on the menu

Palette  Slide Show

A floating menu should popup and click Start Presentation

You can navigate the presentation using the arrows on the top

Let’s go to the next slide.

2+2

To execute a Mathematica command (function) put the cursor on the cell and press Shift + Enter. Executable cells are different from text cells, which you can recognize by the different font. You can do basic arithmetic (the multiplication is done by just putting a space between the numbers or with *). Try it yourself.

2+2

3 4

12/2

3-1

4!

Functions

Mathematica has a plethora of functions already available to you. The functions usually have descriptive names and the arguments are denoted with square brackets. If you are uncertain of how to use a specific function you can just click on its name and press F1 to open a help page with details and examples.
For example. The binomial coefficient  can be computed as

Binomial[n,k]

Try to open the Help page. (You can also navigate to these pages via Help  Wolfram Documentation.) The result is a number only if both n and k are specified.

Binomial[5,2]

You can also use variables and assign values to n and k

n=5
k=2

Binomial[n,k]

Now, n and k are locked to be variables for the rest of the session. You can change their value or unload them

n=10

Binomial[n,k]

Clear[n,k]

Binomial[n,k]

Mathematica also handles symbolic expressions. If you want to see familiar expressions you can use

FunctionExpand[Binomial[n,k]]

Here Gamma is used in the place of the more familiar factorial since when in doubt Mathematica assumes that all variables are complex.

Polynomials and equations

Play around with polynomials

(x+y)^3

Expand[(x+y)^3]

(x+y)^3-(x+y)^2

Expand[(3x+y)^3-(x+2y)^2]

You can solve equations using Solve. Use == to equate an expression to 0. Use of a single = is reserved to assign values.

Solve[x^2-2x +1==0,x]

Solve[x^2-2x +y==0,x]

Functions

Other useful functions we will use are

Range[10]

which lists all the numbers between 1 and 10. Functions will usually have multiple different usages. Use the Help to explore all of them.

Range[5,10]

Range[1,20,2]

Numbers between curly brackets are lists. Imagine them as vectors.

v={x,y,z}

Many useful functions involving vectors are available. For example:

Norm[v]

t={p,q,r}

Cross[v,t]

v.t

the Dot . product is the Euclidean scalar product between vectors. It is also used to contract matrices with vectors

M={{a,b,c},{d,e,f},{g,h,i}}

MatrixForm[M]

M.v

Matrix Form is just used for visualization of matrices. You cannot

MatrixForm[M].v

You can also use operations with matrices

M.M

Det[M]

Inverse[M]

FullSimplify[Inverse[M].M]

Plots

Mathematica has thousands of different options when making plots

Plot[Sin[x],{x,-5,5}]

Plot[x^3,{x,-5,5}]

LogLogPlot[x^3,{x,-5,5}]

And discrete plots (the function Table produces tables)

table=Table[{x,x^3},{x,1,100}]

ListPlot[table]

ListLogLogPlot[table]

Exercise

Quit[]

Prove that the matrix U is unitary if Det[U] = 1

U={{a,-Conjugate[b]},{b,Conjugate[a]}}