COMS3251 Homework 1-ML-Gauss-Jordan-main Solved

30.00 $ 15.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment

Description

Rate this product

 

1       Numerical Problems

  1. Compute each of the following, show all steps and indicate what rule you are using to get full credit.
  1. Convert the following systems of equations into augmented matrix form if possible, otherwise state why it cannot be done:
• 2y + z +2 = 4x, 4y − 2w = 1+ x +6y,                       4w z + x +7y − 4 = 0
x2+3 = 4x1+6, 5x2 = −10,                     x2+3x1 = x2,−3x2 = 9
x +3z y = 3x, x2+ y − 3z = 4
  • 1 = −x1+ x2 + ex2, x1 − 2x3 = x2+5

2       Applications

  1. [Operations Research] A mining company has two mines. One day’s operation at mine A produces ore that contains 10 metric tons of copper and 120 kilograms of silver, while one day’s operation at mine B produces ore containing 6 metric tons of copper and 140 kilograms

of silver. Let and. Then a and b represent the daily output of mines A

and B, respectively.

  • What is the physical interpretation of the vector 4a?
  • Suppose that the mining company operates mine A for x1 days and mine B for x2 Write a vector equation whose solution gives the number of days each mine should operate in order to produce 72 tons of copper and 1340 kilograms of silver.
  • Solve the system from part (b).
  1. [Material Science] Suppose that the temperature around the perimeter of the thin plate shown below is held fixed at the temperature values specified by the diagram (units are degrees Celsius). Suppose that the temperature at each interior node is equal to the average of the temperature at the four neighboring nodes.
    • Write a system of equations satisfied by the four temperatures A, B, C, and D.
    • Solve the system of equations from (a).

3       Theory

  1. As we saw in class, matrices can be used to manipulate vectors (recall that a permutation matrix can reorder the rows of a vector). Here we’ll derive a matrix that can rotate vectors in space. Consider a vector v ∈ R2 of length r that subtends an angle of α from the xaxis. Suppose we want to rotate the vector counter-clockwise by an angle of θ. We’ll derive which matrix can achieve this. Here is a depiction of the quantities we are considering in this problem.
  • Compute the coordinates of in terms of α and r, and the coordinates of

in terms of α, θ and r.

(hint: use trigonometry)

  • Write down the coordinates of purely in terms of coordinates of v and θ.

(hint: use more trig identities).

Simplify it as much as possible and write the relationship between v0 and v as a matrixvector equation v0 = Av (if done correctly, A would only depend on θ).

Note that A is the desired matrix that can rotate a vector!

4       Programming

  1. For this problem, follow the function definitions given in solver.ipnyb. No libraries are permitted for this problem with the exception of NumPy in the final function given in solver.ipynb. Do not modify any of the function signatures.

There are multiple methods to solve a system of linear equations. In this problem we will write a program to solve linear systems of equations that have unique solutions. We will use three closely related methods to produce three solvers. Each solver will take in the matrix A and the vector b, corresponding to a system of linear equations Ax = b where the solution, x, is unique. We will create several helper functions including an implementation of the GaussJordan algorithm, guassjordan, and our own matrix inverter, myinverse.

  • gaussjordansolve will run Gauss Jordan elimination on the augmented matrix, (often notated as A|b) and take the solution x, directly from the ouput of guassjordan with input A|b
  • inversesolve will use myinverse to find the inverse of A (generally notated as A−1) and use a helper function matmul to compute x = A−1b.
  • numpysolve will use NumPy, a nifty numerical computing library, to solve the linear system of equations. This will be the only function for which you can use a third-party library and you are restricted to NumPy, but you can make use of NumPy in any way you wish for this problem. For example, you could use numpy.linalg.inv to compute the inverse with the library and hence numpysolve could have an implementation similar to that of inversesolve, albeit with a library calculated inverse. However, there may be an easier way. In practice, we want to make maximal use of third-party libraries as we can be more confident in their efficiency and correctness than our own ad hoc solutions. Explore the NumPy reference, https://numpy.org/doc/stable/reference/, to decide on an approach for this problem that offloads the maximal amount of computation and logic onto the library.
  1. For this problem, follow the function definitions given in clock.ipnyb. The only library permitted for this problem is NumPy. You may also use the python math library. Do not modify any of the function signatures.

At noon, the minute and the hour hands of an analog clock coincide. Here we will compute numerically at what time the two hands are first perpendicular to each other[1].

To make the problem more concrete, let denote the hour hand of the (analog) clock at noon. and be the minute hand at noon.

  • Write a program that given the minute value (between 0 and 60 continuous), returns the (hx,hy) location of the hour hand on the clock at the given minute during the first hour after noon. You should fill out the function locationatminute on clock.ipynb.
  • Write a program that given the minute value (between 0 and 60 continuous), returns the angle between the minute and the hour hand of the clock at the given minute during the first hour after noon. Plot this in a figure with the minute value on the x-axis and the angle subtended on the y-axis. You should fill out the function angleatminute on clock.ipynb.
  • Programmatically approximate the time (up to the nearest second) when the angle between the hour hand and minute hand are perpendicular for the first time after noon. What time do you get? You should fill out the function timewhenfirstperpendicular on clock.ipynb.

To receive credit, submit a zip file containing two files as described here. They must be named clock.py and solver.py for the clock problem and the linear program solver respectively. Additionally, they must follow the function definitions given in the skeleton code files, clock.ipnyb and solver.ipnyb. Your zip file should also contain a README.txt if you consult any third-party sources (the NumPy reference need not be included).

[1] Naively one may think that this should be at 12:15, but note that the hour hand also moves forward a little bit so the angle subtended at 12:15 is in fact less than 90 degrees!