The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
MPINVERT: Moore-Penrose Inverse of a Matrix
08-29-2014, 09:30 PM
Post: #1
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] ]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
MPINVERT: Moore-Penrose Inverse of a Matrix - Eddie W. Shore - 08-29-2014 09:30 PM



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