0

I have two matrices - s1 and s2.

I want their sum to remain unevaluated.

For instance, the command

s1 + s2 // MatrixForm

should result to two separate matrices joined by the plus operator.

I guess that I have to wrap s1 + s2 inside a function like Hold or Unevaluated, but I cannot find the proper workaround.

Any ideas?

Sektor
  • 3,320
  • 7
  • 27
  • 36
Dimitris
  • 4,794
  • 22
  • 50

1 Answers1

1
s1 = {{8, 6, 6, 1}, {9, 8, 4, 4}, {5, 3, 5, 5}, {10, 5, 6, 2}};
s2 = {{9, 1, 10, 5}, {1, 9, 1, 3}, {8, 4, 4, 9}, {2, 9, 6, 2}};
Apply[
 HoldForm[#1 + #2] &, 
 MapThread[List, {s1, s2}, 2], {2}] // MatrixForm

$\left( \begin{array}{cccc} 8+9 & 6+1 & 6+10 & 1+5 \\ 9+1 & 8+9 & 4+1 & 4+3 \\ 5+8 & 3+4 & 5+4 & 5+9 \\ 10+2 & 5+9 & 6+6 & 2+2 \\ \end{array} \right)$

Or

SetAttributes[plus, Listable]
Apply[
 HoldForm[#1 + #2] &, plus[s1, s2], {2}] // MatrixForm

(same result)

xyz
  • 605
  • 4
  • 38
  • 117