<div dir="ltr"><div class="gmail_default" style=""><font face="garamond, times new roman, serif">Dear NCL'ers,</font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif">I am having a problem with inverting the matrix using NCL that does not make any sense. </font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif"><br></font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif">I double-checked both the routines: inverse_matrix() as well as solve_linsys() and both are functioning well for sample matrices that I am trying out. I even compared their answers to Matlab and they were perfectly right. However, when I use any of the two routines for the below matrix A: </font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif"><br></font></div><div class="gmail_default" style="">
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">write_matrix(A,"9f11.7", False)</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif">A = </font></div><div class="gmail_default" style="">
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space" style=""> </span>0.4000000 -0.0000000 -0.1000000 -0.0000000 -0.1000000<span class="gmail-Apple-converted-space" style=""> </span>0.3077683 -0.0000000<span class="gmail-Apple-converted-space" style=""> </span>0.0726542 -0.0000000</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>-0.0000000<span class="gmail-Apple-converted-space"> </span>0.1500000 -0.0000000 -0.1000000 -0.0000000 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.1902113 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.0363271</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>-0.1000000 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.1500000<span class="gmail-Apple-converted-space"> </span>0.0000000 -0.1000000 -0.1175570 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.1538842 -0.0000000</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>-0.0000000 -0.1000000<span class="gmail-Apple-converted-space"> </span>0.0000000<span class="gmail-Apple-converted-space"> </span>0.1500000 -0.0000000 -0.0000000 -0.1538842 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.1175570</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>-0.1000000 -0.0000000 -0.1000000 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.1500000 -0.0363271 -0.0000000 -0.1902113 -0.0000000</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>0.3077683 -0.0000000 -0.1175570 -0.0000000 -0.0363271<span class="gmail-Apple-converted-space"> </span>0.2500000<span class="gmail-Apple-converted-space"> </span>0.0000000 -0.0000000 -0.0000000</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>-0.0000000<span class="gmail-Apple-converted-space"> </span>0.1902113 -0.0000000 -0.1538842 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.0000000<span class="gmail-Apple-converted-space"> </span>0.2500000<span class="gmail-Apple-converted-space"> </span>0.0000000<span class="gmail-Apple-converted-space"> </span>0.0000000</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>0.0726542 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.1538842 -0.0000000 -0.1902113 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.0000000<span class="gmail-Apple-converted-space"> </span>0.2500000 -0.0000000</font></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="monospace"><span class="gmail-Apple-converted-space"> </span>-0.0000000<span class="gmail-Apple-converted-space"> </span>0.0363271 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.1175570 -0.0000000 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.0000000 -0.0000000<span class="gmail-Apple-converted-space"> </span>0.2500000</font></span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"><font face="monospace"> </font></span></span></p></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif">The inverse that NCL computes is totally wrong. That is: One, it does not satisfy the identity, A Ainv = Identity Matrix. Two, for the same values, it is very different from what Matlab produces and the one that Matlab produces satisfies the identity matrix test. Can someone please help me understand as to what is wrong with the above matrix and how to circumvent this problem? </font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif"><br></font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif">I read in previous NCL help that I could use solve_linsys(A, Identity matrix) and that should give me the inverse. However, that does not work for this particular A as well. It does work for other sample As that I tried. </font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif"><br></font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif">Please offer any advice if you have run into something like this before. </font></div><div class="gmail_default" style=""><font face="garamond, times new roman, serif"><br></font></div><div><font face="garamond, times new roman, serif"><span class="gmail_default" style="">Warm Regards, </span></font></div><div><span class="gmail_default" style=""><font face="garamond, times new roman, serif">Prashanth </font></span></div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"></div></div></div>