A matrix can also be singular if the determinant is very large, 'cause that
means the determinant of its inverse (= the reciprocal of its determinant)
is very small.
det=: -/ .*
H=: %@>:@(+/~)@i. NB. Hilbert matrix
H 7
1 0.5 0.333333 0.25 0.2 0.166667 0.142857
0.5 0.333333 0.25 0.2 0.166667 0.142857 0.125
0.333333 0.25 0.2 0.166667 0.142857 0.125 0.111111
0.25 0.2 0.166667 0.142857 0.125 0.111111 0.1
0.2 0.166667 0.142857 0.125 0.111111 0.1 0.0909091
0.166667 0.142857 0.125 0.111111 0.1 0.0909091 0.0833333
0.142857 0.125 0.111111 0.1 0.0909091 0.0833333 0.0769231
det H 7
4.8358e_25
det %. H 7
2.06791e24
% det %. H 7
4.8358e_25
H 7x
1 1r2 1r3 1r4 1r5 1r6 1r7
1r2 1r3 1r4 1r5 1r6 1r7 1r8
1r3 1r4 1r5 1r6 1r7 1r8 1r9
1r4 1r5 1r6 1r7 1r8 1r9 1r10
1r5 1r6 1r7 1r8 1r9 1r10 1r11
1r6 1r7 1r8 1r9 1r10 1r11 1r12
1r7 1r8 1r9 1r10 1r11 1r12 1r13
det H 7x
1r2067909047925770649600000
det %. H 7x
2067909047925770649600000
On Fri, Jul 11, 2014 at 8:05 AM, Jon Hough <[email protected]> wrote:
> Got it. Thank you.
>
> Although, I've never seen -/ .* before. Is it in the Dictionary somewhere?
>
> > Date: Fri, 11 Jul 2014 06:52:37 -0700
> > From: [email protected]
> > To: [email protected]
> > Subject: Re: [Jprogramming] Testing for singular matrices
> >
> > A matrix M is singular iff 0 = -/ .* M (determinant is 0). Matrix
> algebra
> > on a computer is a snakepit so sometimes you may have to a number with
> tiny
> > magnitude, instead of 0. One of the pleasures of rational numbers is the
> > ability to use 0 here, no ifs or buts.
> >
> >
> >
> > On Fri, Jul 11, 2014 at 6:46 AM, Jon Hough <[email protected]> wrote:
> >
> > > Reading through the dictionary, I see that %. is only defined for
> > > non-singular matrices.
> > > http://www.jsoftware.com/help/dictionary/d131.htm
> > >
> > > If I accidentally use a singular matrix, I get a domain error. So my
> > > question is, what is the best way to test for non-singularity in J?for
> 2x2
> > > matrices, it is pretty simple. But for 8x8 matrices (for example) is
> there
> > > a standard verb used to test for singularity?
> > >
> > >
> > >
> > >
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm