1
$\begingroup$

I need to solve the system of linear equations $S_i = \sum_ {r = 1}^\lambda x_ {r, i} E_r$, where $S_i$ is a $\lambda$ - dimensional vector, $i$ runs from 1 to $n$, $r$ runs from 1 to $\lambda$, and $x$ is a $\lambda\times n$ matrix.

I have no idea how to typeset that in Mathematica when I don' t know the values of $n$ and $\lambda$. The $S_i$ come from datasets of different sizes, and I build the $E_r$ from said datasets.

Thank you very much in advance.

Edit - Maybe this will help explain beter: I want to avoid having to type

Solve[S[[i,1]]==x[[1,i]]E[[1,1]] + x[[2,i]]E[[1,2]] + ...
   && S[[i,2]]== ...
   && ...
   ];

for $\lambda$ rows, each one with $\lambda$ elements. There must be a way to generalise this and typeset in a much simpler way which will then work for any matrix I feed into the code regardless of its dimensions.

Thanks

$\endgroup$
3
  • 1
    $\begingroup$ What about: eq= Table[S[[i]] == Sum[x[[r, i]] E[[r]], {r, \[Lambda]}], {i, n}] $\endgroup$ Oct 13, 2021 at 11:00
  • $\begingroup$ @DanielHuber, and then just solve eq for x? $\endgroup$
    – LNah
    Oct 13, 2021 at 22:40
  • $\begingroup$ Yes, eq gives the equations for x $\endgroup$ Oct 14, 2021 at 7:27

1 Answer 1

1
$\begingroup$
Clear["Global`*"]

$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)

You cannot use E as a variable name since it is used for the exponential constant. Use [DoubleStruckCapitalE] instead.

$Assumptions = Element[i | λ | n, Integers] && 
  i > 0 && λ > 0 && n > 0 && 
  Element[\[DoubleStruckCapitalE] | S, Vectors[λ]] && 
  Element[x, Matrices[{λ, n}]];

Format[\[DoubleStruckCapitalE][r_]] := 
  Subscript[Style[\[DoubleStruckCapitalE], Italic], r];

Format[S[i_]] := Subscript[S, i];

Format[x[r_, i_]] := Subscript[x, r, i]

(eqn = S[i] == 
    Sum[HoldForm[x[r, i]*\[DoubleStruckCapitalE][r]], {r, 
      1, λ}]) // TraditionalForm

enter image description here

Or in StandardForm

eqn // ReleaseHold

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks for pointing out that E cannot be used as a variable name. I just used it here as a placeholder, but I'll keep that in mind in the future. From your answer it is still unclear to me (or maybe I was unclear in my original question) how to solve for x. So far what I've tried either throws out errors or gives me a solution of 'x', which is most unhelpful. $\endgroup$
    – LNah
    Oct 13, 2021 at 22:52

Your Answer

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

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