MPINVERT: Moore-Penrose Inverse of a Matrix
08-29-2014, 09:30 PM
Post: #1
 Eddie W. Shore Senior Member Posts: 1,584 Joined: Dec 2013
MPINVERT: Moore-Penrose Inverse of a Matrix
Also known as a pseudoinverse, the Moore-Penrose inverse of a matrix, denoted by A^+ (capital A with a supersubscript of a plus sign), is an inverse of matrix. Different from the "true" matrix inverse, the Moore-Penrose inverse allows for non-square matrices. Primarily, the Moore-Penrose inverses are calculated is assist in solving linear least-square equations.

Input: MPINVERT(matrix). Execute this from Home or CAS screen.

Program:
EXPORT MPINVERT(mtx)
BEGIN
// 2014-08-27 EWS
// Moore-Penrose Matrix Inverse
LOCAL r,c,d,n;
d:=SIZE(mtx);
r:=d(1);
c:=d(2);
n:=RANK(mtx);
CASE
IF n==c THEN
RETURN (TRN(mtx)*mtx)^-1*mtx;
END;
IF n==r THEN
RETURN TRN(mtx)*(mtx*TRN(mtx))^-1;
END;
DEFAULT
RETURN "No Solution Found";
END;

END;

Examples

Matrix:
[ [ 1, 2, 3 ] [ 3, 4, 0 ] ]

Moore-Penrose Inverse:
[ [ -8/229, 31/229 ] [ 6/229, 34/229 ] [ 75/229, -33/229 ] ]

Matrix:
[ [7, 4, 6, -7] [-1, 5, 3, 3] ]

Moore-Penrose Inverse: (to four decimal places)
[ [0.0489, -0.0338] [0.0194, 0.1092] [0.0360, 0.0600] [-0.0520, 0.0800] ]
 « Next Oldest | Next Newest »

 Messages In This Thread MPINVERT: Moore-Penrose Inverse of a Matrix - Eddie W. Shore - 08-29-2014 09:30 PM RE: MPINVERT: Moore-Penrose Inverse of a Matrix - Namir - 09-01-2014, 09:11 PM RE: MPINVERT: Moore-Penrose Inverse of a Matrix - Han - 02-06-2015, 07:48 PM RE: MPINVERT: Moore-Penrose Inverse of a Matrix - salvomic - 02-06-2015, 03:09 PM RE: MPINVERT: Moore-Penrose Inverse of a Matrix - Han - 02-06-2015, 07:38 PM RE: MPINVERT: Moore-Penrose Inverse of a Matrix - salvomic - 02-06-2015, 08:40 PM RE: MPINVERT: Moore-Penrose Inverse of a Matrix - Han - 10-27-2015, 06:57 PM RE: MPINVERT: Moore-Penrose Inverse of a Matrix - salvomic - 10-28-2015, 09:02 AM

User(s) browsing this thread: 1 Guest(s)