Friday, November 4, 2016

HP Prime and Casio Prizm: Orthogonal Matrix Test



HP Prime and Casio Prizm:  Orthogonal Matrix Test

For the square matrix M, it is orthogonal when either of the following conditions are met:

(I)            M * M^T = M^T * M = I
(II)          M^-1 = M^T

The program presented on this blog entry will use the first test.  Since matrices, unfortunately, cannot be directly compared on the Casio graphing calculators, a work around with two FOR loops is implemented.

HP Prime Program ORTHOG

EXPORT ORTHOG(m)
BEGIN
// 2016-11-01 EWS
// orthogonal test
LOCAL n,p,s;
sSIZE(m);
ss(1);
nTRN(m)*m;
pIDENMAT(s);
IF n==p THEN
RETURN 1;
ELSE
RETURN 0;
END;
END;

Casio Prizm Program ORTH

1 → A
“MATRIX:”? → Mat Z
Dim Mat Z → List 26
List 26[1] → S
(Trn Mat Z * Mat Z) – Identity S → Mat Y
For 1 → R To S
For 1 → C To S
If Mat Y[R,C] ≠ 0
Then
0 → A
Break
IfEnd
Next
Next
A

Results:  0 for a non-orthogonal matrix, 1 for an orthogonal matrix
Example of an orthogonal matrix takes the form of a two dimension rotate matrix:

cos θ
-sin θ
sin θ
cos θ

For example, let θ = 0.2 rad. 
This blog is property of Edward Shore, 2016.

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...