1. Loops

1.1. What is the difference between the While and Do loops that were presented in the lecture notes?

1.2. Using the For, While and Do loops, write the Mathematica commands that  calculate the n first Fibonacci numbers, defined according to the relation
	(Subscript[x, i]) = (Subscript[x, i - 1]) + (Subscript[x, i - 2]),  
      i ≥ 2
(Subscript[x, 0]) = 0
(Subscript[x, 1]) = 1
ie, each Fibonacci number is the sum of two previous ones. Ask the number n from the user. To print out the numbers you can use the Print-command.

1.3. Calculate the sum (∑_(i = 0)^10) (i^2) using Do- and While loops.

1.4. Calculate the values (Subscript[y, i])for i = 0, …, 10 when y is given by the recurrence
	(Subscript[y, i]) = 2 (Subscript[y, i - 1]) + 4  (Subscript[y, i - 2])
(Subscript[y, 0]) = 1
(Subscript[y, 1]) = 4.
Write the numbers (Subscript[y, i]) into a file called arvot.dat.
	
1.5. Advanced: The Hénon map.  Make a loop that iterates the famous Hénon map
	(Subscript[x, i + 1]) = 1 + (Subscript[y, i]) + a ((Subscript[x, i])^2)
(Subscript[y, i + 1]) = b (Subscript[x, i]), a = 1.4
b = 0.3.
Try if you can store the results in a list of points ((Subscript[x, i]), (Subscript[y, i])) and plot those! (You can use the Append command to add (x, y) pairs to a list)

2. Schrödinger equation

2.1 Try to find the first excited state of the hydrogen atom and the corresponding wavefunction.

2.2. Advanced - do this only if you have time. When solving the eigenvalue E we do not necessarily need to write a loop ourselves. We are only looking for a root of the function Δ(E), so, if we can write Δ as a Mathematica function, we can use the FindRoot command to locate the energies E. Try to do this. You can use the Module command to wrap the commands for calculating Δ into a function. Module command takes two arguments, first a list of local variables (that is, variables that you only use inside the function) and second, the commands separated by semicolons (;). Inside the Module command, you can use the Return -command to return the value for delta. Your function Δ in Mathematica could look something like this:

Delta[e_] := Module[
	{rata, ratl, …},
	rata=NDSolve[{yhtalo, …];
	…
	ero = logalk[rvali] - loglop[rvali];
	Return[ero]];
	
You can now plot the function Delta, and use FindRoot to get the energy eigenvalues!

3. Matrices

3.1 Define matrices
	A=(({{1, 2}, {3, 4}})), B=(({{0, 1}, {1, 1}})),
and the vectors 
	X=(({{1}, {2}})), Y=(({{3}, {4}})).
Do the following
(a) Calculate the expressions A B,  B A ,  A X,  
      X·Y and A B - B A
(b) Find the determinant of A, det A.
(c) Solve the equation A Z = Xfor Z. Check the result by substituting Y back into the equation
(d) Find the inverse (A^(-1)) and calculate (A^(-1)) A.
(e) Find the transposed matrix (A^T).
(f) Find the eigenvalues and eigenvectors of A.
(g) Using Mathematicas help system, can you find a command that calculates the cross-product? Use it to calculate X×Y.

3.2 Advanced - try this only if you are interested and have time. Vector calculus Mathematica commands can be found in the package Calculus`VectorAnalysis`. Can you find a way to calculate the gradient ∇f(x, y, z), divergence \(TraditionalForm\`∇\(\(·\)\(\(G\&_\)(x, y, z)\)\)\) and curl \(TraditionalForm\`∇\(\(×\)\(\(G\&_\)(x, y, z)\)\)\) for the scalar function f(x, y, z) = 1/(Sqrt[(x^2) + (y^2) + (z^2)]) and vector function \(TraditionalForm\`\(G\&_\)(x, y, z) = \((x\^2 + y, y + z, z\ x)\)\)?