Create the following matrices using the given constraints. 4 Points each.
np.random.normal centered at 10 with standard deviation of 5, replace all negative values with 0 and then modify it so its rows sum to 1 and 0, use np.round to round to one decimal place.Solve the following systems of equations. 4 Points each. Write out your answer in Markdown
Calculate the eigenvalues and eigenvectors for the following matrices. Solve in Python and then write out the eigenvalues/eigenvectors in LaTeX. When writing decimals, only report two significant figures.
eigh over eig?Using numpy, create a sum or difference of array slices that yields the requested quantity. Consider the following example:
To create this sequence: $$x_0 , x_2, x_4, \ldots $$
Use this slice
x[::2]
Use this particular array for this: x = np.arange(15), but use len(x) when you need to refer to the length of the array. 2 Points each.
Given the following problems, what is the correct method to use? Do not solve the problems, just state the best method. 1 Point each
[4 Points] Compute $\int_{-\infty}^{\infty} x^2 e^{-x^2}\,dx$. Use np.inf to refer to infinity and use a lambda function. Make sure it's clear what is the value of the integral in your print.
[4 Points] Compute the numerical derivative of the following data:
x = [0, 1, 2, 3, 4, 6, 7, 9]
fx = [0.0, 0.84, 0.91, 0.14, -0.76, -0.28, 0.66, 0.41]
[2 Points] Compute the numerical derivative of the following data:
x2 = [0.0, 0.42, 0.83, 1.25, 1.67, 2.08, 2.5, 2.92, 3.33, 3.75, 4.17, 4.58, 5.0, 5.42, 5.83, 6.25, 6.67, 7.08, 7.5, 7.92, 8.33, 8.75, 9.17, 9.58, 10.0]
fx2 = [0.0, 0.4, 0.74, 0.95, 1.0, 0.87, 0.6, 0.22, -0.19, -0.57, -0.85, -0.99, -0.96, -0.76, -0.43, -0.03, 0.37, 0.72, 0.94, 1.0, 0.89, 0.62, 0.26, -0.16, -0.54]
[6 Points] Plot your data from 6.2 and 6.3 against $\cos(x)$, which is the correct derivative. Does the numerical derivative work even with the non-uniform coarse data in part 2?
[6 Points] Integrate the data from 6.2 and compare against the true integral $\int_0^{9} \sin(x)\,dx$. How accurate is it?