Starting from:

$29.99

CSE5004 Homework 1-NumPy and Matplotlib Solution


1. (Matrix Arithmetic)
Let consider a matrix A and a vector b,
.
(1) Generate arrays for A matrix and b vector using NumPy library.
(2) Transpose A and apply matrix multiplication with the original matrix (ATA).
(3) Calculate x as the solution of ATAx = ATb.
(4) Calculate the norm of Ax − b with line-by-line coding and using NumPy library.
2. (Drawing Graphs)
A two-dimensional Ackley function, f(x,y), has many local minima and one global minimum in the domain, (x,y) ∈ [−4,4] × [−4,4].
f(x,y) = −aexp(−bp0.5(x2 + y2)) − exp(0.5(cos(cx) + cos(cy))) + a + exp(1) where a = 20, b = 0.2, and c = 2π.
(1) Plot a 2D contour of the Ackley function on (x,y) ∈ [−4,4] × [−4,4].
(2) Plot a 3D graph of the Ackley function on (x,y) ∈ [−4,4] × [−4,4].
(3) Find the global minimum and its position.
(4) Plot a graph for f(y|x = −2), f(y|x = 0), and f(y|x = 2) in one plot with legends.
(5) Plot the x-direction averaged one-dimensional graph and the y-direction averaged one-dimensional graph on the same canvas.

More products