Linear algebra
The matrix product, transpose, and the symmetric eigensolver. Run a cell to see its output beside the expected one.
The matrix product
@ always means matmul, never elementwise.
transpose
The symmetric eigensolver
eig_sym fills its arguments: values ascending, eigenvectors in columns. Trace = sum of eigenvalues.
Matrix-vector products via matmul
A 2×2 times a length-2 vector.
Chained products
A 3x3 eigenproblem
The eigenvalues come out in ascending order and sum to the trace, 9.
Solvers that return their results
The same solvers as the forms that fill arrays you pass, which still work: the values ascend, and lin_solve's answer gives back b.
transpose reverses the axes
Of a matrix, the rows become columns; of a rank-3 array, all three axes turn around; a vector comes back as it was, as in NumPy. transpose(A, axes) puts them in any order.
The dot product is dot, not @
@ is the matrix product and refuses two vectors; dot(u, v) sums u[i] * v[i] left to right, and outer(u, v) is the other product of two vectors. The cell prints 11 from dot, then stops at the @ line.
expected error: `@` of two vectors is refused…