Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Linear Algebra Operations | Getting into NumPy Basics
Getting into NumPy Basics

book
Linear Algebra Operations

NumPy offers a plethora of functions for executing linear algebra operations on arrays, including matrix multiplication, transposition, inversion, and decomposition. Key functions include:

  • dot(): Computes the dot product of two arrays;
  • transpose(): Transposes an array;
  • inv(): Computes the inverse of a matrix;
  • linalg.svd(): Performs the singular value decomposition of a matrix;
  • linalg.eig(): Determines the eigenvalues and eigenvectors of a matrix.
Taak

Swipe to start coding

  1. Compute the dot product of the arrays.
  2. Transpose the first array.
  3. Compute the inverse of the second array.

Oplossing

import numpy as np

# Create two NumPy arrays
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6], [7, 8]])

# Calculate the dot product of the arrays
dot_product = np.dot(a, b)

# Transpose the first array
a_transposed = np.transpose(a)

# Calculate the inverse of the second array
b_inverse = np.linalg.inv(b)

display(dot_product, a_transposed, b_inverse)

Mark tasks as Completed
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 5
AVAILABLE TO ULTIMATE ONLY
some-alt