0
0
SciPydata~20 mins

Why linear algebra is the foundation of scientific computing in SciPy - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Linear Algebra Mastery in Scientific Computing
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Matrix multiplication output
What is the output of the following code that multiplies two matrices using SciPy?
SciPy
import numpy as np
from scipy.linalg import blas

A = np.array([[1, 2], [3, 4]])
B = np.array([[5, 6], [7, 8]])

result = blas.dgemm(alpha=1.0, a=A, b=B)
print(result)
A
[[5. 12.]
 [21. 32.]]
B
[[12. 14.]
 [30. 34.]]
C
[[17. 20.]
 [39. 46.]]
D
[[19. 22.]
 [43. 50.]]
Attempts:
2 left
💡 Hint
Recall how matrix multiplication sums products of rows and columns.
data_output
intermediate
1:30remaining
Shape of matrix after transpose and multiplication
Given a matrix A of shape (3, 4), what is the shape of the matrix resulting from A.T @ A?
SciPy
import numpy as np
A = np.random.rand(3, 4)
result = A.T @ A
print(result.shape)
A(4, 4)
B(3, 3)
C(3, 4)
D(4, 3)
Attempts:
2 left
💡 Hint
Transpose flips rows and columns. Matrix multiplication shape depends on inner dimensions.
visualization
advanced
3:00remaining
Visualizing eigenvectors of a matrix
Which option correctly plots the eigenvectors of matrix M as arrows starting from the origin?
SciPy
import numpy as np
import matplotlib.pyplot as plt

M = np.array([[2, 1], [1, 2]])
eigenvalues, eigenvectors = np.linalg.eig(M)

plt.figure()
plt.axhline(0, color='grey')
plt.axvline(0, color='grey')
for vec in eigenvectors.T:
    plt.arrow(0, 0, vec[0], vec[1], head_width=0.05, head_length=0.1, fc='blue', ec='blue')
plt.xlim(-1, 1)
plt.ylim(-1, 1)
plt.title('Eigenvectors of M')
plt.show()
APlots eigenvalues as points on x-axis
BPlots two arrows from origin pointing along eigenvectors of M
CPlots matrix M as heatmap
DPlots random vectors unrelated to M
Attempts:
2 left
💡 Hint
Eigenvectors show directions that stretch or shrink under M.
🧠 Conceptual
advanced
1:30remaining
Why is linear algebra essential in scientific computing?
Which statement best explains why linear algebra is the foundation of scientific computing?
AIt provides tools to represent and solve systems of linear equations common in simulations and data analysis.
BIt focuses only on scalar arithmetic which is rarely used in computing.
CIt is mainly about calculus and derivatives, unrelated to matrices.
DIt deals with string manipulation and text processing.
Attempts:
2 left
💡 Hint
Think about how many problems can be expressed as linear systems.
🔧 Debug
expert
2:00remaining
Identify the error in matrix inversion code
What error does the following code raise when trying to invert matrix A?
SciPy
import numpy as np
A = np.array([[1, 2], [2, 4]])
inv_A = np.linalg.inv(A)
print(inv_A)
AValueError: shapes not aligned
BTypeError: unsupported operand type(s)
CLinAlgError: Singular matrix
DNo error, prints inverse matrix
Attempts:
2 left
💡 Hint
Check if matrix A is invertible by its determinant.