# Tutor profile: Conor W.

## Questions

### Subject: Python Programming

Construct a piece of python code that will take a list of tuples (tuple_list), determine all unique values in all of the tuples, and return a dictionary (freq_dict) containing how many times each value appeared in each tuple as a list associated with that value.

To determine the values in the tuples, we first define a list into which every value (including duplicates) can be saved: all_values=[] We then use a for loop to go through each tuple and another loop over the tuple to add every value to our list: for tup in tuple_list: $$\quad$$for val in tup: $$\quad\quad$$all_values.append(val) To get a list of the unique values in this new list, we can use the properties of sets. Sets are defined such that they may only have one of each value, with no duplicates. We may take a version of this list that is a set to remove all duplicates, then return it to a list for our use: val_set=set(all_values) unique_values=list(val_set) To find the number of each value in each tuple, there are many available methods. The method we will use will be to use more nested for loops. First, defining the results dictionary, and then writing the algorithm: freq_dict={} for val in unique_values: $$\quad$$val_freq_list=[] $$\quad$$for tup in tuple_list: $$\quad\quad$$counter=0 $$\quad\quad$$for tup_val in tup: $$\quad\quad\quad$$if val == tup_val: $$\quad\quad\quad\quad$$counter += 1 $$\quad\quad$$val_freq_list.append(counter) $$\quad$$freq_dict[val]=val_freq_list This will give the dictionary freq_dict where each unique value has associated with it a list containing the number of times it appeared in each tuple in tuple_list in the order that the tuples are listed in the original list.

### Subject: Calculus

Solve the differential equation $$\frac{dy}{dx}=5y^{3}x^{2}$$ with the initial condition $$y(3)=1$$.

This differential equation requires the use of the separation of variables. With this method, we want to have components involving the y variable on one side of the equation, and components involving x on the other side. To do this, we can divide through by $$y^{3}$$ and multiply through by $$dx$$: $$\frac{dy}{dx}=5y^{3}x^{2} \rightarrow \frac{dy}{y^{3}}=5x^{2} dx$$ The next step is to find the integral of both sides in order to remove the differentials: $$\int y^{-3} dy=\int 5 x^{2} dx$$ As we know from antiderivatives, the rule for integrating powers of a variable is: $$\int z^{n} dz = \frac{z^{n+1}}{n+1} + c$$ where c is some constant Using this rule on our two integrals: $$\int y^{-3} dy=\int 5 x^{2} dx \rightarrow \frac{y^{-2}}{-2} +c_{1}=5 \frac{x^{3}}{3}+c_{2}$$ The values of the constants are not important at this stage, and can be brought together into a single constant: $$\frac{y^{-2}}{-2} =\frac{5 x^{3}}{3}+c$$ Rearranging to find y in terms of x: $$y^{-2}=\frac{-10 x^{3}}{3}+c \rightarrow y=\frac{1}{(\frac{-10 x^{3}}{3}+c)^{2}}$$ Where c is unchanged as the value does not matter in this step. We can now solve for c using the initial condition: $$y(3)=1$$ This is done by substituting $$x=3$$ into the solution: $$y(3)=\frac{1}{(\frac{-10 (3)^{3}}{3}+c)^{2}}=1 \rightarrow \frac{1}{(-90+c)^{2}}=1$$ As $$3^{3}=27$$ and $$\frac{10 \times 27}{3}=90$$. Multiplying through and solving for c we get: $$\frac{1}{(-90+c)^{2}}=1 \rightarrow (-90+c)^{2}=1 \rightarrow \pm(-90+c)=1 \rightarrow c-90=\pm1 \rightarrow c = 90\pm1$$ Here we see two solutions because the square term can be $$\pm 1$$ and still give a final result of 1. Therefore, the two equations corresponding to these solutions that satisfy the equation and have the initial condition are: $$y=\frac{1}{(\frac{-10 x^{3}}{3}+91)^{2}}$$ and $$y=\frac{1}{(\frac{-10 x^{3}}{3}+89)^{2}}$$

### Subject: Physics

What is the wavelength ($$\lambda$$) of a photon emitted due to the decay of a particle in a one-dimensional infinite square well potential with width a from the first excited state to the ground state?

The one-dimensional infinite square well potential has the potential: $$V(x)=0, \, 0<x<a$$ $$V(x)=\infty, \, x < 0 \, or \, x > a$$ This can be solved by the Schrodinger equation: $$E \psi = \frac{- \hbar^{2}}{2m} \frac{\partial^{2}}{\partial x^{2}} \psi + V(x) \psi $$ Separating into the two domains, starting with the area outside of the well, we see that because the potential energy V(x) is infinite, and we want a finite energy E, we must have $$\psi=0$$ in this domain. Inside the well, we have $$V(x)=0$$ which then gives: $$E \psi = \frac{- \hbar^{2}}{2m} \frac{\partial^{2}}{\partial x^{2}} \psi \rightarrow \frac{-2mE}{\hbar^{2}}\psi = \frac{\partial^{2}}{\partial x^{2}} \psi \rightarrow -k^{2} \psi = \frac{\partial^{2}}{\partial x^{2}} \psi$$ Where $$k^{2}=\frac{\sqrt{2mE}}{\hbar}$$. We should recognise this now as a second-order differential equation. Prior knowledge of differential equations is useful at this point, but with this knowledge we may know that: $$\frac{d^{2}}{dx^{2}} sin(kx) =-k^{2}sin(kx)$$ and $$\frac{d^{2}}{dx^{2}} cos(kx) =-k^{2}cos(kx)$$ This means that the general solution will be a linear combination of these two solutions: $$\psi = A sin(kx)+B cos(kx)$$ Knowing that the region outside of the well has $$\psi=0$$, the boundary conditions can be substituted in this equation to find the values of the constants A and B: $$\psi(0)=0 \rightarrow A sin(0) + B cos(0)= 0$$ We know from trigonometry that $$sin(0)=0$$ and $$cos(0)=0$$, which means that: $$B = 0$$ So the equation must take the form $$\psi=A sin(kx)$$. Substituting in the other boundary condition: $$\psi(a)=0 \rightarrow A sin(k a) = 0$$ As the wavefunction $$\psi$$ may not be zero in order to be renormalizable, the only possible solution is $$sin(k a)=0$$. Knowing the properties of the sine function, we know that $$sin(n \pi)=0$$ where n is an integer (1, 2, 3, ...), so: $$k a = n \pi \rightarrow k = \frac{n \pi}{a}, n=1, 2, 3...$$ We now have all we need to find the energy. Going back to the substitution $$k^{2}=\frac{\sqrt{2mE}}{\hbar}$$ to find: $$\frac{\sqrt{2mE}}{\hbar} = \frac{n \pi}{a} \rightarrow 2mE=\frac{n^{2} \pi^{2} \hbar^{2}}{a^{2}} \rightarrow E=\frac{n^{2} \pi^{2} \hbar^{2}}{2 m a^{2}}$$ The different values of n give different energy levels, with higher values corresponding to higher energies. The lowest level is called the ground state, and each above that is called an excited state. The first excited state corresponds to $$n=2$$ while the ground state is $$n=1$$. We can find the difference between these through simple subtraction: $$\Delta E = \frac{2^{2} \pi^{2} \hbar^{2}}{2 m a^{2}}-\frac{1^{2} \pi^{2} \hbar^{2}}{2 m a^{2}} \rightarrow \Delta E = (4-1) \frac{\pi^{2} \hbar^{2}}{2 m a^{2}}= \frac{3 \pi^{2} \hbar^{2}}{2 m a^{2}}$$ Finally, to find the wavelength $$\lambda$$ of a photon with this energy, we use the equation for photon energy in terms of wavelength: $$\Delta E = \frac{h c}{\lambda} \rightarrow \lambda = \frac{h c}{\Delta E}$$ Substituting in for $$\Delta E$$, and making a substitution of $$\hbar = \frac{h}{2\pi}$$, we get our final result: $$\lambda=\frac{2 m h c a^{2}}{3 \pi^{2} \hbar^{2}} \rightarrow \lambda=\frac{8 m c a^{2}}{3 h}$$

## Contact tutor

needs and Conor will reply soon.