https://marcinciura.wordpress.com/2025/06/20/cracovians-the-twisted-twins-of-matrices/ Skip to content Sidebar Search for: [ ] [Search] Recent Posts * Cracovians: The Twisted Twins of Matrices * Taxi * Orinoko * Visualizing Lexical Distance in Three Dimensions * PageRank in 600 words and 60 lines of Python Recent Comments Julian's avatar Julian on The Vector Space of the Polish... Quintin's avatar Quintin on Slicing Earth, Carefully Marcelo Vinicius Arte's Marcelo Vinicius Art... on Smiths, Millers, avatar Priests: Euro... Pangram - Wikipedia on More Perfect Polish Pangr... marcinciura's avatar marcinciura on Visualizing Lexical Distance i... Archives * June 2025 * April 2025 * October 2023 * August 2019 * June 2019 * December 2018 * July 2018 * June 2018 * April 2017 * March 2017 * November 2016 * June 2016 * April 2016 * March 2016 * February 2016 * January 2016 * December 2015 * November 2015 * September 2015 * July 2015 Categories * Bez kategorii * Data Science * Games * Maps * Word play Meta * Create account * Log in * Entries feed * Comments feed * WordPress.com Cracovians: The Twisted Twins of Matrices 20 June 202520 June 2025 marcinciuramathematics Linear algebra is typically explained using matrices. But matrix theory is just one possible perspective. Below, I describe an alternative approach to linear algebra. Tadeusz Banachiewicz (1882-1954), a Polish astronomer living in Krakow, was passionate about calculating machines. From the 1920s, Banachiewicz developed a method for computations on tables of numbers, which was particularly easy to perform with arithmometers. In honor of Krakow, Banachiewicz named these computational objects cracovians. In the preface to Banachiewicz's book, Cracovian Algebra (Rachunek krakowianowy, PWN 1959), it is noted that "some calculations, generally known to be very tedious, became a sheer entertainment for the executor." Similar to matrices, cracovians are represented as rectangular tables of numbers. The equality of cracovians, addition of cracovians, and multiplication of cracovians by a scalar are defined identically to their matrix counterparts. However, the multiplication of a cracovian by another cracovian is defined differently: the result in column i and row j is the sum of product of elements in column i of the left cracovian and column j of the right cracovian [thanks to andrewla from Hacker News for this definition]. In essence, each column of the left cracovian is multiplied by each column of the right cracovian. Here's an example (cracovians are enclosed in braces to distinguish them from matrices): [I got the initial version of this post by translating my Polish text into English with Gemini. Gemini hallucinated the translation of this example. Now it should be OK. Thanks to everyone who noticed it :-)] \begin{Bmatrix}3 & 2 \\ 1 & 0 \\ 1 & 1\end{Bmatrix}\begin{Bmatrix}1 & 4 \\ 2 & 3 \\ 0 & 6\end{Bmatrix} = \begin{Bmatrix} 3\times1 + 1\ times2 + 1\times0 & 2\times1 + 0\times2 + 1\times0 \\ 3\times4 + 1\ times3 + 1\times6 & 2\times4 + 0\times3 + 1\times6 \end{Bmatrix} = \ begin{Bmatrix}5 & 2 \\ 21 & 14\end{Bmatrix} All such cracovians whose elements on the main diagonal are equal to 1 and other elements are zeros are denoted by the Greek letter t (tau). Any such unit cracovian t as the second factor of multiplication does not change the cracovian by which it is multiplied. As the first factor of multiplication, a unit cracovian t transposes the cracovian by which it is multiplied: \begin{Bmatrix}1 & 0 \\ 0 & 1\end{Bmatrix}\begin{Bmatrix}2 & 5 \\ 3 & 6\end{Bmatrix} = \begin{Bmatrix}2 & 3 \\ 5 & 6\end{Bmatrix} \tau A = A^{\rm T} For any such cracovians A and B that have the same number of rows, the identity holds: \tau(AB) = BA Therefore, in the general case, cracovian multiplication is not commutative. By convention, we agree that cracovian multiplication is left-associative, i.e., ABC=(AB)C The product of cracovians has as many columns as the first factor, and as many rows as the last factor has columns. The following identities hold: \tau(A \times B \times C) = C \times \tau B \times A \tau(A \times B \times C \times D) = D \times \tau C \times \tau B \ times A and so on. All products that occur when calculating t(A[1] x...xA[n] ) have the same number of columns as A[n]. If the last factor A[n] has fewer columns than the first factor A[1] , then it is simpler to calculate t(A[1] x...xA[n]) than A[1] x...xA[n]. The following identities hold: (A \times B) \times C = A \times (C \times (\tau B)) A \times (B \times C) = (A \times (\tau C)) \times B Thus, in the general case, cracovian multiplication is not associative, meaning that cracovians with multiplication do not form a group. By decomposing a cracovian into a product of two upper triangular cracovians, we can solve systems of linear equations, for example: \begin{aligned}2x+6y+4z+2&=0\\4x+15y+26z+25&=0\\7x+21y+19z+27&=0\end {aligned} which is \begin{Bmatrix}x\\ y\\ z\\ 1\end{Bmatrix} \times \tau \begin{Bmatrix} 2&6&4&2\\4&15&26&25\\7&21&19&27\end{Bmatrix} = \begin{Bmatrix}0\\ 0\\ 0\\ 0\end{Bmatrix} In general: X \times \tau P = 0 When we decompose the cracovian P into a product of two upper triangular cracovians GH, the following cracovian equations are equivalent: X \times \tau P = 0 X \times \tau(GH) = 0 X \times (\tau G) \times H = 0 X \times \tau G = 0 \times H^{-1} X \times \tau G = 0 Since \begin{Bmatrix}2&6&4&2\\4&15&26&25\\7&21&19&27\end{Bmatrix} = \begin {Bmatrix}1&3&2&1\\0&1&6&7\\0&0&1&4\end{Bmatrix} \times \begin {Bmatrix}2&4&7\\0&3&0\\0&0&5\end{Bmatrix} we can compute z, y, and x: z+4=0; z=-4 y+6\times(-4)+7=0; y=17 x+3\times 17+2\times(-4)+1=0; x=-44 Banachiewicz rediscovered Cholesky decomposition: any positive-definite symmetric cracovian can be square-rooted, resulting in an upper triangular cracovian. He presented two algorithms for solving symmetric systems of equations. Furthermore, Banachiewicz presented a cracovian approach to the method of least squares and, among other things, the following applications of quaternions: In algebra: * Continued fraction reduction * Polynomial division * Horner's scheme * Interpolation of functions of two arguments directly from function values, without creating differences * Iterative solution of systems of linear equations * Determination of the root of an algebraic equation with the smallest absolute value * Determination of the greatest common divisor of numbers in a sequence whose terms are given by a polynomial with integer coefficients In astronomy: * Determination of the cosines of six angles between the orbital axis directions and coordinate axes from orbital elements or from two heliocentric positions * Determination of topocentric lunar coordinates * Differential corrections for planetary and cometary orbits * Conformal mapping of a spheroid onto a plane * Determination of precessional coefficients In geodesy: * Forward intersection * Resection * Hansen's problem In spherical trigonometry: * Composition and decomposition of rotations * Relationships between elements of a spherical polygon * Gauss's formulas for spherical trigonometry * Solution of spherical hexagons, pentagons, and quadrilaterals * Quaternion composition and decomposition of rotations In Banachiewicz's book, one can find charming advice, such as this: "In practice, when multiplying cracovians, we use movable objects (pen nibs, pencils, matches, etc.) to help the eye in selecting elements from the i-th and j-th columns of the multiplied cracovians. We place these objects on paper at the head (or side) of the appropriate column." In 2025, people no longer multiply large matrices by hand. It turns out that multiplying cracovians by computers is not faster than multiplying matrices. NumPy matrices have two special fields: * shape: Defines the number of elements in each dimension. * strides: Determine how many bytes you need to jump in memory to get to the next element in a given dimension. When NumPy transposes a matrix, it doesn't create a new matrix with copied data. Instead, NumPy creates a "view" on the same data in memory. This view preserves the contents of the old matrix and swaps the two elements of its shape field and the two elements of its strides field. Using the timeit.repeat function, we observe that the time for matrix multiplication AB is similar to the time for matrix multiplication B^ TA, which is equivalent to the cracovian multiplication AB. !/usr/bin/env python3 import timeit import numpy as np N = 4096 def SetUp(): global A, B, BT A = np.random.rand(N, N).astype(np.float32) B = np.random.rand(N, N).astype(np.float32) BT = np.transpose(B) print(timeit.repeat(lambda: np.matmul(A, B), setup=SetUp, number=1)) print(timeit.repeat(lambda: np.matmul(BT, A), setup=SetUp, number=1)) print(A.shape, A.strides, B.shape, B.strides, BT.shape, BT.strides) Here is the output of the program: [0.35147937503643334, 0.36795954196713865, 0.3467264170758426, 0.32935020816512406, 0.3452573330141604] [0.3460142908152193, 0.3827329999767244, 0.3319119580555707, 0.3326827920973301, 0.32132083317264915] (4096, 4096) (16384, 4) (4096, 4096) (16384, 4) (4096, 4096) (4, 16384) Podziel sie: * Click to share on X (Opens in new window) X * Click to share on Facebook (Opens in new window) Facebook * Like Loading... Related Cracovians: The Twisted Twins of Matrices Post navigation - Taxi Leave a comment Cancel reply [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] This site uses Akismet to reduce spam. Learn how your comment data is processed. Blog at WordPress.com. * Comment * Reblog * Subscribe Subscribed + [wpcom-] marcinciura.wordpress.com [ ] Sign me up + Already have a WordPress.com account? Log in now. * + [wpcom-] marcinciura.wordpress.com + Subscribe Subscribed + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar %d [b] Design a site like this with WordPress.com Get started