Module 1 Programming Assignment¶
=================================================================================================================
**Problem 1 ** Plot the curve of function¶
$\(f(x) = x^3 - x,~~ x \in[-1,1].\)$¶
# write your code for solving probelm 1 in this cell
=================================================================================================================
**Problem 2 **¶
(1) Find the two roots of the function¶
(2) Plot the curve of the function \(f(x)\) defined in (1) and mark all the roots on the curve.¶
=================================================================================================================
**Problem 3 **. Given \(P=\begin{bmatrix} 1 & 2 \\ 3 & 4\end{bmatrix}\), investigate the two different multiplications \(P*P\) and \(torch.mm(P,P)\).¶
=================================================================================================================
**Problem 4 ** Given¶
$\(A=\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}, ~~ b=\begin{bmatrix} 1 \\ 2 \\ 3\end{bmatrix}.\)$¶
Solve \(A^2 x = b.\)¶
=================================================================================================================
**Problem 5 ** Given \(f(x,y) = x^2+y^2+(xy)^3\), compute \(\frac{\partial f(x,y)}{\partial y}\) at \(x=1,y=2\).¶
=================================================================================================================
**Problem 6 ** Define a function to find the minimum of three numbers \(a,~b,~c\). Test your code and print the minimum of the three numbers, where \(a=\sqrt{2},~ b=\frac{4}{3},~ c=0.5e\).¶
=================================================================================================================
**Problem 7 ** Define a function to find the maximum and minimum of a sequence with n numbers.¶
Hint: x = np.random.randint(a,b,size=n) can randomly generate n numbers (saved in a row vector x ) and each number is between a and b.
=================================================================================================================
**Problem 8 ** Define a function to sort a sequence with n numbers in ascending order.¶
=================================================================================================================