written by Antonius - roboticist, hardware hacker & low level hacker based in Indonesia
robohax.com - technological innovation for humanity
original article : July 5 2018
revised edition : Dec 2 2026
https://medium.com/@ringlayer/regular-inverse-pseudo-inverse-matrix-calculation-using-singular-value-decomposition-914cedb28e20
There are several mathematical methods for solving inverse kinematics problems in robotic manipulators. One of my favourite approaches involves calculating the pseudoinverse of a Jacobian matrix using Singular Value Decomposition (SVD).
Before exploring its application in robotics, it is important to understand the difference between a regular matrix inverse and a pseudoinverse, as well as how both can be calculated.
Matrix inversion is an operation that produces a matrix which, when multiplied by the original matrix, yields the identity matrix.
In ordinary arithmetic, the reciprocal of a non-zero number b is written as b-1 = 1/b. Similarly, the inverse of a matrix A is denoted by A-1.
For an invertible matrix A:
AA-1 = A-1A = I
where I represents the identity matrix.
A matrix must satisfy two conditions to have a regular inverse:
A square matrix with a determinant of zero is called a singular matrix and does not have a regular inverse.
The Moore-Penrose pseudoinverse is a generalisation of the ordinary matrix inverse. The pseudoinverse of a matrix A is commonly denoted by A+ or A†.
Unlike the regular inverse, the Moore-Penrose pseudoinverse exists and is unique for every real or complex matrix, including:
For an invertible square matrix, the pseudoinverse is identical to its regular inverse:
A+ = A-1
However, when a regular inverse does not exist, the pseudoinverse provides a mathematically useful alternative for solving linear systems.
Suppose we have the following 3 × 3 matrix B:
[ 1 2 1 ]
B = [ 3 3 1 ]
[ 2 1 1 ]
We can calculate its inverse using the adjugate method:
B-1 = adj(B) / det(B)
The calculation consists of four main steps:
Using Laplace expansion along the first row:
det(B) = 1(3 × 1 - 1 × 1) - 2(3 × 1 - 1 × 2) + 1(3 × 1 - 3 × 2)
det(B) = 1(2) - 2(1) + 1(-3)
det(B) = 2 - 2 - 3
det(B) = -3
Since the determinant is non-zero, matrix B is invertible.
The minor Mij of an element is the determinant of the submatrix obtained by removing row i and column j from the original matrix.
For example, to calculate M11, we remove the first row and the first column:
[ 3 1 ] M11 = det [ 1 1 ]
M11 = (3 × 1) - (1 × 1) = 2
Applying the same procedure to every element:
M11 = (3 × 1) - (1 × 1) = 2 M12 = (3 × 1) - (1 × 2) = 1 M13 = (3 × 1) - (3 × 2) = -3 M21 = (2 × 1) - (1 × 1) = 1 M22 = (1 × 1) - (1 × 2) = -1 M23 = (1 × 1) - (2 × 2) = -3 M31 = (2 × 1) - (1 × 3) = -1 M32 = (1 × 1) - (1 × 3) = -2 M33 = (1 × 3) - (2 × 3) = -3
Therefore, the matrix of minors is:
[ 2 1 -3 ]
M = [ 1 -1 -3 ]
[ -1 -2 -3 ]
The cofactor of each element can be calculated using:
Cij = (-1)i+jMij
The corresponding sign pattern for a 3 × 3 matrix is:
[ + - + ] [ - + - ] [ + - + ]
Applying this sign pattern to the matrix of minors gives the cofactor matrix:
[ 2 -1 -3 ]
C = [ -1 -1 3 ]
[ -1 2 -3 ]
The adjugate matrix is obtained by transposing the cofactor matrix.
adj(B) = CT
[ 2 -1 -1 ]
adj(B) = [ -1 -1 2 ]
[ -3 3 -3 ]
The term classical adjoint is also sometimes used for the adjugate. However, adjugate is the more precise term in this context.
Using the inverse formula:
B-1 = adj(B) / det(B)
[ 2 -1 -1 ]
B^-1 = (-1/3) × [ -1 -1 2 ]
[ -3 3 -3 ]
Multiplying each element by -1/3 gives:
[ -2/3 1/3 1/3 ]
B^-1 = [ 1/3 1/3 -2/3 ]
[ 1 -1 1 ]
Multiplying the original matrix by its inverse must produce the identity matrix:
[ 1 0 0 ]
B × B^-1 = I3 = [ 0 1 0 ]
[ 0 0 1 ]
The result confirms that the inverse calculation is correct.
Singular Value Decomposition is a matrix factorisation technique that decomposes a matrix into three separate matrices.
For any real m × n matrix A, its full SVD is expressed as:
A = UΣVT
where:
Both U and V satisfy the orthogonality conditions:
UTU = Im
VTV = In
Unlike standard eigenvalue decomposition, SVD can be applied directly to rectangular matrices.
The singular values of A can be obtained from the square roots of the non-negative eigenvalues of AAT or ATA. These two matrices have the same non-zero eigenvalues, including their multiplicities.
Given the singular value decomposition:
A = UΣVT
The Moore-Penrose pseudoinverse is calculated using:
A+ = VΣ+UT
The matrix Σ+ is constructed by taking the reciprocal of each non-zero singular value, leaving zero singular values unchanged, and transposing the dimensions of the original rectangular diagonal matrix.
In other words, if Σ has dimensions m × n, then Σ+ has dimensions n × m.
Note that Σ+ is not necessarily an ordinary matrix inverse.
Consider the following rectangular matrix:
[ 1 2 -1 ] A = [ 2 1 -1 ]
Matrix A has two rows and three columns. Therefore, it does not have a regular inverse.
We will calculate its Moore-Penrose pseudoinverse manually using SVD.
First, calculate the transpose of A:
[ 1 2 ]
A^T = [ 2 1 ]
[ -1 -1 ]
To find the left singular vectors, calculate AAT:
[ 1 2 -1 ] [ 1 2 ]
AA^T = [ 2 1 -1 ] × [ 2 1 ]
[ -1 -1 ]
The result is:
[ 6 5 ] AA^T = [ 5 6 ]
To find the right singular vectors, we can also calculate ATA:
[ 5 4 -3 ]
A^T A = [ 4 5 -3 ]
[ -3 -3 2 ]
The eigenvectors of AAT correspond to the left singular vectors, while the eigenvectors of ATA correspond to the right singular vectors.
The characteristic equation is:
det(AAT - λI) = 0
where λ represents an eigenvalue and I represents the identity matrix.
[ 6 - λ 5 ] det [ 5 6 - λ ] = 0
(6 - λ)2 - 25 = 0
λ2 - 12λ + 11 = 0
(λ - 11)(λ - 1) = 0
Therefore, the eigenvalues are:
λ1 = 11
λ2 = 1
For each eigenvalue, solve the following equation:
(AAT - λI)u = 0
[ -5 5 ] [ x1 ] [ 0 ] [ 5 -5 ] [ x2 ] = [ 0 ]
-5x1 + 5x2 = 0
x1 = x2
One valid eigenvector is:
[ -1 ] u1 = [ -1 ]
Its Euclidean norm is:
||u1|| = √((-1)2 + (-1)2) = √2
After normalisation:
1 [ -1 ]
u1 = ----- × [ -1 ]
sqrt(2)
[ 5 5 ] [ x1 ] [ 0 ] [ 5 5 ] [ x2 ] = [ 0 ]
5x1 + 5x2 = 0
x1 + x2 = 0
Therefore:
x1 = -x2
One valid eigenvector is:
[ -1 ] u2 = [ 1 ]
After normalisation:
1 [ -1 ]
u2 = ----- × [ 1 ]
sqrt(2)
Combining both normalised eigenvectors as columns gives matrix U:
1 [ -1 -1 ]
U = ----- × [ -1 1 ]
sqrt(2)
Numerically:
[ -0.707107 -0.707107 ] U = [ -0.707107 0.707107 ]
The singular values are obtained by taking the square roots of the non-negative eigenvalues.
σ1 = √λ1 = √11
σ2 = √λ2 = 1
Since A is a 2 × 3 matrix, Σ must also be a 2 × 3 matrix:
[ sqrt(11) 0 0 ] Sigma = [ 0 1 0 ]
Numerically:
[ 3.316625 0 0 ] Sigma = [ 0 1 0 ]
The two non-zero singular values indicate that A has rank 2.
For every non-zero singular value, a corresponding right singular vector can be calculated from its left singular vector using:
vi = ATui / σi
This approach ensures that the signs of the left and right singular vectors are consistent.
v1 = ATu1 / √11
1 [ -3 ]
v1 = ------ × [ -3 ]
sqrt(22) [ 2 ]
Numerically:
[ -0.639602 ]
v1 = [ -0.639602 ]
[ 0.426401 ]
v2 = ATu2 / 1
1 [ 1 ]
v2 = ----- × [ -1 ]
sqrt(2) [ 0 ]
Numerically:
[ 0.707107 ]
v2 = [ -0.707107 ]
[ 0.000000 ]
Since we are calculating the full SVD of a 2 × 3 matrix, matrix V must contain three orthonormal columns.
The third right singular vector belongs to the null space of A and satisfies:
Av3 = 0
[ 1 2 -1 ] [ x1 ] [ 0 ]
[ 2 1 -1 ] [ x2 ] = [ 0 ]
[ x3 ]
This gives two equations:
x1 + 2x2 - x3 = 0
2x1 + x2 - x3 = 0
Subtracting the equations gives:
x1 = x2
Substituting this result into either equation gives:
x3 = 3x1
One valid null-space vector is:
[ 1 ] [ 1 ] [ 3 ]
Its Euclidean norm is √11. After normalisation:
1 [ 1 ]
v3 = ------ × [ 1 ]
sqrt(11) [ 3 ]
Combining the three orthonormal right singular vectors gives V:
[ -0.639602 0.707107 0.301511 ]
V = [ -0.639602 -0.707107 0.301511 ]
[ 0.426401 0.000000 0.904534 ]
Transposing V gives:
[ -0.639602 -0.639602 0.426401 ]
V^T = [ 0.707107 -0.707107 0.000000 ]
[ 0.301511 0.301511 0.904534 ]
The matrices U, Σ, and V now form a valid full singular value decomposition.
Our original singular value matrix is:
[ sqrt(11) 0 0 ] Sigma = [ 0 1 0 ]
Since this matrix is rectangular, it does not have a regular inverse.
Instead, we calculate its pseudoinverse by replacing each non-zero singular value with its reciprocal and reversing the matrix dimensions.
[ 1/sqrt(11) 0 ]
Sigma+ = [ 0 1 ]
[ 0 0 ]
Numerically:
[ 0.301511 0 ]
Sigma+ = [ 0 1 ]
[ 0 0 ]
We now have all the matrices required to calculate the Moore-Penrose pseudoinverse.
A+ = VΣ+UT
The matrix dimensions are:
V : 3 × 3 Sigma+ : 3 × 2 U^T : 2 × 2 A+ : 3 × 2
Multiplying the matrices using the exact singular values and singular vectors gives:
[ -4/11 7/11 ]
A+ = [ 7/11 -4/11 ]
[ -1/11 -1/11 ]
Numerically:
[ -0.363636 0.636364 ]
A+ = [ 0.636364 -0.363636 ]
[ -0.090909 -0.090909 ]
This is the Moore-Penrose pseudoinverse of our original matrix A.
The Moore-Penrose pseudoinverse satisfies four mathematical conditions, known as the Penrose equations:
Because A has full row rank, multiplying A by its pseudoinverse produces the 2 × 2 identity matrix:
[ 1 0 ] A × A+ = I = [ 0 1 ]
However, multiplying the matrices in the opposite order gives:
1 [ 10 -1 -3 ]
A+ × A = -- × [ -1 10 -3 ]
11 [ -3 -3 2 ]
This is not the 3 × 3 identity matrix. Instead, it is an orthogonal projection matrix onto the row space of A.
This illustrates an important difference between a regular inverse and a pseudoinverse.
Although SVD can be calculated manually, numerical libraries such as NumPy provide efficient implementations for practical applications.
The following Python script calculates the full SVD of the same matrix used in our manual example and constructs its pseudoinverse explicitly.
#!/usr/bin/env python3
import numpy as np
A = np.array([
[1, 2, -1],
[2, 1, -1]
], dtype=float)
np.set_printoptions(
precision=6,
suppress=True
)
# Calculate the full SVD
U, s, VT = np.linalg.svd(
A,
full_matrices=True
)
m, n = A.shape
# Construct Sigma
Sigma = np.zeros((m, n))
for i, sigma in enumerate(s):
Sigma[i, i] = sigma
tol = max(m, n) * np.finfo(float).eps * s[0]
Sigma_plus = np.zeros((n, m))
for i, sigma in enumerate(s):
if sigma > tol:
Sigma_plus[i, i] = 1.0 / sigma
# Calculate the pseudoinverse
A_plus = VT.T @ Sigma_plus @ U.T
print("Original matrix A:")
print(A)
print("\nU:")
print(U)
print("\nSingular values:")
print(s)
print("\nSigma:")
print(Sigma)
print("\nV transpose:")
print(VT)
print("\nSigma pseudoinverse:")
print(Sigma_plus)
print("\nPseudoinverse of A:")
print(A_plus)
# Verify the SVD reconstruction
print("\nSVD reconstruction:")
print(U @ Sigma @ VT)
# Verify the four Penrose conditions
print("\nPenrose conditions:")
print(np.allclose(
A @ A_plus @ A, A
))
print(np.allclose(
A_plus @ A @ A_plus, A_plus
))
print(np.allclose(
(A @ A_plus).T, A @ A_plus
))
print(np.allclose(
(A_plus @ A).T, A_plus @ A
))
The expected singular values are:
[3.316625 1.000000]
The expected pseudoinverse is:
[[-0.363636 0.636364] [ 0.636364 -0.363636] [-0.090909 -0.090909]]
All four Penrose conditions should return True.
Depending on the numerical implementation, NumPy may return singular vectors with different signs from those obtained manually. This is normal, provided that the corresponding singular vectors remain consistent and the reconstructed matrix and pseudoinverse are correct.
NumPy also provides the pinv() function, which calculates the Moore-Penrose pseudoinverse directly using SVD.
#!/usr/bin/env python3
import numpy as np
A = np.array([
[1, 2, -1],
[2, 1, -1]
], dtype=float)
np.set_printoptions(
precision=6,
suppress=True
)
A_plus = np.linalg.pinv(A)
print("Pseudoinverse of A:")
print(A_plus)
Output:
[[-0.363636 0.636364] [ 0.636364 -0.363636] [-0.090909 -0.090909]]
The result agrees with our manual calculation.
For certain matrices with full rank, the pseudoinverse can also be calculated without explicitly performing SVD.
If A has linearly independent columns, its pseudoinverse is:
A+ = (ATA)-1AT
If A has linearly independent rows, its pseudoinverse is:
A+ = AT(AAT)-1
Our example matrix has full row rank, so we can use the second formula to independently verify the result.
[ 6 5 ] AA^T = [ 5 6 ]
The determinant is:
det(AAT) = 36 - 25 = 11
Therefore:
1 [ 6 -5 ]
(AA^T)^-1 = -- × [ -5 6 ]
11
Multiplying by AT:
1 [ 1 2 ] [ 6 -5 ]
A+ = -- × [ 2 1 ] × [ -5 6 ]
11 [ -1 -1 ]
This gives:
[ -4/11 7/11 ]
A+ = [ 7/11 -4/11 ]
[ -1/11 -1/11 ]
Again, the result is identical to the pseudoinverse obtained through SVD.
However, SVD is generally preferable when working with rank-deficient or poorly conditioned matrices, because the alternative formulas require the corresponding matrix products to be invertible and can amplify numerical conditioning problems.
One of the most interesting applications of the pseudoinverse is numerical inverse kinematics for robotic manipulators.
In differential kinematics, the Jacobian matrix relates joint velocities to the corresponding end-effector velocity:
x_dot = Jq_dot
where:
Depending on the number of joints and the dimensions of the task space, the Jacobian matrix may be rectangular or singular.
Consequently, a regular matrix inverse may not exist.
By using the Moore-Penrose pseudoinverse, we can calculate a minimum-norm least-squares joint velocity solution:
q_dot = J+x_dot
For an iterative inverse kinematics algorithm, the joint configuration can be updated using:
Δq = αJ+e
qnew = qcurrent + Δq
where e represents the task-space error and α is a positive step-size parameter.
The Jacobian is recalculated at each iteration until an acceptable error tolerance is reached or a stopping condition is satisfied.
For redundant robotic manipulators, the pseudoinverse provides the minimum-norm joint update among the least-squares solutions.
Although the pseudoinverse can be calculated for singular matrices, very small non-zero singular values may produce excessively large joint velocity commands when their reciprocals are taken.
This can result in unstable or impractical motion near robotic singularities.
One common alternative is the Damped Least Squares method:
Jd = JT(JJT + μ2I)-1
where μ is a positive damping parameter.
The joint velocity solution becomes:
q_dot = Jdx_dot
Damping reduces the sensitivity of the inverse kinematics calculation to small singular values, at the cost of introducing some task-space error. The damped inverse is not generally identical to the Moore-Penrose pseudoinverse.
| Property | Regular Inverse | Moore-Penrose Pseudoinverse |
|---|---|---|
| Notation | A-1 | A+ |
| Matrix dimensions | Square only | Square or rectangular |
| Singular matrices | Does not exist | Exists |
| Uniqueness | Unique when it exists | Always unique |
| Calculation methods | Adjugate, Gauss-Jordan elimination, LU decomposition | Singular Value Decomposition |
| Linear system solutions | Unique exact solution | Minimum-norm least-squares solution |
| Robotic applications | Invertible square Jacobian matrices | General rectangular or rank-deficient Jacobian matrices |
The regular matrix inverse is defined only for non-singular square matrices. The Moore-Penrose pseudoinverse extends the concept of matrix inversion to rectangular and singular matrices.
Singular Value Decomposition provides a general and numerically reliable method for calculating the pseudoinverse by decomposing a matrix into its left singular vectors, singular values, and right singular vectors.
Understanding these mathematical concepts is particularly useful when studying robotic manipulators, Jacobian matrices, numerical inverse kinematics, optimisation, computer vision, machine learning, and control systems.
Although mathematical libraries can perform these calculations automatically, understanding the underlying mathematical procedure provides valuable insight into the behaviour and limitations of numerical algorithms.

RoboMall was developed by Antonius (w1sdom) in 2023, The robot was designed to be operated in a mall. The purpose is that mall visitors doesn't need to visit mall directly, instead, they can use this robot to stroll in a mall and if they deposit in RoboMall wallet system they can buy things on mall, then the goods will be delivered by couriers.
Robotsoft LightBox is a solar powered outdoor lighting. Features : water proof, controlled by voice & android application. This product was created by Antonius (w1sdom). This product was created for his startup Robotsoft in 2020.
Robotsoft FloorLight is a solar powered outdoor lighting. Features : water proof, controlled by voice & android application. This product was created by Antonius (w1sdom). This product was created for his startup Robotsoft in 2020.
Robotsoft Torch is a solar powered outdoor lighting. Features : water proof, controlled by voice & android application. This product was created by Antonius (w1sdom). This product was created for his startup Robotsoft in 2020.
Solar Powered Electrical Generator. This generator created by Antonius (w1sdom). This product created for his startup Robotsoft in 2020.
The first hacker robot that I created. This robot was developed in 2014. Some demo videos were posted in Youtube around 2016. This robot can explains about low level exploitation techniques. Robot skills : can hack wifi (wpa cracking using aircrack), evil twin, wifi deauth, arp cache poisoning. My old video channel --> https://www.youtube.com/@antoniusringlayer/videos
I planned to develop a spy robot, but this robot was too big. The chassis was created using metals. Developed in 2017, posted in youtube around 2019. Developed by Antonius (w1sdom)

Airhax is a wireless network auditor gadget. This device was created in 2015. This gadget functions : wifi cracking, evil twin, wifi deauth, arp poisoning. Developed by Antonius (w1sdom / sw0rdm4n / ev1lut10n / robotsoft)
I built this robot in 2014. It is a shy robot that is afraid of humans. I used 3 ultrasonic sensors.
A large-scale prototype robot powered by a mini PC and an Arduino, built as a personal project rather than a commercial product. At first, I planned to equip it with high-torque servos and an airsoft gun, but I realized that could be dangerous, so I scrapped the idea. Real hacking should be harmless. Build 2017 - by Prof. Antonius Robotsoft

Various Robots (finished and unfinished) - build by Antonius Robotsoft (w1sdom).
A short guide on identifying resistor value. This post was taken from my old blog post : https://sw0rdm4n.wordpress.com/2014/12/06/identifying-resistor-value/
Tlc5940 is a 16 channel led driver. Since this IC has pwm control ability we can use this IC for controlling up to 16 servo(s).
Kinematics is a branch of mathematics, physics and classic mechanical engineering. There are 2 mostly used kinematics in robotic field, they are : forward kinematics and inverse kinematics. Forward kinematics is frequently used to calculate the position of end effector when we know the degree value of each joint, meanwhile inverse kinematics is used to compute the degree of each joint when we know the position of the end effector.
This post was taken from my old blog post in 2015. Haxtronic was my first generation hacker robot that I built from 2013-2015
An introduction to matrix determinants in linear algebra, explaining how to calculate determinants using Sarrus' rule and Laplace expansion through step-by-step mathematical examples.
A step-by-step guide to calculating matrix inverses and Moore-Penrose pseudoinverses using the adjugate method and Singular Value Decomposition (SVD), with manual calculations, Python NumPy implementations, and applications in robotic inverse kinematics.
An introduction to first-order partial derivatives in multivariable calculus, featuring step-by-step calculations for functions of two and three variables and their relevance to Jacobian matrices and robotic inverse kinematics.
An exploration of Convolutional Neural Networks (CNNs) for object recognition and detection, covering mathematical foundations, feature extraction, activation functions, and popular deep learning architectures such as LeNet, VGG16, ResNet, and RetinaNet, with practical Python and Keras examples.
In this guide, we are going to train a model using keras retinanet to detect and localize a custom object : “cardboard box” from the image.
Technical guide on convolutional operations behind convolutional neural network.
An introduction to four common types of electrical switches (SPST, SPDT, DPST, and DPDT), explaining their contact configurations, operating principles, and practical applications through simple diagrams and real-world examples.
This tutorial is about motor dc control using uln2803 ic. Taken from my old blog post.
Robohax is dedicated to provide creative, innovative technological innovations that benefits humanity.
Our projects range from autonomous robots, electronic devices and IoT devices for commercial / business to custom robots & hacking gadgets for physical penetration testing.
Robohax was founded by Antonius. Antonius (w1sdom) is a roboticist, technology inventor, hardware hacker, low level hacker & electronic engineer based in Indonesia.
Robomall (2023)
RoboHax is a teleoperated robot that allows shoppers to visit shopping malls without having to be there in person. Users can remotely navigate the mall, browse storefronts, explore products, and shop as if they were physically there. To make purchases, users can add funds to their RoboWallet, and their purchases will be delivered to their doorstep through an on-demand courier service.
Haxtronic (2014)
The concept behind the world's first hacking robot, designed to perform WPA cracking, Evil Twin Wi-Fi attacks, and Wi-Fi deauthentication. The robot is also equipped with Artificial Narrow Intelligence (ANI) specialized in cybersecurity, enabling it to explain low-level exploitation concepts and techniques. Natural language processing is powered by the Natural Language Toolkit (NLTK).
The first hacker from Indonesia who confirmed to have written a paper for Phrack.
Paper : UAF Exploitation in The Sheaves Era
This paper presents a novel heap-based use-after-free exploitation technique for the Linux 7.0 kernel, developed by Antonius (w1sdom).
Completed robots, electronics, hacking gadgets and other hardware projects.
Prototypes and experimental builds currently in development.
Demos, tutorials and project walkthroughs.
Technical write-ups on robotics, electronics, hacking gadgets and more.
Profile, disciplines and links.