Math 300 - Practice Final Exam

Suggetsed solution could be found by this link.

You have 75 minutes (the entire class duration).

You can type your answers in any text editor you like. My suggestion is that you keep it simple and use Notepad/Notepad++/TextEdit/gedit/etc. . More advanced word processor like Microsoft Word, Libre Office Writer, Apple Pages, etc. would also be fine. If you are using any other text editor, please double check with me before leaving the class if I can view your document. You can just use a pen and a paper, if you want.

Once you are done, email me your document (o.dykhovychnyi@wsu.edu).

If I receive your document after 12:00pm, it will not be accepted and you will get 0 points for the exam.

Provide answers to the following questions:

MATLAB

  1. Choose the correct statement:
    1. A variable defined in a MATLAB session can be read and modified by a MATLAB function which is being executed in the current session, but can not be read or modified by a MATLAB script which is being executed in the current session.
    2. A variable defined in a MATLAB session can neither be read, nor modified by a MATLAB script or a MATLAB function which is being executed in the current session.
    3. A variable defined in a MATLAB session can be read and modified by a MATLAB script which is being executed in the current session, but can not be read or modified by a MATLAB function which is being executed in the current session.
    4. A variable defined in a MATLAB session can be read and modified by any MATLAB function or any MATLAB script which are being executed in the current session.
  2. Provide a single MATLAB command that will create a variable named x and assigns it the value of the following expression: \( \sin \left( \frac{\pi}{18} \right) + \ln {\frac{6^3}{5}} + \sum_{i=5}^{35} i^3 \). The command should display the value of newly created variable x.
  3. Assume there is a variable A defined in current MATLAB session which represents a 5x6 matrix of integeres. Provide a single MATLAB command that will create a new matrix variable named B consisting of the first, the third and the fifth rows of the matrix A.
  4. Provide a single MATLAB command that will create a 8x5 matrix of floating point random numbers uniformly distibuted between 0 and 1 and then square (raise to the second power) every element of the newly created matrix.
  5. What is the name of the MATLAB data type that uses 32 bits to store an integer, with value ranging from 0 to 232-1.
  6. Provide a single MATLAB command that will create a row-vector, which coordinates represent the values of cosine at \(0, \frac{\pi}{100}, \frac{2\pi}{100}, \frac{3\pi}{100}, \ldots, \frac{99\pi}{100}, \pi \).
  7. Provide a MATLAB script that will do the following:
    1. Define a function variable (variable of function_handle data type) named f1 which represents the following function: \( f_1(x) = \frac{8x^3+3x^2-26x+8}{10x^3+13} \).
    2. Approximate the limit of \( f_1(x) \) at positive infinity by successively evaluating its value at points \( 1, 2, 3, \ldots \, x_i-1, x_i, x_i+1, \ldots \) until you get to some \( x_k \) such that \( |f_1(x_k) - f_1(x_k+1)| \lt 10^{-5} \). Then the approximated value of the limit at positive infinity is simply \( f_1(x_k) \).
    3. Print approximated value of the limit at positive infinity.
    4. Plot the graph of \( f_1(x) \) on the interval \( [0, x_k ] \) (where \( x_k \) is the x-value obtained at step 2 and used to approximate your limit).

Python

  1. Provide a single Python command that imports all modules and functions from NumPy package to the current session, so they can be used without specifying the name of the package or any alias.
  2. Provide a single Python command that generates the following 2x50 matrix (you can not specify values of all elements excplicitly): 1 2 3 49 50 51 52 53 99 100
  3. Provide a Python function that has a single input argument named somevalue and will do the following (be precise with indentations!):
    1. If somevalue is not an integer, raises an error using raise statement with the following message: "Provided value is not an integer!".
    2. If somevalue is strictly between 10 and 100 and divisible by 2, displays the following message: "Case 1!"
    3. If somevalue is greater or equal than 100 and not divisible by 3 displays the following message: "Case 2!"
    4. If non of the conditions mentioned in 1, 2 and 3 is true, displays the following message: "I do not know!"
  4. Provide a Python script that will do the following (be precise with indentations!):
    1. Cretae a multdimensional array representing a 10x10 square matrix of random floating point numbers uniformly distirubted between 0 and 1.
    2. Multiply created matrix by itself 25 times (your code for this step can not contain more than two lines/commands/statements).
    3. Divide every element of the matrix obtained at the previous step by its determinant.
    4. Multiply the matrix obtained at the previous step by a column-vector consisting of all integres from 1 to 10 (the vector should be created with a single command without explictily specifying all its coordinates).
    5. Compute the sum of squares of all coordinates of the vector obtained at the previous step.