HP Forums
Not returning correct Matrix Calculation - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Not returning correct Matrix Calculation (/thread-16823.html)



Not returning correct Matrix Calculation - Amer7 - 04-27-2021 06:47 PM

My calculator is not giving me the correct matrix calculation.
Code:

2568.0000    -2568.00            1    0
2568.0000    2568.00000    0    1
3852.1284    -2568.00            1    0
2568.0000    3852.12840    0    1
3536.9834    -3411.36           1    0
3411.3569    3536.98344    0    1

That is Matrix A

Matrix O 
-4851346.102
-6513502.217
-4850456.274
-6513809.817
-4850472.619
-6513149.860

TRN(A)*A should be
58770372.8276     0.0000              9957.1118    8547.3569
0.0000                   58770372.8276     -8547.3569    9957.1118
9957.1118           -8547.3569      3.0000            0.0000
8547.3569            9957.1118      0.0000            3.0000

Inverse(TRN(A)*A) should be
7.29974E-07    -1.81352E-22    -0.002422813    -0.002079784
-2.53893E-21    7.29974E-07    0.002079784    -0.002422813
-0.002422813    0.002079784    14.30029098    0
-0.002079784    -0.002422813    -4.54077E-14    14.30029098

But I get different numbers than in Excel, im using Shift + devide key to inverse. Can someone explain, and later in my calculation i get wrong answer because of Inverse mistake.

TRN(A)*O should be
-1.03972E+11
-23394687040
-1.46E+07
-1.95E+07

- I get this OK, But my issue is here

M=( Inverse((TRN(A)*A) * (TRN(A)*O)
-0.6929740
0.2395352
4853740.802
6514666.637

But I get:
0.6929740
-0.2395352
-4853740.802
-6514666.637
Can someone explain why this is happening? - Im not writing a program im manually doing the calculation on Home screen.

And later 
A*M+O should be
0.017
-0.011
-0.023
-0.017
0.006
0.027

but I get
0.03314
-0.01158 
etc. - WRONG

I have tried to multiply the M matrix with (-1) but again calculation of O seems wrong.

What is the best command for finding Inverse matrix ? same happens when i use inv(Matrix that i want to invert)
[attachment=9421]


RE: Not returning correct Matrix Calculation - Albert Chan - 04-27-2021 08:09 PM

Hi, Amer7

Tried this in Numpy, Excel numbers were wrong.

>>> from numpy import *
>>> A = array([
... [2568.0000, -2568.00 , 1, 0],
... [2568.0000, 2568.00000, 0, 1],
... [3852.1284, -2568.00 , 1, 0],
... [2568.0000, 3852.12840, 0, 1],
... [3536.9834, -3411.36 , 1, 0],
... [3411.3569, 3536.98344, 0, 1]])
>>> B = dot(transpose(A), A)
Code:
>>> print B
[[  5.87703727e+07  -1.08281943e+01   9.95711180e+03   8.54735690e+03]
 [ -1.08281943e+01   5.87703941e+07  -8.54736000e+03   9.95711184e+03]
 [  9.95711180e+03  -8.54736000e+03   3.00000000e+00   0.00000000e+00]
 [  8.54735690e+03   9.95711184e+03   0.00000000e+00   3.00000000e+00]]
>>> print linalg.inv(B)
[[  7.29974488e-07   3.48034952e-13  -2.42281154e-03  -2.07978531e-03]
 [  3.48034952e-13   7.29972621e-07   2.07977844e-03  -2.42280733e-03]
 [ -2.42281154e-03   2.07977844e-03   1.43002735e+01   1.61304069e-05]
 [ -2.07978531e-03  -2.42280733e-03   1.61304069e-05   1.43002770e+01]]



RE: Not returning correct Matrix Calculation - Amer7 - 04-27-2021 08:20 PM

Thank you Albert for numerous replies, I get the same numbers as you on my calculator. I guess something is wrong in Excel ( all formulas seemed ok). - I really doubt these are calculations from the teacher. The excel all matches up, with control calculations. Even my friends that use TI get the same numbers


RE: Not returning correct Matrix Calculation - Albert Chan - 04-27-2021 10:56 PM

(04-27-2021 08:20 PM)Amer7 Wrote:  I guess something is wrong in Excel ( all formulas seemed ok).

It is possible the problem is not Excel.
From your attached screenshot, there were a picture suggesting A51 = A62, A61 = -A52.

Your provided A (row 5 and row 6) does not match this symmetrical pattern.
Not terribly off, but enough to mess up the numbers.


RE: Not returning correct Matrix Calculation - Amer7 - 04-28-2021 05:25 AM

(04-27-2021 10:56 PM)Albert Chan Wrote:  
(04-27-2021 08:20 PM)Amer7 Wrote:  I guess something is wrong in Excel ( all formulas seemed ok).

It is possible the problem is not Excel.
From your attached screenshot, there were a picture suggesting A51 = A62, A61 = -A52.

Your provided A (row 5 and row 6) does not match this symmetrical pattern.
Not terribly off, but enough to mess up the numbers.

I have found the Issue, Im not sure why this happens. When number in column F have in front of them - ( minus, aka they are negative) Inverse matrix is not going to be the same as in Excel.
So when I input O matrix as all positive numbers I get inverse matrix correct.
And in last matrix calculation ( excel uses formula example (trn(A)*N) + O and when I adjust this to (trn(A)*N) - O I get everything correct.

I'm not sure why this difference is happening between calculator and Excel.
-Downloaded a virtual TI Nspire to check, they also get the same Matrix as we on our HP Prime.
-So its something querk of Excel.