# What's the meaning of Sign function applied to matrices with MatrixFunction?

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)$$ • 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. Nov 5 '21 at 19:16 • @Nasser in your example you do not use MatrixFunction. Without it, a function applies to a matrix element-wise. Nov 5 '21 at 19:31 • @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)$. Nov 5 '21 at 19:35 • 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. Nov 5 '21 at 20:26
• 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. Nov 5 '21 at 20:53

Format[a[n_, m_]] := Subscript[a, Row[{n, m}]]

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

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


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


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 *)

• This rises a question, what is Abs when applied to matrices. Nov 5 '21 at 20:58
• @Anixx - For an input of {{0, 1}, {1, 0}} I get a result of {{0, 1}, {1, 0}} for all three evaluations. Nov 6 '21 at 2:12