0
$\begingroup$

Question:

Let i be an n-level identity matrix and j be an n-level matrix with all elements of 1.

Let n-order matrix m be

$M=\left(\begin{array}{ccccc}k & \lambda & \lambda & \cdots & \lambda \\ \lambda & k & \lambda & \cdots & \lambda \\ \vdots & \vdots & \vdots & & \vdots \\ \lambda & \lambda & \lambda & \cdots & k\end{array}\right)$

How to express m in the form of x i + y j, where x and y are coefficients.

My code:

When n is a definite positive integer, I can successfully run the code to solve x and y.

For example, n==5:

Clear["Global`*"];

m = DiagonalMatrix[Table[k - \!\(TraditionalForm\`\[Lambda]\), {5}]] +
   ConstantArray[\!\(TraditionalForm\`\[Lambda]\), {5, 5}]

i = IdentityMatrix[5]

j = ConstantArray[1, {5, 5}]

Reduce[x*i + y*j == m, {x, y}]

$\mathrm{x}=\mathrm{k}-\lambda \operatorname{\& \& } \mathrm{y}==\lambda$

But when n is an uncertain positive integer (just a symbolic variable), the code fails.

Clear["Global`*"];

$Assumptions = (m | i | j) \[Element] Matrices[{n, n}];

m[n_Integer?Positive] := 
 DiagonalMatrix[Table[k - \!\(TraditionalForm\`\[Lambda]\), {n}]] + 
  ConstantArray[\!\(TraditionalForm\`\[Lambda]\), {n, n}]

i[n_Integer?Positive] := IdentityMatrix[n];

j[n_Integer?Positive] := ConstantArray[1, {n, n}];

Reduce[x*i[n] + y*j[n] == m[n], {x, y}]

$\left(j[n] \neq 0 \& \& y=\frac{-x i[n]+m[n]}{j[n]}\right)||\left(j[n]=0 \& \& i[n] \neq 0 \& \& x=\frac{m[n]}{i[n]}\right)||(m[n]=0 \& \& j[n]=0 \& \& i[n]=0)$

I wonder if MMA can solve this problem?

$\endgroup$

1 Answer 1

1
$\begingroup$

Does this work for you?

ident[i_, j_] := KroneckerDelta[i, j]
jmat[i_, j_] := 1
mmat[i_, j_] := (k - \[Lambda])  KroneckerDelta[i, j] + \[Lambda]

then:

res = Assuming[
 {i \[Element] Integers && j \[Element] Integers},
 Reduce[x ident[i, j] + y jmat[i, j] == mmat[i, j], {x, y}, Reals]
 ]

gives me: enter image description here

and,

FullSimplify[res]

gives me enter image description here

$\endgroup$

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.