MPINVERT: Moore-Penrose Inverse of a Matrix +- HP Forums (http://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: MPINVERT: Moore-Penrose Inverse of a Matrix (/thread-2037.html) |
MPINVERT: Moore-Penrose Inverse of a Matrix - Eddie W. Shore - 08-29-2014 04:30 PM 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] ] |