3
$\begingroup$

I have noticed that Sign function can be very well applied to matrices using MatrixFunction. It even works on some zero divisors, such as {{1,1},{1,1}}. But how does it work and what is its meaning?

For instance, I noticed that when applied to split-complex numbers in matrix form it takes 9 possible values: $0,1,-1, j, -j, 1/2+j/2,1/2-j/2, -1/2+j/2, -1/2-j/2$. This is in contrast to complex numbers, where the set of values is infinite.

When applied to dual numbers, it gives 5 different values.

The usual rule $\text{sign } (AB)=\text{sign }A\cdot \text{sign } B$ still holds though.

It can give totally complicated results, for instance, when applied to a tessarine $1+i+j$:

Unprotect[Power];
Power[0, 0] = 1;
Protect[Power];
$Pre = If[FreeQ[#, J], #, Module[{tmp},
     tmp = Evaluate[
        MatrixFunction[Function[J, #], {{0, 1}, {1, 0}}]] // 
       FullSimplify;
           tmp /. {{a_, b_}, {b_, a_}} -> a + J b]] &;
Sign[J + 1 + I]

It produces: $\left(\frac{1+\frac{i}{2}}{\sqrt{5}}-\frac{i}{2}\right) j+\left(\frac{1}{5}+\frac{i}{10}\right) \left(\sqrt{5}+(1+2 i)\right)$

$\endgroup$
11
  • 3
    $\begingroup$ But how does it work is it not just element by element? Sign[{{1, -8}, {1, 7}}] gives {{1, -1}, {1, 1}} so the Sign was applied to each element of the matrix? resulting in new matrix with only 1 and -1 in it. but may be I am overlooking something deeper in your question. $\endgroup$
    – Nasser
    Nov 5, 2021 at 19:16
  • 1
    $\begingroup$ @Nasser in your example you do not use MatrixFunction. Without it, a function applies to a matrix element-wise. $\endgroup$
    – Anixx
    Nov 5, 2021 at 19:31
  • 1
    $\begingroup$ @Nasser But try MatrixFunction[Sign, {{1, -8}, {-1, 7}}] and you will get a more complicated result $\left( \begin{array}{cc} -\frac{3}{\sqrt{17}} & -\frac{8}{\sqrt{17}} \\ -\frac{1}{\sqrt{17}} & \frac{3}{\sqrt{17}} \\ \end{array} \right)$. $\endgroup$
    – Anixx
    Nov 5, 2021 at 19:35
  • 1
    $\begingroup$ Sign does work element by element. But there is a $Pre here and some magical handling of the symbol J so it's not obvious what to expect in the result. You might want to break this down into separate steps to understand exactly where it departs from expectations. $\endgroup$ Nov 5, 2021 at 20:26
  • 1
    $\begingroup$ The documentation has examples where a symbolic scalar function is used, e.g., MatrixFunction[f, {{1, -8}, {-1, 7}}]. As long as no derivatives of the scalar function occur, substituting Sign for f will yield the results you see. $\endgroup$
    – Carl Woll
    Nov 5, 2021 at 20:53

1 Answer 1

3
$\begingroup$
Format[a[n_, m_]] := Subscript[a, Row[{n, m}]]

mat = Array[a, {2, 2}];

(sgnmat = MatrixFunction[Sign, mat] // FullSimplify)

enter image description here

(sgnmat2 = MatrixFunction[#/Abs[#] &, mat] // FullSimplify)

enter image description here

MatrixFunction[Sign, {{1, -8}, {1, 7}}]

(* {{1, 0}, {0, 1}} *)

% === (sgnmat /. Thread[Flatten[mat] -> Flatten[{{1, -8}, {1, 7}}]])

(* True *)

%% === (sgnmat2 /. Thread[Flatten[mat] -> Flatten[{{1, -8}, {1, 7}}]])

(* True *)

MatrixFunction[Sign, {{1, -8}, {-1, 7}}] // Simplify

(* {{-(3/Sqrt[17]), -(8/Sqrt[17])}, {-(1/Sqrt[17]), 3/Sqrt[17]}} *)

% === (sgnmat /. Thread[Flatten[mat] -> Flatten[{{1, -8}, {-1, 7}}]])

(* True *)

%% === (sgnmat2 /. 
    Thread[Flatten[mat] -> Flatten[{{1, -8}, {-1, 7}}]] // Simplify)

(* True *)
$\endgroup$
2
  • $\begingroup$ This rises a question, what is Abs when applied to matrices. $\endgroup$
    – Anixx
    Nov 5, 2021 at 20:58
  • $\begingroup$ @Anixx - For an input of {{0, 1}, {1, 0}} I get a result of {{0, 1}, {1, 0}} for all three evaluations. $\endgroup$
    – Bob Hanlon
    Nov 6, 2021 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.