Skip to main content

Questions tagged [linear-algebra]

For challenges involving linear algebra, the mathematics of vector spaces and linear mappings between them.

Filter by
Sorted by
Tagged with
18 votes
7 answers
2k views

The cross product is a peculiarly 3-dimensional phenomenon. There are multiple ways of generalizing it, but each of them have trade offs. If you require that a cross product be a product of two ...
Wheat Wizard's user avatar
  • 103k
14 votes
19 answers
3k views

Output (or print) each of the 11 times, one per line, in the POSIX %I:%M:%S format, at which the hour and minute hands of a 12-hour clock are antiparallel. Here <...
Ray Toal's user avatar
  • 811
12 votes
7 answers
2k views

Introduction Tensor contraction is an operation that can be performed on a tensor. It is a generalization of the idea of the trace of a matrix. For example, if we have a rank-2 tensor (a matrix) and ...
Tbw's user avatar
  • 3,023
26 votes
41 answers
2k views

Diagonalize a vector into a matrix. Input A vector, list, array, etc. of integers \$\mathbf{v}\$ of length \$n\$. Output A \$n \times n\$ matrix, 2D array, etc. \$A\$ such that for each element \$a_i \...
bigyihsuan's user avatar
  • 11.4k
15 votes
13 answers
1k views

A Hankel matrix is a square matrix in which each ascending skew-diagonal from left to right is constant, e.g.: $$\begin{bmatrix} a & b & c & d \\ b & c & d & e \\ c & d &...
alephalpha's user avatar
  • 51.9k
7 votes
2 answers
525 views

Given a list of N lists, each containing M positive integers, and a separate list of M positive integers (target values), return a list of N scalars (integers with a value of 0 or more) that ...
drmosley's user avatar
  • 757
15 votes
7 answers
824 views

A basis of a vector space \$V\$ is a set of vectors \$B\$ such that every vector \$\vec v \in V\$ can be uniquely written as a linear combination of the vectors in \$B\$. In other words, let \$B = \{\...
caird coinheringaahing's user avatar
16 votes
4 answers
801 views

Executive summary: Print NxN matrices \$A\$ and \$B\$ where \$ AB = 10A + B \$. Largest N wins! Details: Entrants in this challenge should choose an N. Submit a program that takes an input integer '...
QuadmasterXLII's user avatar
17 votes
10 answers
1k views

Background The special linear group \$ SL_2(\mathbb{Z}) \$ is a multiplicative group of \$ 2 \times 2 \$ matrices whose elements are integers and determinant is 1. It is known that every member of \$...
Bubbler's user avatar
  • 79.3k
6 votes
6 answers
652 views

One of the Klarner-Rado sequences is defined as follows: the first term is \$1\$ for all subsequent terms, the following rule applies: if \$x\$ is present, so are \$2x+1\$ and \$3x+1\$ the sequence ...
maryrio7's user avatar
  • 173
29 votes
8 answers
6k views

Given the 2-dimensional positions and velocities of a pair of billiard balls right before impact, calculate their velocities after a perfectly elastic collision. The balls are assumed to be ideal ...
ngn's user avatar
  • 15.6k
24 votes
18 answers
5k views

Challenge Given nine numbers, a, b, c, d, e, f, g, h, i, as input which correspond to the square matrix: $$\mathbf{M} = \begin{pmatrix}a& b& c\\ d& e&...
Beta Decay's user avatar
  • 23.6k
13 votes
9 answers
3k views

The challenge is to write the fastest code possible for computing the Hafnian of a matrix. The Hafnian of a symmetric 2n-by-2n ...
user avatar
31 votes
10 answers
1k views

I was at a friend's house for dinner and they suggested the idea of a "Prime-factor vector space". In this space the positive integers are expressed as a vector such that the nth element in the ...
Wheat Wizard's user avatar
  • 103k
14 votes
13 answers
3k views

The characteristic polynomial of a square matrix \$A\$ is defined as the polynomial \$p_A(x) = \det(Ix-A)\$ where \$I\$ is the identity matrix and \$\det\$ the determinant. Note that this definition ...
ბიმო's user avatar
12 votes
5 answers
852 views

Mathematical Background Let A be an N by N matrix of real numbers, b a vector of N real numbers and x a vector N unknown real numbers. A matrix equation is Ax = b. Jacobi's method is as follows: ...
user1997744's user avatar
22 votes
14 answers
2k views

Given a matrix of integers, test if it's rank-one, meaning that every row is a multiple of the same vector. For example, in ...
xnor's user avatar
  • 150k
27 votes
10 answers
4k views

There are lots of different ways to explain matrix multiplication. I'll stick with a single figure since I believe most people here are familiar with it (and the figure is very descriptive). If you ...
Stewie Griffin's user avatar
15 votes
3 answers
518 views

(inspired by this question over on Math) The Definitions Given an n x n square matrix A, we can call it invertible if there ...
AdmBorkBork's user avatar
  • 43.7k
10 votes
14 answers
832 views

This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix. The diagonals in specific are ...
Maltysen's user avatar
  • 25.8k
20 votes
5 answers
1k views

Important note: Because this challenge only applies to square matrices, any time I use the term matrix, it is assumed that I am referring to a square matrix. I am leaving off the “square” description ...
user avatar
13 votes
11 answers
2k views

Related, but very different. In the examples below, \$A\$ and \$B\$ will be \$2\times2\$ matrices, and the matrices are one-indexed. A Kronecker product has the following properties: ...
Stewie Griffin's user avatar
9 votes
6 answers
1k views

In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed. A Kronecker product has the ...
Stewie Griffin's user avatar
13 votes
6 answers
2k views

This challenge but with a better spec. Spec Your program will take a linear equation containing a single variable x and output the value of ...
Downgoat's user avatar
  • 29.2k
18 votes
12 answers
1k views

The determinant of a 2 by 2 matrix a b c d is given by ad - bc. Given a matrix of digits with dimensions 2n by 2n, n ≥ 1, ...
Sp3000's user avatar
  • 62.2k