# Tutor profile: Evelyn D.

## Questions

### Subject: MATLAB

Read in a text file called $$\texttt{'data.txt'}$$ with 2 columns of data. Plot the text file data as a black line in a figure, with the first column on the x axis and the second column on the y axis. Mark the minimum y value with a blue circle and the maximum y value with a red +.

First read the data into a matrix: $$\texttt{data = readmatrix('data.txt')}$$ Separate the columns into two separate variables: $$\texttt{x = data(:,1);}$$ $$\texttt{y = data(:,2);}$$ Plot the line and keep the figure selected for future commands: $$\texttt{plot(x, y, 'k')}$$ $$\texttt{hold on}$$ Then find the minimum and maximum y values and their corresponding indices in the vector: $$\texttt{[miny,mini] = min(y);}$$ $$\texttt{[maxy,maxi] = max(y);}$$ Now we can plot the min and max values as specified: $$\texttt{plot(x(mini), miny, 'bo')}$$ $$\texttt{plot(x(maxi), maxy, 'r+')}$$

### Subject: Linear Algebra

Find the eigenvalues and eigenvectors of the following $$2 \times 2$$ matrix: $$\pmb A = \begin{bmatrix} 1 & -2 \\ -2 & 3 \end{bmatrix}$$.

The eigenvalues and eigenvectors of a matrix tell us how a linear transformation acts upon the matrix. In this problem, the first thing we need to find are the eigenvalues, which will then be needed to find the eigenvectors. To find eigenvalues, we know they need to satisfy the following equation: $$\pmb Ax=\lambda \pmb x$$, or $$(\pmb A - \lambda \pmb I) \pmb x = 0 $$. To find the eigenvalues according to the previous equation, we can use the following: $$det (\pmb A - \lambda \pmb I) = 0$$, where $$det (\pmb A - \lambda \pmb I)$$ is the characteristic polynomial. The first step here is to plug in $$\pmb A$$ and simplify: $$\left| \begin{bmatrix} 1 & -2 \\ -2 & 3 \end{bmatrix} - \begin{bmatrix} \lambda & 0 \\ 0 & \lambda \end{bmatrix}\right| = \begin{vmatrix} 1-\lambda & -2 \\ -2 & 3-\lambda \end{vmatrix}$$ Now we evaluate the determinant, setting it equal to 0: $$\begin{vmatrix} 1-\lambda & -2 \\ -2 & 3-\lambda \end{vmatrix} = (1-\lambda)(3-\lambda)-(-2)(-2) = \lambda^2 - 4\lambda - 1 = 0$$ We can use the quadratic formula $$\lambda = \frac{{ - b \pm \sqrt {b^2 - 4ac} }}{{2a}}$$ to find the factors, where $$b=4$$, $$c=-1$$, and $$a=1$$: $$\lambda = \frac{{ 4 \pm \sqrt {4^2 + 4} }}{{2}}= \frac{{ 4 \pm \sqrt {20} }}{{2}}=\frac{{ 4 \pm 2\sqrt {5} }}{{2}}= 2 \pm \sqrt {5} $$. Since our matrix is $$2 \times 2$$, we have the maximum number of unique eigenvectors, 2. These are: $$\lambda_1 = 2+ \sqrt{5}$$ and $$\lambda_2=2-\sqrt{5}$$. So now we have solved the first part, and we can use our newly calculated eigenvalues to find the eigenvectors $$\pmb v_1$$ and $$\pmb v_2$$ by plugging each eigenvalue into the equation $$(\pmb A - \lambda \pmb I) \pmb v = 0$$. The nullspace of $$(\pmb A - \lambda \pmb I)$$ is $$\pmb v$$, and can be found by putting the matrix into reduced row echelon form. Starting with $$\lambda_1$$, we find: $$(\pmb A - \lambda_1 \pmb I) \pmb v_1 = \begin{bmatrix} -\left(1+\sqrt{5}\right) & -2 \\ -2 & 1-\sqrt{5} \end{bmatrix} \begin{bmatrix} v_{11} \\ v_{12} \end{bmatrix}=0$$ Putting it into RREF, we get: $$\begin{bmatrix} 1 & -\frac{1-\sqrt{5}}{2} \\ 0 & 0 \end{bmatrix}$$. We can see that this matrix is not full rank, which means we have infinitely many valid eigenvectors, and any $$\pmb v_1$$ that satisfies $$v_{11}=\frac{1-\sqrt{5}}{2} v_{12}$$ is an eigenvector. We can represent this as: $$\boxed{\pmb v_1 = \begin{bmatrix} \frac{1-\sqrt{5}}{2} \\ 1\end{bmatrix} t}$$, where $$v_{12}=t$$, and any value of $$t$$ results in a valid eigenvector. We can repeat the same process to find $$\pmb v_2$$: $$(\pmb A - \lambda_2 \pmb I) \pmb v_2 = \begin{bmatrix} -(1-\sqrt{5}) & -2 \\ -2 & 1+\sqrt{5} \end{bmatrix} \begin{bmatrix} v_{11} \\ v_{12} \end{bmatrix}=0$$ In RREF: $$\begin{bmatrix} 1 & -\frac{\left(1+\sqrt{5}\right)}{2} \\ 0 & 0 \end{bmatrix}$$ We end up with $$\boxed{\pmb v_2 = \begin{bmatrix} \frac{1+\sqrt{5}}{2} \\ 1 \end{bmatrix} t}$$.

### Subject: Calculus

Integrate the following function: $$\int x^2 e^{3x} dx$$

Whenever integrating a function, the first step is to determine what method of integration to use. The first thing to check is whether your function to integrate is contained in your Table of Integrals. This one is not, so now we know that we need to somehow transform it into a form that does appear in the table. Some common integration methods to choose from are: substitution, integration by parts, or partial fractions. If we try by substitution, we need to choose $$u$$. We can try to let $$u=x^2$$, and then we need to try and find $$du$$ and $$x$$ in terms of $$u$$. So, $$du=2x dx$$ and $$x=\sqrt{u}$$. Then we rewrite the integral in terms of $$u$$: $$\int x^2 e^{3x} dx=\int u e^{3\sqrt{u}} \frac{du}{2x}$$. We can see that like this the function is still not in a form seen in an integral table. Next we can consider another method, partial fractions. Right away we can see that this method won't work, because we aren't even dealing with a fraction in the original integral, $$\int x^2 e^{3x} dx$$. Now let's try the integration by parts method. For integration by parts, we need to break the integral down into 2 parts, $$u$$ and $$dv$$. Then we can apply the product rule, $$udv=d(uv)-vdu$$ to make the integral easier to solve. We always want to choose a $$u$$ that is easily differentiable to $$du$$ and a $$dv$$ that is easily integrable to $$v$$. So, since $$x^2$$ is easily differentiable, let's make $$u=x^2$$, and then $$du=2xdx$$. Then, $$dv=e^{3x}dx$$ and $$v=\frac{e^{3x}}{3}$$, and we can plug these in so that we have the standard integration by parts form: $$\int x^2 e^{3x} dx=\int u dv$$. Once we have this form and the values of $$du$$ and $$v$$, we can apply the integration by parts formula, derived from the product rule: $$\int udv=uv-\int vdu$$. Plugging in everything, our integral becomes: $$\int x^2 e^{3x} dx=x^2 \frac{e^{3x}}{3} - \int \frac{e^{3x}}{3} 2x dx$$. We still haven't achieved a form that is easily integrable, but that's ok because we can just apply integration by parts one more time! In this case, we can say $$u=2x$$ and $$dv=\frac{e^{3x}}{3}$$, which means $$du=2dx$$ and $$v=\frac{e^{3x}}{9} $$, and we get: $$\int \frac{e^{3x}}{3} 2x dx = 2x \frac{e^{3x}}{9} - \int \frac{e^{3x}}{9} 2dx$$. The whole original integral now looks like this: $$\int x^2 e^{3x} dx=x^2 \frac{e^{3x}}{3} - \left(2x \frac{e^{3x}}{9} - \int \frac{e^{3x}}{9} 2dx\right)$$. This looks great now, because the only integral left is in a form that would be shown in our integral table! Now we can solve the remaining integral (don't forget your added constant $$C$$) and simplify to get the final answer: $$\int \frac{e^{3x}}{3} dx = x^2 \frac{e^{3x}}{3} - 2x \frac{e^{3x}}{9} + \frac{2e^{3x}}{27} + C = \boxed{\frac{1}{27}e^{3x}\left(9x^2-6x+2\right) + C}$$.